aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/enums
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-02-23 16:06:45 -0800
committerAllan Wang <me@allanwang.ca>2020-02-23 16:06:45 -0800
commitc8b54fd10a08ed53eb7d21578a4fe990fe14e3bc (patch)
tree0841d112c8c00504ce10ca72ef39e403b69c595c /app/src/main/kotlin/com/pitchedapps/frost/enums
parent4d5aaf541dbfa7d521ebbc5f011a642c83c4b9c5 (diff)
downloadfrost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.tar.gz
frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.tar.bz2
frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.zip
Move prefs to service locator
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/enums')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt12
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt15
2 files changed, 15 insertions, 12 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt
index 92aa93ab..4f6d6a29 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt
@@ -24,17 +24,17 @@ import com.pitchedapps.frost.utils.Prefs
*/
enum class MainActivityLayout(
val titleRes: Int,
- val backgroundColor: () -> Int,
- val iconColor: () -> Int
+ val backgroundColor: (Prefs) -> Int,
+ val iconColor: (Prefs) -> Int
) {
TOP_BAR(R.string.top_bar,
- { Prefs.headerColor },
- { Prefs.iconColor }),
+ { it.headerColor },
+ { it.iconColor }),
BOTTOM_BAR(R.string.bottom_bar,
- { Prefs.bgColor },
- { Prefs.textColor });
+ { it.bgColor },
+ { it.textColor });
companion object {
val values = values() // save one instance
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 6c911e9c..a4f7525d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt
@@ -23,6 +23,8 @@ 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.
@@ -82,11 +84,11 @@ enum class Theme(
CUSTOM(R.string.kau_custom,
CssAssets.CUSTOM,
- { Prefs.customTextColor },
- { Prefs.customAccentColor },
- { Prefs.customBackgroundColor },
- { Prefs.customHeaderColor },
- { Prefs.customIconColor });
+ { prefs.customTextColor },
+ { prefs.customAccentColor },
+ { prefs.customBackgroundColor },
+ { prefs.customHeaderColor },
+ { prefs.customIconColor });
val textColor: Int
get() = textColorGetter()
@@ -103,7 +105,8 @@ enum class Theme(
val iconColor: Int
get() = iconColorGetter()
- companion object {
+ companion object:KoinComponent {
+ private val prefs: Prefs by inject()
val values = values() // save one instance
operator fun invoke(index: Int) = values[index]
}