fix: fix theme switch

This commit is contained in:
k1ngsterr1
2026-02-03 16:06:53 +05:00
parent fa22c2dccd
commit af4df0a353
3 changed files with 42 additions and 14 deletions

View File

@@ -20,6 +20,7 @@ class PreferencesManager(private val context: Context) {
// Onboarding & Theme
val HAS_SEEN_ONBOARDING = booleanPreferencesKey("has_seen_onboarding")
val IS_DARK_THEME = booleanPreferencesKey("is_dark_theme")
val THEME_MODE = stringPreferencesKey("theme_mode") // "light", "dark", "auto"
// Notifications
val NOTIFICATIONS_ENABLED = booleanPreferencesKey("notifications_enabled")
@@ -63,6 +64,15 @@ class PreferencesManager(private val context: Context) {
context.dataStore.edit { preferences -> preferences[IS_DARK_THEME] = value }
}
val themeMode: Flow<String> =
context.dataStore.data.map { preferences ->
preferences[THEME_MODE] ?: "dark" // Default to dark theme
}
suspend fun setThemeMode(value: String) {
context.dataStore.edit { preferences -> preferences[THEME_MODE] = value }
}
// ═════════════════════════════════════════════════════════════
// 🔔 NOTIFICATIONS
// ═════════════════════════════════════════════════════════════