iosMain.com.softartdev.theme.pref.IosPreferenceHelper.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of theme-prefs Show documentation
Show all versions of theme-prefs Show documentation
Kotlin Multiplatform library for easy switching Dark/Light Material themes on Compose.
The newest version!
package com.softartdev.theme.pref
import androidx.compose.runtime.Composable
import platform.Foundation.NSUserDefaults
class IosPreferenceHelper : PreferenceHelper {
private var preferences: NSUserDefaults = NSUserDefaults.standardUserDefaults
override var themeEnum: ThemeEnum
get() = preferences.integerForKey(defaultName = THEME_KEY).toInt().let(ThemeEnum.values()::get)
set(value) = preferences.setInteger(value.ordinal.toLong(), THEME_KEY)
override fun clear() = preferences.removeObjectForKey(defaultName = THEME_KEY)
}
@Composable
actual fun obtainPreferenceHelper(): PreferenceHelper = IosPreferenceHelper()
© 2015 - 2024 Weber Informatics LLC | Privacy Policy