HapeLee 3 месяцев назад
Родитель
Сommit
59b69de57e

+ 8 - 5
app/src/main/java/io/legado/app/ui/theme/AppTheme.kt

@@ -6,21 +6,21 @@ import androidx.compose.material3.darkColorScheme
 import androidx.compose.material3.lightColorScheme
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.getValue
 import androidx.compose.runtime.remember
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.platform.LocalDensity
 import androidx.compose.ui.platform.LocalInspectionMode
-import top.yukonga.miuix.kmp.theme.ColorSchemeMode
-import com.materialkolor.PaletteStyle
-import androidx.compose.runtime.getValue
+import androidx.compose.ui.unit.Density
 import androidx.lifecycle.compose.collectAsStateWithLifecycle
+import com.materialkolor.PaletteStyle
 import io.legado.app.domain.gateway.AppShellSettingsGateway
 import io.legado.app.domain.gateway.ThemeSettingsGateway
 import io.legado.app.domain.model.settings.customColors
 import io.legado.app.utils.sysConfiguration
-import androidx.compose.ui.unit.Density
 import org.koin.compose.koinInject
+import top.yukonga.miuix.kmp.theme.ColorSchemeMode
 
 @OptIn(ExperimentalMaterial3ExpressiveApi::class)
 @Composable
