[新增] 新增了一些 Compose 界面的相关配置,界面模糊配置尚不可用
This commit is contained in:
@@ -172,6 +172,8 @@ object PreferKey {
|
||||
const val cPrimary = "colorPrimary"
|
||||
const val cAccent = "colorAccent"
|
||||
const val customMode = "customMode"
|
||||
const val paletteStyle = "paletteStyle"
|
||||
const val enableBlur = "enableBlur"
|
||||
const val cBackground = "colorBackground"
|
||||
const val cBBackground = "colorBottomBackground"
|
||||
const val bgImage = "backgroundImage"
|
||||
|
||||
@@ -902,6 +902,17 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
appCtx.putPrefString(PreferKey.labelVisibilityMode, value)
|
||||
}
|
||||
|
||||
var paletteStyle
|
||||
get() = appCtx.getPrefString(PreferKey.paletteStyle, "tonalSpot")
|
||||
set(value) {
|
||||
appCtx.putPrefString(PreferKey.paletteStyle, value)
|
||||
}
|
||||
|
||||
var enableBlur
|
||||
get() = appCtx.getPrefBoolean(PreferKey.enableBlur, false)
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.enableBlur, value)
|
||||
}
|
||||
var menuAlpha: Int
|
||||
get() = appCtx.getPrefInt(PreferKey.menuAlpha, 100)
|
||||
set(value) {
|
||||
@@ -961,5 +972,7 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.sliderVibrator, value)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
||||
true
|
||||
}
|
||||
|
||||
// TODO:删掉种子色了喵
|
||||
val hasColorImage = !getPrefString(PreferKey.colorImage).isNullOrBlank()
|
||||
colorPrimary?.isEnabled = !hasColorImage
|
||||
if (hasColorImage)
|
||||
@@ -178,15 +179,16 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
||||
//recreateActivities()
|
||||
}
|
||||
|
||||
PreferKey.customMode -> handleRestartRequired()
|
||||
|
||||
PreferKey.pureBlack -> {
|
||||
PreferKey.paletteStyle, PreferKey.pureBlack, PreferKey.enableBlur -> {
|
||||
ThemeSyncer.syncAll()
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
recreateActivities()
|
||||
}, 100)
|
||||
}
|
||||
|
||||
PreferKey.customMode -> handleRestartRequired()
|
||||
|
||||
PreferKey.isPredictiveBackEnabled -> {
|
||||
toastOnUi("重启以应用")
|
||||
}
|
||||
|
||||
@@ -19,12 +19,14 @@ fun AppTheme(
|
||||
val appThemeMode by ThemeState.themeMode.collectAsState()
|
||||
val isPureBlack by ThemeState.isPureBlack.collectAsState()
|
||||
val hasImageBg by ThemeState.hasImageBg.collectAsState()
|
||||
val paletteStyle by ThemeState.paletteStyle.collectAsState()
|
||||
|
||||
val colorScheme = ThemeManager.getColorScheme(
|
||||
mode = appThemeMode,
|
||||
darkTheme = darkTheme,
|
||||
isAmoled = isPureBlack,
|
||||
isImageBg = hasImageBg
|
||||
isImageBg = hasImageBg,
|
||||
paletteStyle = paletteStyle
|
||||
)
|
||||
|
||||
MaterialExpressiveTheme(
|
||||
@@ -34,4 +36,5 @@ fun AppTheme(
|
||||
shapes = Shapes(),
|
||||
content = content
|
||||
)
|
||||
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import com.materialkolor.PaletteStyle
|
||||
import io.legado.app.lib.theme.primaryColor
|
||||
import io.legado.app.ui.theme.ThemeResolver.resolvePaletteStyle
|
||||
import io.legado.app.ui.theme.colorScheme.AugustColorScheme
|
||||
import io.legado.app.ui.theme.colorScheme.CarlottaColorScheme
|
||||
import io.legado.app.ui.theme.colorScheme.ElinkColorScheme
|
||||
@@ -46,10 +46,11 @@ object ThemeManager {
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
isAmoled: Boolean,
|
||||
isImageBg: Boolean,
|
||||
paletteStyle: String?,
|
||||
forceOpaque: Boolean = false
|
||||
): ColorScheme {
|
||||
val context = LocalContext.current
|
||||
|
||||
val style = resolvePaletteStyle(paletteStyle)
|
||||
val actualMode = if (forceOpaque && mode == AppThemeMode.Transparent) {
|
||||
AppThemeMode.WH
|
||||
} else {
|
||||
@@ -66,7 +67,7 @@ object ThemeManager {
|
||||
}
|
||||
|
||||
AppThemeMode.CUSTOM -> {
|
||||
CustomColorScheme(context, context.primaryColor, PaletteStyle.Vibrant)
|
||||
CustomColorScheme(context, context.primaryColor, style)
|
||||
.getColorScheme(darkTheme)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.legado.app.ui.theme
|
||||
|
||||
import com.materialkolor.PaletteStyle
|
||||
|
||||
object ThemeResolver {
|
||||
|
||||
fun resolveThemeMode(value: String): AppThemeMode = when (value) {
|
||||
@@ -19,4 +21,20 @@ object ThemeResolver {
|
||||
"13" -> AppThemeMode.Transparent
|
||||
else -> AppThemeMode.Dynamic
|
||||
}
|
||||
|
||||
fun resolvePaletteStyle(value: String?): PaletteStyle {
|
||||
return when (value) {
|
||||
"tonalSpot" -> PaletteStyle.TonalSpot
|
||||
"neutral" -> PaletteStyle.Neutral
|
||||
"vibrant" -> PaletteStyle.Vibrant
|
||||
"expressive" -> PaletteStyle.Expressive
|
||||
"rainbow" -> PaletteStyle.Rainbow
|
||||
"fruitSalad" -> PaletteStyle.FruitSalad
|
||||
"monochrome" -> PaletteStyle.Monochrome
|
||||
"fidelity" -> PaletteStyle.Fidelity
|
||||
"content" -> PaletteStyle.Content
|
||||
else -> PaletteStyle.TonalSpot
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,14 @@ object ThemeState {
|
||||
MutableStateFlow(AppConfig.hasImageBg)
|
||||
val hasImageBg: StateFlow<Boolean> = _hasImageBg.asStateFlow()
|
||||
|
||||
private val _paletteStyle =
|
||||
MutableStateFlow(AppConfig.paletteStyle)
|
||||
val paletteStyle: StateFlow<String?> = _paletteStyle.asStateFlow()
|
||||
|
||||
private val _enableBlur =
|
||||
MutableStateFlow(AppConfig.enableBlur)
|
||||
val enableBlur: StateFlow<Boolean> = _enableBlur.asStateFlow()
|
||||
|
||||
fun updateThemeMode(newMode: AppThemeMode) {
|
||||
if (_themeMode.value != newMode) {
|
||||
_themeMode.value = newMode
|
||||
@@ -39,4 +47,17 @@ object ThemeState {
|
||||
_hasImageBg.value = enabled
|
||||
}
|
||||
}
|
||||
|
||||
fun updatePaletteStyle(style: String?) {
|
||||
if (_paletteStyle.value != style) {
|
||||
_paletteStyle.value = style
|
||||
}
|
||||
}
|
||||
|
||||
fun updateEnableBlur(enabled: Boolean) {
|
||||
if (_enableBlur.value != enabled) {
|
||||
_enableBlur.value = enabled
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ object ThemeSyncer {
|
||||
syncThemeMode()
|
||||
syncPureBlack()
|
||||
syncImageBg()
|
||||
syncPaletteStyle()
|
||||
syncEnableBlur()
|
||||
}
|
||||
|
||||
fun syncThemeMode() {
|
||||
@@ -26,4 +28,12 @@ object ThemeSyncer {
|
||||
fun syncImageBg() {
|
||||
ThemeState.updateImageBg(AppConfig.hasImageBg)
|
||||
}
|
||||
|
||||
fun syncPaletteStyle() {
|
||||
ThemeState.updatePaletteStyle(AppConfig.paletteStyle)
|
||||
}
|
||||
|
||||
fun syncEnableBlur() {
|
||||
ThemeState.updateEnableBlur(AppConfig.enableBlur)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -34,12 +34,14 @@ fun GlobalModalBottomSheet(
|
||||
val themeMode by ThemeState.themeMode.collectAsState()
|
||||
val isPureBlack by ThemeState.isPureBlack.collectAsState()
|
||||
val hasImageBg by ThemeState.hasImageBg.collectAsState()
|
||||
val paletteStyle by ThemeState.paletteStyle.collectAsState()
|
||||
|
||||
val colorScheme = ThemeManager.getColorScheme(
|
||||
mode = themeMode,
|
||||
isAmoled = isPureBlack,
|
||||
isImageBg = hasImageBg,
|
||||
forceOpaque = true
|
||||
forceOpaque = true,
|
||||
paletteStyle = paletteStyle
|
||||
)
|
||||
|
||||
ModalBottomSheet(
|
||||
|
||||
Reference in New Issue
Block a user