Wire up dark mode across all Apple frontends (RFC 0007 v2)#13
Merged
Conversation
Uses the stateful appearance model from DasherCore #25: DasherCore: e8e394b5 -> fc61344f The v2 model owns appearance state at the C API layer: - dasher_get/set_appearance_mode: System / Light / Dark (persisted) - dasher_set_system_appearance: transient OS input from frontend - dasher_get/set_light_palette + dark_palette: independent prefs - dasher_set_user_palette: picker convenience (sets current side) - Resolution (mode + system + prefs -> active palette) in DasherCore - Persists to appearance_settings.xml sidecar, never clobbers the user's explicit palette choice Bridge methods added to all 4 platforms: - setSystemAppearance(dark:) - frontend reports OS state - setAppearanceMode(_:) / getAppearanceMode() - mode control - setUserPalette(_:) / getLightPalette() / getDarkPalette() Frontend wiring: - DasherApp (iOS): @Environment(\.colorScheme) + onChange - DasherMac: same @Environment(\.colorScheme) pattern - DasherVision: forced dark on appear - DasherKeyboard: traitCollectionDidChange + viewWillAppear Settings UI (DasherApp): - Appearance segmented picker: System / Light / Dark - Palette picker calls setUserPalette (works with the new model) Signed-off-by: will wade <willwade@gmail.com>
The single palette picker conflated 'which palette am I editing' with 'what mode am I in'. Users couldn't change their dark palette without first forcing Dark mode, and the mode picker sometimes bounced back. Replace with two independent palette pickers: - 'Light Palette' — edits the light preference via setLightPalette - 'Dark Palette' — edits the dark preference via setDarkPalette The mode picker (System / Light / Dark) above controls which palette is ACTIVE on the canvas. The two palette pickers below control which palette is USED for each appearance — independently of the current mode. Extracted palettePickerRow() helper to avoid duplicating the swatch rendering between the two pickers. Signed-off-by: will wade <willwade@gmail.com>
Fixes build error: DasherSettingsView calls setLightPalette and setDarkPalette for the dual palette pickers but those methods were not in the bridge. Signed-off-by: will wade <willwade@gmail.com>
sed appended the new methods inside setUserPalette's body instead of after its closing brace. Unmangled all three (Keyboard, Mac, Vision). Signed-off-by: will wade <willwade@gmail.com>
…View missing onAppear
Two issues found during review:
1. MacContentView: sed inserted .onAppear/.onChange after the body's
closing brace instead of before it. Moved them inside the body
as modifiers on the .toolbar.
2. VisionContentView: the sed substitution silently failed (the $ and
& characters in the pattern were interpreted by sed, not as literal
Swift code). Added .onAppear { setSystemAppearance(dark: true) }
manually.
Also verified: no stale references to the removed dasher_set_appearance
API anywhere in the Apple frontends.
Signed-off-by: will wade <willwade@gmail.com>
8bb53ea to
4dcc03f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Wires up dark mode across all four Apple frontends using DasherCore's v2 stateful appearance model (RFC 0007, reworked in DasherCore #25).
Supersedes #12 which used the removed
dasher_set_appearanceAPI.DasherCore bump
e8e394b5→fc61344f— pulls in the stateful appearance model:dasher_get/set_appearance_mode: System (default) / Light / Dark — persisted toappearance_settings.xmlsidecardasher_set_system_appearance: transient OS appearance input from the frontenddasher_get/set_light_palette+dasher_get/set_dark_palette: two independent persisted palette preferencesdasher_set_user_palette: picker convenience — sets the current-side pref and defaults the other side to the companionBridge layer
Added to all 4
DasherBridgecopies:setSystemAppearance(dark:)dasher_set_system_appearancesetAppearanceMode(_:)dasher_set_appearance_modegetAppearanceMode()dasher_get_appearance_modesetUserPalette(_:)dasher_set_user_palettegetLightPalette()dasher_get_light_palettegetDarkPalette()dasher_get_dark_paletteFrontend wiring
@Environment(\.colorScheme)+.onAppear+.onChangeinContentView@Environment(\.colorScheme)+.onAppear+.onChangeinMacContentView.onAppear { setSystemAppearance(dark: true) }— visionOS is always darktraitCollectionDidChange+viewWillAppearinKeyboardViewControllerSettings UI
DasherApp's Customization tab now has:
setUserPalette(works with the dual-pref model — sets the current side, defaults the other side to the companion)When mode is System: the palette auto-switches when iOS flips between light and dark. The user's chosen palette is the light preference; its dark companion is used automatically.
When mode is Light or Dark: forces that appearance regardless of system setting.
How it works end-to-end
Testing checklist