aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt36
1 files changed, 28 insertions, 8 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt
index 4a0ffd8f..1eff6780 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt
@@ -1,19 +1,39 @@
package com.pitchedapps.frost.utils
+import android.graphics.Color
import com.pitchedapps.frost.R
+import com.pitchedapps.frost.injectors.CssAssets
+import com.pitchedapps.frost.injectors.InjectorContract
+import com.pitchedapps.frost.injectors.JsActions
/**
* Created by Allan Wang on 2017-06-14.
*/
-enum class Theme(val textRes: Int) {
- DEFAULT(R.string._default),
- LIGHT(R.string.light),
- DARK(R.string.dark),
- AMOLED(R.string.amoled),
- GLASS(R.string.glass),
- CUSTOM(R.string.custom);
+enum class Theme(val textRes: Int, val injector: InjectorContract,
+ private val textColorGetter: () -> Int, private val backgroundColorGetter: () -> Int,
+ private val headerColorGetter: () -> Int, private val iconColorGetter: () -> Int) {
+ DEFAULT(R.string._default, JsActions.EMPTY, { Color.BLACK }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }),
+ LIGHT(R.string.light, CssAssets.MATERIAL_LIGHT, { Color.BLACK }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }),
+ DARK(R.string.dark, CssAssets.MATERIAL_DARK, { Color.WHITE }, { 0xff303030.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }),
+ AMOLED(R.string.amoled, CssAssets.MATERIAL_AMOLED, { Color.WHITE }, { Color.BLACK }, { Color.BLACK }, { Color.WHITE }),
+ GLASS(R.string.glass, CssAssets.MATERIAL_GLASS, { Color.WHITE }, { 0x80000000.toInt() }, { 0xb3000000.toInt() }, { Color.WHITE }),
+ CUSTOM(R.string.custom, JsActions.EMPTY, { Prefs.customTextColor }, { Prefs.customBackgroundColor }, { Prefs.customHeaderColor }, { Prefs.customIconColor });
+ //todo create custom
+
+ val textColor: Int
+ get() = textColorGetter.invoke()
+
+ val bgColor: Int
+ get() = backgroundColorGetter.invoke()
+
+ val headerColor: Int
+ get() = headerColorGetter.invoke()
+
+ val iconColor: Int
+ get() = iconColorGetter.invoke()
companion object {
- operator fun invoke(index: Int) = values()[index]
+ val values = values() //save one instance
+ operator fun invoke(index: Int) = values[index]
}
} \ No newline at end of file