-
Notifications
You must be signed in to change notification settings - Fork 6k
[Linux] fix and test light vs. dark theme detection #32618
Conversation
@robert-ancell and @cbracken, this is a spin-off of #32456 that I had trouble adding tests for. I have done some refactoring around P.S. I have included it all here for now for feedback but if you think the changes look good in principle, I can start splitting this into smaller PRs. |
These changes would also lay the foundations for implementing accessibility features for Linux, to make Flutter respect the high-contrast and disabled animations accessibility settings in GNOME. |
Changes make sense to me - let's split into smaller PRs. |
This follows the common naming convention for fake implementations, and makes room for a GMock-based mock implementation that registers calls and allows settings expectations. Split off from flutter#32618.
This follows the common naming convention for fake implementations, and makes room for a GMock-based mock implementation that registers calls and allows settings expectations. This is a preparation step split off from flutter#32618 that will eventually fix flutter/flutter#101438.
I started splitting off some changes but I didn't realize the bot would get mad at me for not including tests when adding code to testing/. |
Some users have reported that toggling between light and dark system theme results in Flutter detecting the opposite theme. This is because the window text color, which is used to calculate the brightness, may not have been yet refreshed when the theme change signal is emitted. This commit replaces the unreliable (and untestable) window text color -based theme detection with the simpler alternative proposed in flutter#25535 to check for a "-dark" suffix in the theme name, which is used by convention in dark GTK theme names (Yaru vs. Yaru-dark, Adwaita vs. Adwaita-dark, Pop vs. Pop-dark, ...). Ref: flutter/flutter#101438
I've rebased the remaining commits and left out the GNOME 42 color-scheme changes from this. Let's fix and test the "legacy" theme detection first. |
FlSettings is an interface that provides desktop settings and notifies changes, whereas FlSettingsPlugin merely communicates the settings to the framework. This makes it straightforward to test both separately. As a bonus, it will be easy to add FlSettings implementations for other DEs too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Let MockBinaryMessenger internally manage the FlBinaryMessenger wrapper instance and provide it via operator FlBinaryMessenger*() to avoid having to create two objects in every test. The same technique was used for MockSettings in flutter#32618.
Let MockBinaryMessenger internally manage the FlBinaryMessenger wrapper instance and provide it via operator FlBinaryMessenger*() to avoid having to create two objects in every test. The same technique was used for MockSettings in flutter#32618.
Let MockBinaryMessenger internally manage the FlBinaryMessenger wrapper instance and provide it via operator FlBinaryMessenger*() to avoid having to create two objects in every test. The same technique was used for MockSettings in flutter#32618.
Let MockBinaryMessenger internally manage the FlBinaryMessenger wrapper instance and provide it via operator FlBinaryMessenger*() to avoid having to create two objects in every test. The same technique was used for MockSettings in #32618.
…ter#34029) Let MockBinaryMessenger internally manage the FlBinaryMessenger wrapper instance and provide it via operator FlBinaryMessenger*() to avoid having to create two objects in every test. The same technique was used for MockSettings in flutter#32618.
This PR replaces the unreliable (and untestable) window text color
-based theme detection with the simpler alternative proposed in
#25535 to check for a "-dark" suffix in the theme name,
which is used by convention in dark GTK theme names (Yaru vs. Yaru-dark,
Adwaita vs. Adwaita-dark, Pop vs. Pop-dark, ...).
Partial fix to: flutter/flutter#101438
Pre-launch Checklist
///
).Before
Personally, I was able to reproduce the issue in a Pop!_OS 20.04 VM
popos-before.mp4
After
Same VM with the fix applied
popos-after.mp4