@@ -52,7 +52,8 @@ private fun AppThemePreview(
         composeEngine = "material"
     )
     CompositionLocalProvider(
-        LocalLegadoThemeColors provides themeColors
+        LocalLegadoThemeColors provides themeColors,
+        LocalThemeSettings provides ThemeSettings(),
     ) {
         MaterialThemeWrapper(
             themeColors = themeColors,
@@ -184,11 +185,13 @@ private fun AppThemeActual(
     // 7. 提供主题数据并根据引擎渲染
     CompositionLocalProvider(
         LocalLegadoThemeColors provides themeColors,
+        LocalThemeSettings provides themeSettings,
         LocalDensity provides appDensity,
     ) {
         if (ThemeResolver.isMiuixEngine(themeColors.composeEngine)) {
             MiuixThemeWrapper(
                 themeColors = themeColors,
+                themeSettings = themeSettings,
                 customFontFamily = customFontFamily,
                 content = content
             )

+ 3 - 0
app/src/main/java/io/legado/app/ui/theme/LegadoTheme.kt

@@ -10,6 +10,7 @@ import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.text.TextStyle
 import com.materialkolor.PaletteStyle
 import dev.chrisbanes.haze.HazeState
+import io.legado.app.domain.model.settings.ThemeSettings
 import top.yukonga.miuix.kmp.theme.ColorSchemeMode
 
 data class LegadoThemeMode(
@@ -22,6 +23,8 @@ data class LegadoThemeMode(
     val composeEngine: String,
 )
 
+val LocalThemeSettings = compositionLocalOf { ThemeSettings() }
+
 data class LegadoColorScheme(
     val primary: Color,
     val onPrimary: Color,

+ 9 - 5
app/src/main/java/io/legado/app/ui/theme/ThemeComponents.kt

@@ -15,6 +15,8 @@ import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.graphics.compositeOver
 import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.text.font.FontFamily
+import io.legado.app.domain.model.settings.ThemeSettings
+import io.legado.app.domain.model.settings.customColors
 import io.legado.app.ui.config.themeConfig.ThemeConfig
 import top.yukonga.miuix.kmp.theme.ColorSchemeMode
 import top.yukonga.miuix.kmp.theme.MiuixTheme
@@ -48,12 +50,13 @@ fun rememberCustomFont(fontPath: String?): FontFamily? {
 @Composable
 fun MiuixThemeWrapper(
     themeColors: LegadoThemeMode,
+    themeSettings: ThemeSettings,
     customFontFamily: FontFamily?,
     content: @Composable () -> Unit
 ) {
-    val useMiuixMonet = ThemeConfig.useMiuixMonet
-    val paletteStyleValue = ThemeConfig.paletteStyle
-    val materialVersion = ThemeConfig.materialVersion
+    val useMiuixMonet = themeSettings.useMiuixMonet
+    val paletteStyleValue = themeSettings.paletteStyle
+    val materialVersion = themeSettings.materialVersion
     val darkTheme = themeColors.isDark
 
     // AppTheme has already resolved system mode to an explicit light/dark value.
@@ -116,8 +119,9 @@ fun MiuixThemeWrapper(
         }
 
         val miuixColorScheme = MiuixTheme.colorScheme
-        val customColors = ThemeConfig.customThemeColors(darkTheme)
-        val isDeepPersonalizationActive = ThemeConfig.isDeepPersonalizationActive
+        val customColors = themeSettings.customColors(darkTheme)
+        val isDeepPersonalizationActive =
+            themeSettings.appTheme == "12" && themeSettings.enableDeepPersonalization
         // MiuixTheme keeps one Colors instance and updates its state-backed fields in place.
         // Caching by miuixColorScheme would therefore retain an obsolete LegadoColorScheme
         // after a light/dark change.

+ 8 - 3
app/src/main/java/io/legado/app/ui/widget/components/FloatingBottomBar.kt

@@ -63,10 +63,12 @@ import com.kyant.backdrop.highlight.Highlight
 import com.kyant.backdrop.shadow.InnerShadow
 import com.kyant.backdrop.shadow.Shadow
 import com.kyant.capsule.ContinuousCapsule
+import io.legado.app.domain.model.settings.customColors
 import io.legado.app.ui.animation.DampedDragAnimation
 import io.legado.app.ui.animation.InteractiveHighlight
 import io.legado.app.ui.config.themeConfig.ThemeConfig
 import io.legado.app.ui.theme.LegadoTheme
+import io.legado.app.ui.theme.LocalThemeSettings
 import kotlinx.coroutines.flow.collectLatest
 import kotlinx.coroutines.launch
 import kotlin.math.abs
@@ -116,13 +118,16 @@ fun FloatingBottomBar(
     content: @Composable RowScope.() -> Unit
 ) {
     val isInLightTheme = !LegadoTheme.isDark
-    val customColors = ThemeConfig.customThemeColors(LegadoTheme.isDark)
-    val accentColor = if (ThemeConfig.isDeepPersonalizationActive && customColors.primary != 0) {
+    val themeSettings = LocalThemeSettings.current
+    val customColors = themeSettings.customColors(LegadoTheme.isDark)
+    val hasCustomColors = themeSettings.appTheme == "12" &&
+            themeSettings.enableDeepPersonalization
+    val accentColor = if (hasCustomColors && customColors.primary != 0) {
         Color(customColors.primary)
     } else {
         LegadoTheme.colorScheme.primary
     }
-    val containerColor = if (ThemeConfig.isDeepPersonalizationActive && customColors.secondary != 0) {
+    val containerColor = if (hasCustomColors && customColors.secondary != 0) {
         Color(customColors.secondary).copy(alpha = if (isBlurEnabled) ThemeConfig.bottomBarBlurAlpha / 100f else 1f)
     } else if (isBlurEnabled) {
         LegadoTheme.colorScheme.surfaceContainer.copy(alpha = ThemeConfig.bottomBarBlurAlpha / 100f)

+ 9 - 4
app/src/main/java/io/legado/app/ui/widget/components/navigation/AppNavigationBar.kt

@@ -24,9 +24,11 @@ import androidx.compose.ui.graphics.vector.ImageVector
 import androidx.compose.ui.layout.HorizontalAlignmentLine
 import androidx.compose.ui.layout.Measured
 import androidx.compose.ui.unit.dp
+import io.legado.app.domain.model.settings.customColors
 import io.legado.app.ui.config.themeConfig.ThemeConfig
 import io.legado.app.ui.theme.LegadoTheme
 import io.legado.app.ui.theme.LocalHazeState
+import io.legado.app.ui.theme.LocalThemeSettings
 import io.legado.app.ui.theme.ThemeResolver
 import io.legado.app.ui.theme.regularHazeEffect
 import io.legado.app.ui.widget.components.GlassDefaults
@@ -49,8 +51,11 @@ fun AppNavigationBar(
         alwaysShowLabel -> NavigationBarDisplayMode.IconAndText
         else -> NavigationBarDisplayMode.IconWithSelectedLabel
     }
-    val opacity = (ThemeConfig.bottomBarOpacity.coerceIn(0, 100)) / 100f
-    val customSecondaryColor = ThemeConfig.customThemeColors(LegadoTheme.isDark).secondary
+    val themeSettings = LocalThemeSettings.current
+    val opacity = (themeSettings.bottomBarOpacity.coerceIn(0, 100)) / 100f
+    val customSecondaryColor = themeSettings.customColors(LegadoTheme.isDark).secondary
+    val hasCustomSecondary = themeSettings.appTheme == "12" &&
+            themeSettings.enableDeepPersonalization && customSecondaryColor != 0
     val hazeState = LocalHazeState.current
     val hazeModifier = if (hazeState != null) {
         Modifier.regularHazeEffect(hazeState)
@@ -60,7 +65,7 @@ fun AppNavigationBar(
 
     if (isMiuix) {
         val baseColor =
-            if (ThemeConfig.isDeepPersonalizationActive && customSecondaryColor != 0) {
+            if (hasCustomSecondary) {
                 Color(customSecondaryColor)
             } else {
                 GlassDefaults.glassColor(
@@ -78,7 +83,7 @@ fun AppNavigationBar(
         )
     } else {
         val baseColor =
-            if (ThemeConfig.isDeepPersonalizationActive && customSecondaryColor != 0) {
+            if (hasCustomSecondary) {
                 Color(customSecondaryColor)
             } else {
                 GlassDefaults.glassColor(