aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-02-23 16:15:42 -0800
committerAllan Wang <me@allanwang.ca>2020-02-23 16:15:42 -0800
commitcd69ccf7c49f486a6c90a7cee0d32a74ea00247d (patch)
tree7db781b28d5fb5ec191cd213e77838a9c5b74815 /app
parent7b5bf87a3f5ce8f7fd3c95ed889076f4869f0310 (diff)
downloadfrost-cd69ccf7c49f486a6c90a7cee0d32a74ea00247d.tar.gz
frost-cd69ccf7c49f486a6c90a7cee0d32a74ea00247d.tar.bz2
frost-cd69ccf7c49f486a6c90a7cee0d32a74ea00247d.zip
Remove pref component from theme
Diffstat (limited to 'app')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt40
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt10
2 files changed, 16 insertions, 34 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt
index 8e789c34..23fa2ebf 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt
@@ -23,8 +23,6 @@ import com.pitchedapps.frost.injectors.CssAssets
import com.pitchedapps.frost.injectors.InjectorContract
import com.pitchedapps.frost.injectors.JsActions
import com.pitchedapps.frost.utils.Prefs
-import org.koin.core.KoinComponent
-import org.koin.core.inject
/**
* Created by Allan Wang on 2017-06-14.
@@ -35,11 +33,11 @@ const val BLUE_LIGHT = 0xff5d86dd.toInt()
enum class Theme(
@StringRes val textRes: Int,
val injector: InjectorContract,
- private val textColorGetter: () -> Int,
- private val accentColorGetter: () -> Int,
- private val backgroundColorGetter: () -> Int,
- private val headerColorGetter: () -> Int,
- private val iconColorGetter: () -> Int
+ val textColorGetter: (Prefs) -> Int,
+ val accentColorGetter: (Prefs) -> Int,
+ val backgroundColorGetter: (Prefs) -> Int,
+ val headerColorGetter: (Prefs) -> Int,
+ val iconColorGetter: (Prefs) -> Int
) {
DEFAULT(R.string.kau_default,
@@ -84,29 +82,13 @@ enum class Theme(
CUSTOM(R.string.kau_custom,
CssAssets.CUSTOM,
- { prefs.customTextColor },
- { prefs.customAccentColor },
- { prefs.customBackgroundColor },
- { prefs.customHeaderColor },
- { prefs.customIconColor });
+ { it.customTextColor },
+ { it.customAccentColor },
+ { it.customBackgroundColor },
+ { it.customHeaderColor },
+ { it.customIconColor });
- val textColor: Int
- get() = textColorGetter()
-
- val accentColor: Int
- get() = accentColorGetter()
-
- val bgColor: Int
- get() = backgroundColorGetter()
-
- val headerColor: Int
- get() = headerColorGetter()
-
- val iconColor: Int
- get() = iconColorGetter()
-
- companion object : KoinComponent {
- private val prefs: Prefs by inject()
+ companion object {
val values = values() // save one instance
operator fun invoke(index: Int) = values[index]
}
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 15d7ba9e..3d394abe 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -77,10 +77,10 @@ class Prefs(factory: KPrefFactory) : KPref("${BuildConfig.APPLICATION_ID}.prefs"
val t: Theme by loader
val textColor: Int
- get() = t.textColor
+ get() = t.textColorGetter(this)
val accentColor: Int
- get() = t.accentColor
+ get() = t.accentColorGetter(this)
inline val accentColorForWhite: Int
get() = when {
@@ -97,13 +97,13 @@ class Prefs(factory: KPrefFactory) : KPref("${BuildConfig.APPLICATION_ID}.prefs"
.withAlpha(30)
val bgColor: Int
- get() = t.bgColor
+ get() = t.backgroundColorGetter(this)
val headerColor: Int
- get() = t.headerColor
+ get() = t.headerColorGetter(this)
val iconColor: Int
- get() = t.iconColor
+ get() = t.iconColorGetter(this)
val themeInjector: InjectorContract
get() = t.injector