Let the user choose theme (#1499)
This commit is contained in:
parent
a8fbb882f2
commit
68f9c81628
13 changed files with 216 additions and 3 deletions
|
|
@ -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() }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue