feat(theme): persist useWallpaperColors preference + dynamic ColorScheme branching#116
Merged
Conversation
…eme branching Adds a third DataStore key (use_wallpaper_colors, default false) with a Flow<Boolean> + suspend setter on AppPreferences, then collects it at the composition root and threads it into PyrycodeMobileTheme's existing dynamicColor parameter. The theme's internal SDK gate (Build.VERSION.SDK_INT >= S) already falls back to the brand palette on pre-S devices when the preference is true, so no Android-version branching is needed at the call site. Theme.kt is untouched — its 18+ @Preview composables continue to use the default dynamicColor = false. Invisible-by-default: the only path to flip the preference programmatically is the new setter, consumed by sibling ticket #89 (Settings switch row). Closes #88 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Author
Code Review: #88Decision: PASS Findings
SummaryThe diff matches
Mechanical / blast-radius checks
Architecture complianceMatches the convention #86 established (caller passes a |
…nching (#88) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Adds a third DataStore-backed preference (
use_wallpaper_colors, defaultfalse) onAppPreferences, with aFlow<Boolean>andsuspend setUseWallpaperColors.MainActivity.setContentcollects it next tothemeModeand passes it into the existingdynamicColor: Booleanparameter onPyrycodeMobileTheme. The theme's internalBuild.VERSION.SDK_INT >= Sgate already routes pre-S devices to the brand palette even whendynamicColor = true, so no extra SDK check is needed at the call site.Theme.ktis untouched.This slice is invisible-by-default — the only way to flip the preference is programmatically. The visible Settings switch row lands in #89.
Issue
Closes #88
Testing
./gradlew test— passes; addsuseWallpaperColors_defaultsToFalseandsetUseWallpaperColors_roundTripsBothValuestoAppPreferencesTest(realPreferenceDataStoreFactory+TemporaryFolder, mirroring the existingpairedServerExists/themeModetests). Confirmed RED → GREEN before commit../gradlew lint— clean../gradlew assembleDebug— succeeds../gradlew connectedAndroidTest— not run (no device/emulator attached in this worktree); no instrumented tests added in this slice../gradlew spotlessCheck— fails on a pre-existing violation inui/settings/ThemePickerDialog.kt(from feat(theme): persist ThemeMode preference + reactive PyrycodeMobileTheme wiring #86) that is outside this ticket's scope. The files in this diff are spotless-clean.Manual smoke test (re-collection re-renders without process restart)
Per AC:
collectAsStateWithLifecycle(initialValue = false)makesdynamicColora state read inside thesetContentcomposition, so writes viasetUseWallpaperColorstrigger recomposition and thewhenblock insidePyrycodeMobileThemere-resolves theColorScheme. I did not run an emulator-side toggle in this PR because there is no caller for the setter yet (#89 wires it). The setter is exercised by the round-trip unit test, and the live-re-theme behavior is the standard semantics ofcollectAsStateWithLifecyclealready used forthemeModein #86.Architecture compliance
Follows
docs/specs/architecture/88-use-wallpaper-colors-preference.mdexactly:pairedServerExists's shape for the new key + flow + setter.USE_WALLPAPER_COLORS = booleanPreferencesKey("use_wallpaper_colors").themeMode; theme call gainsdynamicColor = useWallpaperColors.Theme.ktnot edited — extends the feat(theme): persist ThemeMode preference + reactive PyrycodeMobileTheme wiring #86 convention of "caller passes aBoolean, theme function resolves internally."AppPreferencesis already a Koinsingle).🤖 Generated with Claude Code