Skip to content

Instantly share code, notes, and snippets.

@egorikftp

egorikftp/new.kt Secret

Created Aug 22, 2021
Embed
What would you like to do?
enum class Theme(val storageKey: String) {
LIGHT("light"),
DARK("dark"),
SYSTEM("system")
}
// initialization DataStore with extension
private val dataStore: DataStore<Preferences> = context.dataStore
var selectedTheme by PreferenceDataStore<String>(
dataStore = dataStore,
key = stringPreferencesKey(name = "pref_dark_mode"),
defaultValue = SYSTEM.storageKey
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment