diff options
author | Allan Wang <me@allanwang.ca> | 2021-01-12 20:46:02 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2021-01-12 20:46:02 -0800 |
commit | 0e5c1ab2dd2b574970883576e18f9a119b058788 (patch) | |
tree | ba715d7a5e0537b9598722e203956fb56d3d5c53 /app/src/main/kotlin/com/pitchedapps/frost/utils | |
parent | 82fa4c5d6c75e245e74d903328b3e5d96b01b5ca (diff) | |
download | frost-0e5c1ab2dd2b574970883576e18f9a119b058788.tar.gz frost-0e5c1ab2dd2b574970883576e18f9a119b058788.tar.bz2 frost-0e5c1ab2dd2b574970883576e18f9a119b058788.zip |
Create themeprovider
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 883ea9aa..ab0e13fd 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -67,8 +67,8 @@ import com.pitchedapps.frost.facebook.FbUrlFormatter.Companion.VIDEO_REDIRECT import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.facebook.formattedFbUri import com.pitchedapps.frost.facebook.formattedFbUrl -import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.injectors.JsAssets +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import java.io.File import java.io.IOException @@ -222,21 +222,21 @@ class ActivityThemeUtils : KoinComponent { fun theme(activity: Activity) { with(activity) { - statusBarColor = prefs.headerColor.darken(0.1f).withAlpha(255) - if (prefs.tintNavBar) navigationBarColor = prefs.headerColor - if (themeWindow) window.setBackgroundDrawable(ColorDrawable(prefs.bgColor)) - toolbar?.setBackgroundColor(prefs.headerColor) - toolbar?.setTitleTextColor(prefs.iconColor) - toolbar?.overflowIcon?.setTint(prefs.iconColor) - texts.forEach { it.setTextColor(prefs.textColor) } - headers.forEach { it.setBackgroundColor(prefs.headerColor) } - backgrounds.forEach { it.setBackgroundColor(prefs.bgColor) } + statusBarColor = themeProvider.headerColor.darken(0.1f).withAlpha(255) + if (prefs.tintNavBar) navigationBarColor = themeProvider.headerColor + if (themeWindow) window.setBackgroundDrawable(ColorDrawable(themeProvider.bgColor)) + toolbar?.setBackgroundColor(themeProvider.headerColor) + toolbar?.setTitleTextColor(themeProvider.iconColor) + toolbar?.overflowIcon?.setTint(themeProvider.iconColor) + texts.forEach { it.setTextColor(themeProvider.textColor) } + headers.forEach { it.setBackgroundColor(themeProvider.headerColor) } + backgrounds.forEach { it.setBackgroundColor(themeProvider.bgColor) } } } } -inline fun Activity.setFrostColors(prefs: Prefs, builder: ActivityThemeUtils.() -> Unit) { - val themer = ActivityThemeUtils(prefs) +inline fun Activity.setFrostColors(builder: ActivityThemeUtils.() -> Unit) { + val themer = ActivityThemeUtils() themer.builder() themer.theme(this) } @@ -458,7 +458,7 @@ fun String.unescapeHtml(): String = .replace("\\u003C", "<") .replace("\\\"", "\"") -suspend fun Context.loadAssets(prefs: Prefs): Unit = coroutineScope { - ThemeProvider.load(this@loadAssets, prefs) +suspend fun Context.loadAssets(themeProvider: ThemeProvider): Unit = coroutineScope { + themeProvider.preload() JsAssets.load(this@loadAssets) } |