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

[BUG] - In SuperEditor it's not straightforward to theme caret/handles on mobile according to brightness #2302

Closed
miguelcmedeiros opened this issue Sep 3, 2024 · 4 comments
Assignees
Labels
area_super_reader Related to SuperReader area_supereditor Pertains to SuperEditor area_supertextfield Pertains to SuperTextField awaiting-customer-feedback Waiting for the customer to respond to us bounty_junior f:superlist Funded by Superlist time:2 type_bug Something isn't working

Comments

@miguelcmedeiros
Copy link
Collaborator

Package Version
super_editor main branch (c3190a9cc77b25d9ce18c798b1b7cdcecab13ecc)

User Info
Superlist

Details
The only way I found to consistently customize the color of caret and handles on mobile so that it changes when the brightness changes is to wrap SuperEditor with a Theme:

Theme(
  data: Theme.of(context).copyWith(
    primaryColor:
      Theme.of(context).brightness == Brightness.light
        ? Colors.black
        : Colors.white,
  ),
  child: SuperEditor(...),

Platform
iOS and Android

Flutter version
Flutter master

@miguelcmedeiros miguelcmedeiros added the type_bug Something isn't working label Sep 3, 2024
@miguelcmedeiros
Copy link
Collaborator Author

Cc @matthew-carroll

@matthew-carroll matthew-carroll added area_supereditor Pertains to SuperEditor area_supertextfield Pertains to SuperTextField bounty_junior f:superlist Funded by Superlist time:2 area_super_reader Related to SuperReader labels Sep 14, 2024
@angelosilvestre
Copy link
Collaborator

It is possible to configure SuperEditorIosHandlesDocumentLayerBuilder and SuperEditorAndroidHandlesDocumentLayerBuilder with the desired caret color, but we have a bug where it's not immediately being updated when switching the brightness.

@matthew-carroll Could you take a look at this comment to see if we can move forward?

@angelosilvestre
Copy link
Collaborator

@miguelcmedeiros

Now that #2388 is merged you should be able to set the desired colors in SuperEditorIosHandlesDocumentLayerBuilder and SuperEditorAndroidHandlesDocumentLayerBuilder. For example:

SuperEditor(
  documentOverlayBuilders: [
    DefaultCaretOverlayBuilder(
      caretStyle: const CaretStyle().copyWith(color: isLight ? Colors.black : Colors.redAccent),
    ),
    if (defaultTargetPlatform == TargetPlatform.iOS) ...[
      SuperEditorIosHandlesDocumentLayerBuilder(
        handleColor: isLight ? Colors.blue : Colors.redAccent,
      ),
      SuperEditorIosToolbarFocalPointDocumentLayerBuilder(),
    ],
    if (defaultTargetPlatform == TargetPlatform.android) ...[
      SuperEditorAndroidToolbarFocalPointDocumentLayerBuilder(),
      SuperEditorAndroidHandlesDocumentLayerBuilder(
        caretColor: isLight ? Colors.blue : Colors.redAccent,
      ),
    ],
  ],
)
Simulator.Screen.Recording.-.iPhone.15.Plus.-.2024-12-31.at.09.42.26.mp4

@miguelcmedeiros
Copy link
Collaborator Author

Thanks @angelosilvestre. Feel free to close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area_super_reader Related to SuperReader area_supereditor Pertains to SuperEditor area_supertextfield Pertains to SuperTextField awaiting-customer-feedback Waiting for the customer to respond to us bounty_junior f:superlist Funded by Superlist time:2 type_bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants