diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-15 15:49:20 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-15 15:49:20 -0700 |
commit | 9e0044f8789a47a41933d341b968fe0a6bc22b6d (patch) | |
tree | 551096bd404331a39022e81853aff003236bb234 /app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt | |
parent | 610c37698ab93b8d51efcaec9f721292cacfd854 (diff) | |
download | frost-9e0044f8789a47a41933d341b968fe0a6bc22b6d.tar.gz frost-9e0044f8789a47a41933d341b968fe0a6bc22b6d.tar.bz2 frost-9e0044f8789a47a41933d341b968fe0a6bc22b6d.zip |
Add full theming
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt index 115f981a..396b4471 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -3,6 +3,7 @@ package com.pitchedapps.frost.utils import android.graphics.Color import ca.allanwang.kau.kpref.KPref import ca.allanwang.kau.kpref.kpref +import com.pitchedapps.frost.injectors.InjectorContract /** * Created by Allan Wang on 2017-05-28. @@ -15,15 +16,39 @@ object Prefs : KPref() { var userId: Long by kpref("user_id", -1L) - var theme: Int by kpref("theme", 0) + var theme: Int by kpref("theme", 0, postSetter = { value: Int -> + loader.invalidate() + }) - var textColor: Int by kpref("color_text", Color.BLACK) + var customTextColor: Int by kpref("color_text", Color.BLACK) - var bgColor: Int by kpref("color_bg", Color.WHITE) + var customBackgroundColor: Int by kpref("color_bg", 0xfffafafa.toInt()) - var headerColor: Int by kpref("color_header", 0xff3b5998.toInt()) + var customHeaderColor: Int by kpref("color_header", 0xff3b5998.toInt()) - var iconColor: Int by kpref("color_icons", Color.WHITE) + var customIconColor: Int by kpref("color_icons", Color.WHITE) var exitConfirmation: Boolean by kpref("exit_confirmation", true) + + private val loader = lazyResettable { Theme.values[Prefs.theme] } + + private val t: Theme by loader + + val textColor: Int + get() = t.textColor + + val bgColor: Int + get() = t.bgColor + + val headerColor: Int + get() = t.headerColor + + val iconColor: Int + get() = t.iconColor + + val themeInjector: InjectorContract + get() = t.injector + + val isCustomTheme: Boolean + get() = t == Theme.CUSTOM } |