beeware/toga

Add property to evaluate if app is in dark mode

Closed

#2,841 opened on 2024年9月14日

GitHub で見る
 (16 comments) (0 reactions) (0 assignees)Python (3,615 stars) (624 forks)batch import
enhancementgood first issueiOSwebwindows

説明

What is the problem or limitation you are having?

Most operating systems now have a concept of "dark mode"; if you're manually setting colors for labels or other text, you need to know if you're in dark mode to be able to determine if a label color should be high or low contrast.

Describe the solution you'd like

toga.App.dark_mode should return True if the app is in dark mode, False otherwise.

It might make sense to return None on platforms where this can't be determined (e.g., the platform doesn't have an explicit concept of "dark mode". This would evaluate as false-y, while still be checked as is None.

Describe alternatives you've considered

Ideally, color selection is something that would be done with a full style sheet with media selectors; however, that requires a full CSS implementation (see Colosseum); and regardless, colosseum would still require an app's style applicator to provide the current dark/light mode as an input to the style process.

Additional context

See #2830 for the original request.

This will require an implementation on every backend, calling native APIs to determine dark mode status.

コントリビューターガイド