mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-08 20:12:39 +01:00
Remove pref component from theme
This commit is contained in:
parent
7b5bf87a3f
commit
cd69ccf7c4
@ -23,8 +23,6 @@ import com.pitchedapps.frost.injectors.CssAssets
|
|||||||
import com.pitchedapps.frost.injectors.InjectorContract
|
import com.pitchedapps.frost.injectors.InjectorContract
|
||||||
import com.pitchedapps.frost.injectors.JsActions
|
import com.pitchedapps.frost.injectors.JsActions
|
||||||
import com.pitchedapps.frost.utils.Prefs
|
import com.pitchedapps.frost.utils.Prefs
|
||||||
import org.koin.core.KoinComponent
|
|
||||||
import org.koin.core.inject
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Allan Wang on 2017-06-14.
|
* Created by Allan Wang on 2017-06-14.
|
||||||
@ -35,11 +33,11 @@ const val BLUE_LIGHT = 0xff5d86dd.toInt()
|
|||||||
enum class Theme(
|
enum class Theme(
|
||||||
@StringRes val textRes: Int,
|
@StringRes val textRes: Int,
|
||||||
val injector: InjectorContract,
|
val injector: InjectorContract,
|
||||||
private val textColorGetter: () -> Int,
|
val textColorGetter: (Prefs) -> Int,
|
||||||
private val accentColorGetter: () -> Int,
|
val accentColorGetter: (Prefs) -> Int,
|
||||||
private val backgroundColorGetter: () -> Int,
|
val backgroundColorGetter: (Prefs) -> Int,
|
||||||
private val headerColorGetter: () -> Int,
|
val headerColorGetter: (Prefs) -> Int,
|
||||||
private val iconColorGetter: () -> Int
|
val iconColorGetter: (Prefs) -> Int
|
||||||
) {
|
) {
|
||||||
|
|
||||||
DEFAULT(R.string.kau_default,
|
DEFAULT(R.string.kau_default,
|
||||||
@ -84,29 +82,13 @@ enum class Theme(
|
|||||||
|
|
||||||
CUSTOM(R.string.kau_custom,
|
CUSTOM(R.string.kau_custom,
|
||||||
CssAssets.CUSTOM,
|
CssAssets.CUSTOM,
|
||||||
{ prefs.customTextColor },
|
{ it.customTextColor },
|
||||||
{ prefs.customAccentColor },
|
{ it.customAccentColor },
|
||||||
{ prefs.customBackgroundColor },
|
{ it.customBackgroundColor },
|
||||||
{ prefs.customHeaderColor },
|
{ it.customHeaderColor },
|
||||||
{ prefs.customIconColor });
|
{ it.customIconColor });
|
||||||
|
|
||||||
val textColor: Int
|
companion object {
|
||||||
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()
|
|
||||||
val values = values() // save one instance
|
val values = values() // save one instance
|
||||||
operator fun invoke(index: Int) = values[index]
|
operator fun invoke(index: Int) = values[index]
|
||||||
}
|
}
|
||||||
|
@ -77,10 +77,10 @@ class Prefs(factory: KPrefFactory) : KPref("${BuildConfig.APPLICATION_ID}.prefs"
|
|||||||
val t: Theme by loader
|
val t: Theme by loader
|
||||||
|
|
||||||
val textColor: Int
|
val textColor: Int
|
||||||
get() = t.textColor
|
get() = t.textColorGetter(this)
|
||||||
|
|
||||||
val accentColor: Int
|
val accentColor: Int
|
||||||
get() = t.accentColor
|
get() = t.accentColorGetter(this)
|
||||||
|
|
||||||
inline val accentColorForWhite: Int
|
inline val accentColorForWhite: Int
|
||||||
get() = when {
|
get() = when {
|
||||||
@ -97,13 +97,13 @@ class Prefs(factory: KPrefFactory) : KPref("${BuildConfig.APPLICATION_ID}.prefs"
|
|||||||
.withAlpha(30)
|
.withAlpha(30)
|
||||||
|
|
||||||
val bgColor: Int
|
val bgColor: Int
|
||||||
get() = t.bgColor
|
get() = t.backgroundColorGetter(this)
|
||||||
|
|
||||||
val headerColor: Int
|
val headerColor: Int
|
||||||
get() = t.headerColor
|
get() = t.headerColorGetter(this)
|
||||||
|
|
||||||
val iconColor: Int
|
val iconColor: Int
|
||||||
get() = t.iconColor
|
get() = t.iconColorGetter(this)
|
||||||
|
|
||||||
val themeInjector: InjectorContract
|
val themeInjector: InjectorContract
|
||||||
get() = t.injector
|
get() = t.injector
|
||||||
|
Loading…
Reference in New Issue
Block a user