diff options
author | Allan Wang <me@allanwang.ca> | 2017-08-18 20:25:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-18 20:25:26 -0700 |
commit | ede53aff0ca989881247afead959341818f705b4 (patch) | |
tree | 4cafcf203bac331ebc53eab690c0fb41813d23da /app/src/main/kotlin/com/pitchedapps/frost/utils | |
parent | 22df6cd1cf436433d5e381a6d6e694a91f647075 (diff) | |
download | frost-ede53aff0ca989881247afead959341818f705b4.tar.gz frost-ede53aff0ca989881247afead959341818f705b4.tar.bz2 frost-ede53aff0ca989881247afead959341818f705b4.zip |
Feature/theme accent (#192)
* Add lots of theming components
* Optimize and add
* Update accents
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt | 17 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt | 71 |
2 files changed, 66 insertions, 22 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 9b8064a4..27405026 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -26,6 +26,8 @@ object Prefs : KPref() { var customTextColor: Int by kpref("color_text", 0xffeceff1.toInt()) + var customAccentColor: Int by kpref("color_accent", 0xff0288d1.toInt()) + var customBackgroundColor: Int by kpref("color_bg", 0xff212121.toInt()) var customHeaderColor: Int by kpref("color_header", 0xff01579b.toInt()) @@ -49,6 +51,9 @@ object Prefs : KPref() { val textColor: Int get() = t.textColor + val accentColor: Int + get() = t.accentColor + val bgColor: Int get() = t.bgColor @@ -58,18 +63,6 @@ object Prefs : KPref() { val iconColor: Int get() = t.iconColor - /** - * Ensures that the color is visible against the background - */ - val accentColor: Int - get() = if (headerColor.isColorVisibleOn(bgColor, 100)) headerColor else textColor - - /** - * Ensures that the color is visible against the background - */ - val iconBackgroundColor: Int - get() = if (headerColor.isColorVisibleOn(bgColor)) headerColor else headerColor.colorToForeground(0.2f) - val themeInjector: InjectorContract get() = t.injector 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 cb265149..5cbb051d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt @@ -10,20 +10,71 @@ import com.pitchedapps.frost.injectors.JsActions /** * Created by Allan Wang on 2017-06-14. */ -enum class Theme(@StringRes 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.kau_default, JsActions.EMPTY, { 0xde000000.toInt() }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }), - LIGHT(R.string.kau_light, CssAssets.MATERIAL_LIGHT, { 0xde000000.toInt() }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }), - DARK(R.string.kau_dark, CssAssets.MATERIAL_DARK, { Color.WHITE }, { 0xff303030.toInt() }, { 0xff2e4b86.toInt() }, { Color.WHITE }), - AMOLED(R.string.kau_amoled, CssAssets.MATERIAL_AMOLED, { Color.WHITE }, { Color.BLACK }, { Color.BLACK }, { Color.WHITE }), - GLASS(R.string.kau_glass, CssAssets.MATERIAL_GLASS, { Color.WHITE }, { 0x80000000.toInt() }, { 0xb3000000.toInt() }, { Color.WHITE }), - CUSTOM(R.string.kau_custom, CssAssets.CUSTOM, { Prefs.customTextColor }, { Prefs.customBackgroundColor }, { Prefs.customHeaderColor }, { Prefs.customIconColor }) - ; +const val FACEBOOK_BLUE = 0xff3b5998.toInt() +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) { + + DEFAULT(R.string.kau_default, + JsActions.EMPTY, + { 0xde000000.toInt() }, + { FACEBOOK_BLUE }, + { 0xfffafafa.toInt() }, + { FACEBOOK_BLUE }, + { Color.WHITE }), + + LIGHT(R.string.kau_light, + CssAssets.MATERIAL_LIGHT, + { 0xde000000.toInt() }, + { FACEBOOK_BLUE }, + { 0xfffafafa.toInt() }, + { FACEBOOK_BLUE }, + { Color.WHITE }), + + DARK(R.string.kau_dark, + CssAssets.MATERIAL_DARK, + { Color.WHITE }, + { BLUE_LIGHT }, + { 0xff303030.toInt() }, + { 0xff2e4b86.toInt() }, + { Color.WHITE }), + + AMOLED(R.string.kau_amoled, + CssAssets.MATERIAL_AMOLED, + { Color.WHITE }, + { BLUE_LIGHT }, + { Color.BLACK }, + { Color.BLACK }, + { Color.WHITE }), + + GLASS(R.string.kau_glass, + CssAssets.MATERIAL_GLASS, + { Color.WHITE }, + { BLUE_LIGHT }, + { 0x80000000.toInt() }, + { 0xb3000000.toInt() }, + { Color.WHITE }), + + CUSTOM(R.string.kau_custom, + CssAssets.CUSTOM, + { Prefs.customTextColor }, + { Prefs.customAccentColor }, + { Prefs.customBackgroundColor }, + { Prefs.customHeaderColor }, + { Prefs.customIconColor }); val textColor: Int get() = textColorGetter() + val accentColor: Int + get() = accentColorGetter() + val bgColor: Int get() = backgroundColorGetter() |