Let the user choose theme (#1499)
This commit is contained in:
+13
@@ -39,6 +39,7 @@ private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(na
|
||||
private val richTextEditorKey = booleanPreferencesKey("richTextEditor")
|
||||
private val developerModeKey = booleanPreferencesKey("developerMode")
|
||||
private val customElementCallBaseUrlKey = stringPreferencesKey("elementCallBaseUrl")
|
||||
private val themeKey = stringPreferencesKey("theme")
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultPreferencesStore @Inject constructor(
|
||||
@@ -89,6 +90,18 @@ class DefaultPreferencesStore @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun setTheme(theme: String) {
|
||||
store.edit { prefs ->
|
||||
prefs[themeKey] = theme
|
||||
}
|
||||
}
|
||||
|
||||
override fun getThemeFlow(): Flow<String?> {
|
||||
return store.data.map { prefs ->
|
||||
prefs[themeKey]
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun reset() {
|
||||
store.edit { it.clear() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user