Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance stringToColor with a custom defined palette from DefaultStyles #2095

Merged
merged 2 commits into from
Aug 20, 2024

Conversation

vishna
Copy link
Collaborator

@vishna vishna commented Aug 8, 2024

Description

This change allows overriding and extending colors provided by stringToColor. You're now able to define custom colors in DefautStyles e.g.:

palette: {
  "primary": Colors.red,
  "secondary": Colors.blue
}

and later use it:

BackgroundAttribute("primary")

Why?

This is particularly useful if your app has multiple themes and some limited color set per each theme. Currently there is a big switch with hardcoded values in stringToColor which cannot be customized. This PR solves this problem without introducing any breaking changes.

Related Issues

There was no issue for this.

Type of Change

  • New feature: Adds new functionality without breaking existing features.
  • 🛠️ Bug fix: Resolves an issue without altering current behavior.
  • 🧹 Code refactor: Code restructuring that does not affect behavior.
  • Breaking change: Alters existing functionality and requires updates.
  • 🧪 Tests: Adds new tests or modifies existing tests.
  • 📝 Documentation: Updates or additions to documentation.
  • 🗑️ Chore: Routine tasks, or maintenance.
  • Build configuration change: Changes to build or deploy processes.

Suggestions

This switch could be a default palette https://github.com/singerdmx/flutter-quill/blob/master/lib/src/common/utils/color.dart#L4 🤔

lib/src/common/utils/color.dart Outdated Show resolved Hide resolved
@singerdmx
Copy link
Owner

@EchoEllet please have a look

@singerdmx
Copy link
Owner

[ +2 ms] Target dart2js failed: ProcessException: Process exited abnormally with exit code 1:
../../../../.pub-cache/hosted/pub.dev/image_cropper_platform_interface-5.0.0/lib/src/models/cropped_file/html.dart:32:38:
Error: The method 'UnmodifiableUint8ListView' isn't defined for the class 'CroppedFile'.
- 'CroppedFile' is from 'package:image_cropper_platform_interface/src/models/cropped_file/html.dart' ('../../../../.pub-cache/hosted/pub.dev/image_cropper_platform_interface-5.0.0/lib/src/models/cropped_file/html.dart').
return Future.value(UnmodifiableUint8ListView(_initBytes!));
^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Compilation failed.

Not sure this error is related to your change.
@CatHood0 do you have a chance to have a look?

@CatHood0
Copy link
Collaborator

CatHood0 commented Aug 9, 2024

@CatHood0 do you have a chance to have a look?

I will. Does the failed build occur on any platform or is it only for a certain platform?

@CatHood0
Copy link
Collaborator

CatHood0 commented Aug 9, 2024

I think the version of the image_cropper could be the main problem (the last version of the package is 8.0.1):

# Plugins
image_cropper: ^5.0.1

I will make a PR solving this soon

@CatHood0
Copy link
Collaborator

CatHood0 commented Aug 9, 2024

@singerdmx UnmodifiableUint8ListView is now deprecated since Dart 3.4 see this

@singerdmx
Copy link
Owner

Ah I see

@singerdmx
Copy link
Owner

I think the version of the image_cropper could be the main problem (the last version of the package is 8.0.1):

# Plugins
image_cropper: ^5.0.1

I will make a PR solving this soon

@CatHood0 how did it go?

@singerdmx
Copy link
Owner

@vishna could you please rebase?

@vishna
Copy link
Collaborator Author

vishna commented Aug 19, 2024

@singerdmx will do it now - I was off last week

@singerdmx singerdmx merged commit 11c8bc7 into singerdmx:master Aug 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants