重写主题系统
This commit is contained in:
1 parent
588ac40282
commit
0bb2528fab
56 files changed
+531
-665
No files matched your search
@@ -100,7 +100,6 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
get() = when (themeMode) {
|
||||
"1" -> false
|
||||
"2" -> true
|
||||
"3" -> false
|
||||
else -> sysConfiguration.isNightMode
|
||||
}
|
||||
set(value) {
|
||||
|
||||
@@ -42,7 +42,6 @@ object ThemeConfig {
|
||||
}
|
||||
|
||||
fun getTheme() = when {
|
||||
AppConfig.isEInkMode -> Theme.EInk
|
||||
AppConfig.isNightTheme -> Theme.Dark
|
||||
else -> Theme.Light
|
||||
}
|
||||
@@ -216,58 +215,7 @@ object ThemeConfig {
|
||||
* 更新主题
|
||||
*/
|
||||
fun applyTheme(context: Context) = with(context) {
|
||||
when {
|
||||
AppConfig.isEInkMode -> {
|
||||
ThemeStore.editTheme(this)
|
||||
.primaryColor(Color.WHITE)
|
||||
.accentColor(Color.BLACK)
|
||||
.backgroundColor(Color.WHITE)
|
||||
.bottomBackground(Color.WHITE)
|
||||
.apply()
|
||||
}
|
||||
|
||||
AppConfig.isNightTheme -> {
|
||||
val primary =
|
||||
getPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_blue_grey_600))
|
||||
val accent =
|
||||
getPrefInt(PreferKey.cNAccent, getCompatColor(R.color.md_deep_orange_800))
|
||||
var background =
|
||||
getPrefInt(PreferKey.cNBackground, getCompatColor(R.color.md_grey_900))
|
||||
if (ColorUtils.isColorLight(background)) {
|
||||
background = getCompatColor(R.color.md_grey_900)
|
||||
putPrefInt(PreferKey.cNBackground, background)
|
||||
}
|
||||
val bBackground =
|
||||
getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850))
|
||||
ThemeStore.editTheme(this)
|
||||
.primaryColor(ColorUtils.withAlpha(primary, 1f))
|
||||
.accentColor(ColorUtils.withAlpha(accent, 1f))
|
||||
.backgroundColor(ColorUtils.withAlpha(background, 1f))
|
||||
.bottomBackground(ColorUtils.withAlpha(bBackground, 1f))
|
||||
.apply()
|
||||
}
|
||||
|
||||
else -> {
|
||||
val primary =
|
||||
getPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_brown_500))
|
||||
val accent =
|
||||
getPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_red_600))
|
||||
var background =
|
||||
getPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100))
|
||||
if (!ColorUtils.isColorLight(background)) {
|
||||
background = getCompatColor(R.color.md_grey_100)
|
||||
putPrefInt(PreferKey.cBackground, background)
|
||||
}
|
||||
val bBackground =
|
||||
getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200))
|
||||
ThemeStore.editTheme(this)
|
||||
.primaryColor(ColorUtils.withAlpha(primary, 1f))
|
||||
.accentColor(ColorUtils.withAlpha(accent, 1f))
|
||||
.backgroundColor(ColorUtils.withAlpha(background, 1f))
|
||||
.bottomBackground(ColorUtils.withAlpha(bBackground, 1f))
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
|
||||
Reference in new issue
Block a user