beeware/toga

Conditional Colorization based on Dark Mode State

Opened this issue · 5 comments

What is the problem or limitation you are having?

Some platforms the UI dark/light can autochange based on something like time, so we need to probably implement something similar to a "color set" specifying different colors to display under dark/light mode differently, and have it automatically switch using native APIs.

Describe the solution you'd like

See above

Describe alternatives you've considered

Using a handler for users to change all colors manually; if there's a huge bunch of colors, maybe won't work so well.

Additional context

#2841 (comment)

Also closely related: #2842

I don't think #2842 is quite the same. That issue is about "I have this shade of red; give me the same color, but 25% lighter". This issue is about providing an equivalent of the CSS @media (prefers-color-scheme: dark) directive.

No, not the same, although I'd imagine that one can actually maybe generate alternative colors for dark mode using a heuristic if people are too lazy to encode their own alternative colors.

No, not the same, although I'd imagine that one can actually maybe generate alternative colors for dark mode using a heuristic if people are too lazy to encode their own alternative colors.

I was also thinking that while the simplest execution of a dark-mode-aware "less emphasized" or "more emphasized" modifier would be to perform its calculation based on the current mode and spit out a plain, precomputed Color instance... it could be very useful if there were a way to keep track of the color it's based on, and which "direction" it's supposed to go, and then update its displayed value if and when the app's dark/light mode changes.

Hrm... maybe... but what little I know of color spaces suggests the problem is a lot more complex than "invert a brightness attribute in a HSL definition".