macosui / macos_ui

Flutter widgets and themes implementing the current macOS design language.
https://macosui.github.io/macos_ui/#/
MIT License
1.82k stars 178 forks source link

Leverage `EventChannel` to listen for the system accent color #243

Open GroovinChip opened 2 years ago

GroovinChip commented 2 years ago

Currently, we are hardcoding the bizarrely-named MacosColors.controlAccentColor, which is the user's selected system accent color. (Obviously this name doesn't make much sense, but that's what Apple calls it...).

Obviously, someone making a macOS application would expect that their choice of system-level accent color would be reflected in their application unless explicitly overridden. Since macos_ui is now a plugin, we can leverage Flutter's EventChannel to listen to the native controlAccentColor's value.

This would require some refactoring to MacosColors since controlAccentColor is a static value. I'm not quite certain the best way to proceed with this at this time.

whiplashoo commented 2 years ago

Could this be of any help?

whiplashoo commented 2 years ago

Also, a more complete way of getting the accent color.

GroovinChip commented 2 years ago

Also, a more complete way of getting the accent color.

Okay, I have done a first pass on this feature via the code found above. It should be noted that this is done through MethodChannel, though, not EventChannel. I tried doing that and I kept getting null back for the color. See this gist for more on that attempt.

This code is available to browse in the accent_color_listener branch

GroovinChip commented 1 year ago

@Adrian-Samoticha this is relevant to our accuracy work.