Support Dark Mode #4

Open
opened 2026-06-23 20:37:30 +00:00 by elvis · 1 comment
Owner
No description provided.
elvis added this to the pokedex project 2026-06-23 20:37:30 +00:00
Author
Owner

Plan: Support Dark Mode Configurations

To support customizable theme selections (Light, Dark, or System Default):

1. **Preferences Storage (`UserPreferences`):**
   * Define a `ThemeOption` enum (`LIGHT`, `DARK`, `SYSTEM`) and save it in `UserPreferences`.
   * Expose it as a flow in `UserPreferences`.

2. **Dynamically Apply Theme in MainActivity:**
   * Retrieve the selected theme option flow inside `MainActivity.kt` and collect it as state.
   * Calculate `useDarkTheme` dynamically:
     ```kotlin
     val useDarkTheme = when (themeOption) {
         ThemeOption.LIGHT -> false
         ThemeOption.DARK -> true
         ThemeOption.SYSTEM -> isSystemInDarkTheme()
     }
     ```
   * Pass the resolved `useDarkTheme` to the root `PokeboxTheme(darkTheme = useDarkTheme)`.

3. **Theme Settings Configuration:**
   * Add theme option toggles (e.g., radio buttons or a drop-down) within the `SettingsScreen` (to be created alongside the onboarding screen).
   * Update the selection in `UserPreferences`, which will automatically trigger recomposition and update colors across the entire app.
### Plan: Support Dark Mode Configurations To support customizable theme selections (Light, Dark, or System Default): 1. **Preferences Storage (`UserPreferences`):** * Define a `ThemeOption` enum (`LIGHT`, `DARK`, `SYSTEM`) and save it in `UserPreferences`. * Expose it as a flow in `UserPreferences`. 2. **Dynamically Apply Theme in MainActivity:** * Retrieve the selected theme option flow inside `MainActivity.kt` and collect it as state. * Calculate `useDarkTheme` dynamically: ```kotlin val useDarkTheme = when (themeOption) { ThemeOption.LIGHT -> false ThemeOption.DARK -> true ThemeOption.SYSTEM -> isSystemInDarkTheme() } ``` * Pass the resolved `useDarkTheme` to the root `PokeboxTheme(darkTheme = useDarkTheme)`. 3. **Theme Settings Configuration:** * Add theme option toggles (e.g., radio buttons or a drop-down) within the `SettingsScreen` (to be created alongside the onboarding screen). * Update the selection in `UserPreferences`, which will automatically trigger recomposition and update colors across the entire app.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
elvis/pokebox#4
No description provided.