Skip to content

Wire up dark mode across all Apple frontends (RFC 0007)#12

Closed
willwade wants to merge 1 commit into
mainfrom
feature/dark-mode-integration
Closed

Wire up dark mode across all Apple frontends (RFC 0007)#12
willwade wants to merge 1 commit into
mainfrom
feature/dark-mode-integration

Conversation

@willwade

Copy link
Copy Markdown
Contributor

What

Wires up dark mode across all four Apple frontends using the DasherCore appearance-aware palette system (RFC 0007, merged in DasherCore #24).

DasherCore bump

581093efe8e394b5 — pulls in:

  • 8 dark companion palette XMLs (Default Dark, Rainbow Dark, etc.)
  • 3 C API functions: dasher_set_appearance, dasher_get_palette_appearance, dasher_find_companion_palette
  • Bidirectional companion lookup so legacy palettes are paired even without metadata

Frontend integration

Bridge layer

Added setAppearance(dark: Bool) to all 4 DasherBridge copies (DasherApp, DasherMac, DasherVision, DasherKeyboard). Calls dasher_set_appearance(ctx, dark ? 2 : 1). Returns silently if no companion exists.

Per-platform wiring

Platform How appearance is observed
DasherApp (iOS) @Environment(\.colorScheme) + .onChange in ContentView
DasherMac @Environment(\.colorScheme) + .onChange in MacContentView
DasherVision .onAppear { setAppearance(dark: true) } — visionOS is always dark
DasherKeyboard traitCollectionDidChange + viewWillAppear in KeyboardViewController

How it works

When the OS switches between light and dark:

  1. Frontend calls bridge.setAppearance(dark: ...)
  2. Bridge calls dasher_set_appearance(ctx, appearance)
  3. DasherCore looks up the current palette's companion
  4. If found, switches to the companion (e.g. "Default" → "Default Dark")
  5. If not found (e.g. "Yellow on Blue" has no companion), returns -1 — palette unchanged, user's explicit choice respected

Dark palettes inherit their parent's letter/group fills and override only chrome colours (background, labels, outlines, crosshair). Canvas identity stays consistent; only the background flips.

Testing checklist

  • DasherApp (iOS): switch system to dark mode → palette background flips
  • DasherApp (iOS): switch back to light → palette flips back
  • DasherMac: same test via System Settings → Appearance
  • DasherVision: always dark — confirm dark palette active on launch
  • DasherKeyboard: switch iOS dark/light → keyboard palette follows
  • Settings: pick "Yellow on Blue" → switch appearance → palette stays (no companion)

Bumps DasherCore to e8e394b5 which adds:
- 8 dark companion palette XML files (Default Dark, Rainbow Dark, etc.)
- C API: dasher_set_appearance, dasher_get_palette_appearance,
  dasher_find_companion_palette
- ColorIO/ColorPalette changes for appearance+companion metadata
- Bidirectional companion lookup for legacy palettes

Frontend integration (this commit):
- DasherBridge.setAppearance(dark:) added to all 4 bridges
  (DasherApp, DasherMac, DasherVision, DasherKeyboard)
- DasherApp (iOS): @Environment(\.colorScheme) + onChange
  calls setAppearance on appear and when system theme flips
- DasherMac: same @Environment(\.colorScheme) pattern
- DasherVision: forced dark (visionOS is always dark mode)
- DasherKeyboard: traitCollectionDidChange + viewWillAppear

When the OS switches between light and dark, each frontend calls
dasher_set_appearance(ctx, DARK/LIGHT). If the current palette has
a companion, DasherCore switches to it; if not (e.g. 'Yellow on
Blue' which is already dark), it returns -1 and the palette is left
unchanged — the user's explicit choice is respected.

Dark palettes inherit their parent's letter/group fills and override
only the chrome (background, labels, outlines, crosshair, info/warning
boxes), so the canvas identity stays consistent across appearances.

Signed-off-by: will wade <willwade@gmail.com>
@willwade

Copy link
Copy Markdown
Contributor Author

Superseded by the stateful appearance model in DasherCore #25. Will open a new PR using the new API (dasher_set_appearance_mode / dasher_set_system_appearance / dasher_set_user_palette).

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.

1 participant