Skip to content

Add day and night colors, and default to a Material 3 DayNight theme - #137

Merged
freakboy3742 merged 2 commits into
beeware:mainfrom
kattni:claude/affectionate-kapitsa-1d8ec7
Dec 2, 2026
Merged

freakboy3742 merged 2 commits into
beeware:mainfrom
kattni:claude/affectionate-kapitsa-1d8ec7

Conversation

@kattni

@kattni kattni commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Toga's Android backend is moving to Material 3, and Briefcase's Toga bootstrap is moving to a Theme.Material3.DayNight theme. In dark mode, that theme expects a light primary color, and uses dark text (#381E72) on buttons filled with it. This template always sets colorPrimary to the app's primary_color (#008577 by default), so in dark mode those buttons get dark text on a dark fill.

This PR:

  • Lets primary_color, primary_color_dark and accent_color be either a single color, used in both light and dark mode, or a table with day and night values, such as primary_color = {day = "#5B2A8C", night = "#D4BBFF"}. Night values are written to a new values-night/colors.xml. A table needs both keys. If one is missing, briefcase create fails with a configuration error.
  • Adds primary_text_color, which sets colorOnPrimary and takes the same forms. It defaults to #FFFFFF, so these buttons are readable in dark mode with no configuration.
  • Changes the default base_theme from Theme.AppCompat.Light.DarkActionBar to Theme.Material3.DayNight.
  • Always adds com.google.android.material:material:1.13.0, next to the AppCompat dependency the template already adds. colorOnPrimary is defined by the Material library, so including it keeps every app building, whatever its theme.

Effect on existing apps, checked on an Android 15 emulator in light and dark mode:

  • An app that sets base_theme and uses single colors looks the same. An app with Theme.AppCompat.Light.DarkActionBar and released Toga 0.5 was pixel-identical with the old and new template, in both modes.
  • An app that doesn't set base_theme gets Theme.Material3.DayNight at its next briefcase create. With Toga 0.5 it stays readable in both modes, but it looks different: the app bar no longer uses the primary color, and the app follows dark mode.

Generating a full Material 3 color scheme from a seed color is a possible later alternative, tracked in beeware/briefcase#3167.

Note: Briefcase change

beeware/briefcase#3168 documents these settings and updates the Toga bootstrap. Because this template now provides the theme and the Material library, the bootstrap no longer sets base_theme or lists the Material dependency. beeware/briefcase#3168 must merge together with or after this PR. Otherwise, new Toga apps would get an AppCompat theme without the Material library.

PR Checklist:

  • I will abide by the BeeWare Code of Conduct
  • I have read and have followed the CONTRIBUTING.md file
  • This PR was generated or assisted using an AI tool

Assisted-by: Claude Code (Claude Opus 5.5)

The primary_color, primary_color_dark and accent_color settings, and the
new primary_text_color setting, can each be a single color used in both
modes, or a table with "day" and "night" values. Night values are written
to values-night/colors.xml.

primary_text_color sets colorOnPrimary, the text color on buttons filled
with the primary color. It defaults to white, so buttons stay readable in
dark mode.

The default base theme is now Theme.Material3.DayNight, and the Material
library is always included.

@freakboy3742 freakboy3742 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes all make sense; the only questions relate to bigger picture issues raised on the matching Briefcase PR:

  1. Whether the surface color should be customizable
  2. Whether material should be promoted to this template

@freakboy3742 freakboy3742 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the discussion on the Briefcase ticket, I've reverted some of the proposed changes in favour of explicit configuration on the Briefcase side; otherwise, this looks great - thanks!

@freakboy3742
freakboy3742 merged commit 6403f5c into beeware:main Dec 2, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants