-
Notifications
You must be signed in to change notification settings - Fork 249
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
iOS caret color in dark mode not as expected (barely visible) #2042
Comments
@simonbengtsson To update the caret color on iOS, you need to provide a That way, you can customize the caret for iOS: |
Got it! So Since |
@simonbengtsson Yeah, you'll need to do that. |
@simonbengtsson did that work for you? If so, can you paste the code that you had to write to get the effect you want? I'd like for us to take a look at how much work that is and see if it makes sense to create an easier pathway. |
Actually no. When reassigning the
My attempt was just adding the following lines to the _buildEditor method in example_editor.dart L370. Widget _buildEditor(BuildContext context) {
final isLight = Theme.of(context).brightness == Brightness.light;
// Added code
_iosControlsController.dispose();
_iosControlsController = SuperEditorIosControlsController(
handleColor: isLight ? Colors.black : Colors.redAccent,
);
[...] |
@simonbengtsson You should try to update it on the |
Tried now, but @override
void didChangeDependencies() {
super.didChangeDependencies();
final isLight = Theme.of(context).brightness == Brightness.light;
_iosControlsController.dispose();
_iosControlsController = SuperEditorIosControlsController(
handleColor: isLight ? Colors.black : Colors.redAccent,
);
print('Reassigned ${isLight}'); // Only called once, not on theme change
} |
@simonbengtsson @matthew-carroll I took a look at this. The To solve this, the theme should be moved up, outside of @override
Widget build(BuildContext context) {
return ValueListenableBuilder(
valueListenable: _brightness,
builder: (context, brightness, child) {
return Theme(
data: ThemeData(brightness: brightness),
child: child!,
);
},
child: Builder(
// This builder captures the new theme
builder: (themedContext) {
...
}
),
);
} |
@angelosilvestre if that resolves the issue in the demo app, let's go ahead and make the change. Then let's take another look at how much code is involved with such a simple behavior. |
@matthew-carroll After taking a better look, I noticed that However, I noticed this isn't working correctly even for desktop. The color doesn't update immediately: 2024-06-24.20-31-22.movThis looks like a deeper problem in |
@angelosilvestre can you dig deeper and try to find out where the problem is? |
@matthew-carroll After taking a deeper look, I found that the cause is that When switching between light and dark mode, the only thing that we change in the editor is the font color. Because of that, only A possible solution can be achieved by making every What do you think of that approach? Do you have any other ideas? |
@angelosilvestre I'm not entirely sure about the implications here, but on the surface of the issue, I don't know why we'd want to re-run layout for color changes. Layout is generally expensive and we should only run it when layout truly changes. Is there a particular reason that you're suggesting we re-run layout for color changes? |
Because without a re-run of the layout, the overlayers won't be rebuilt, so they won't pick the new colors. |
To help me understand exactly what's happening here, can you please write a failing test and open a PR with that test failure? |
@matthew-carroll Opened #2388 |
I set handlerColor when in dark mode the cursor color still black.... |
@simonbengtsson @lucasjinreal This should now work as expected. Please see this comment #2302 (comment) |
Hi, can u point out which version start from could fix this? |
@lucasjinreal We didn't release a new pub version yet, but you can add a dependency to the latest main. |
Package Version
"super_editor, GitHub, stable branch"
To Reproduce
Actual behavior
The caret is black and hard to see since editor background is a dark grey.
Expected behavior
The caret to be visible. I expect the caret color to be red since this is set in the caretStyle and what is happening on macOS.
Platform
iOS. The issue is not happening on mac or web (or it does but the caret gets the correct color after refocusing the editor). Not tried other platforms.
Flutter version
Flutter 3.22.0 • channel stable
Framework • revision 5dcb86f68f (2 weeks ago) • 2024-05-09 07:39:20 -0500
Engine • revision f6344b75dc
Tools • Dart 3.4.0 • DevTools 2.34.3
Screenshots
This is the same problem as described in #1347, but I can reproduce every time on iOS.
The text was updated successfully, but these errors were encountered: