Przeglądaj źródła

Revert "feat: 主题重置"

This reverts commit bf528a1bed7f4ec9460306dcba275b0e091e1a8b.
HapeLee 3 miesięcy temu
rodzic
commit
da12a2ec73

+ 5 - 303
app/src/main/java/io/legado/app/ui/config/themeConfig/ThemeConfigViewModel.kt

@@ -5,20 +5,10 @@ import androidx.lifecycle.ViewModel
 import androidx.lifecycle.viewModelScope
 import androidx.lifecycle.viewModelScope
 import io.legado.app.R
 import io.legado.app.R
 import io.legado.app.constant.PreferKey
 import io.legado.app.constant.PreferKey
-import io.legado.app.domain.gateway.AppShellBooleanSetting
 import io.legado.app.domain.gateway.AppShellSettingsGateway
 import io.legado.app.domain.gateway.AppShellSettingsGateway
-import io.legado.app.domain.gateway.AppShellSettingsUpdate
-import io.legado.app.domain.gateway.AppShellStringSetting
-import io.legado.app.domain.gateway.LabSettingsGateway
 import io.legado.app.domain.gateway.ReadSettingsGateway
 import io.legado.app.domain.gateway.ReadSettingsGateway
-import io.legado.app.domain.gateway.ReadSettingsUpdate
-import io.legado.app.domain.gateway.ThemeBooleanSetting
-import io.legado.app.domain.gateway.ThemeColorSlot
-import io.legado.app.domain.gateway.ThemeFloatSetting
-import io.legado.app.domain.gateway.ThemeIntSetting
 import io.legado.app.domain.gateway.ThemeSettingsGateway
 import io.legado.app.domain.gateway.ThemeSettingsGateway
-import io.legado.app.domain.gateway.ThemeSettingsUpdate
-import io.legado.app.domain.gateway.ThemeStringSetting
+import io.legado.app.domain.gateway.LabSettingsGateway
 import io.legado.app.domain.model.settings.AppShellSettings
 import io.legado.app.domain.model.settings.AppShellSettings
 import io.legado.app.domain.model.settings.ThemeSettings
 import io.legado.app.domain.model.settings.ThemeSettings
 import io.legado.app.ui.main.MainDestination
 import io.legado.app.ui.main.MainDestination
@@ -28,6 +18,8 @@ import io.legado.app.utils.MD5Utils
 import io.legado.app.utils.externalFiles
 import io.legado.app.utils.externalFiles
 import io.legado.app.utils.inputStream
 import io.legado.app.utils.inputStream
 import io.legado.app.utils.openInputStream
 import io.legado.app.utils.openInputStream
+import java.io.File
+import java.io.FileOutputStream
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.flow.MutableSharedFlow
 import kotlinx.coroutines.flow.MutableSharedFlow
 import kotlinx.coroutines.flow.MutableStateFlow
 import kotlinx.coroutines.flow.MutableStateFlow
@@ -36,8 +28,6 @@ import kotlinx.coroutines.flow.asStateFlow
 import kotlinx.coroutines.flow.update
 import kotlinx.coroutines.flow.update
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.launch
 import splitties.init.appCtx
 import splitties.init.appCtx
-import java.io.File
-import java.io.FileOutputStream
 
 
 class ThemeConfigViewModel(
 class ThemeConfigViewModel(
     private val appShellSettingsGateway: AppShellSettingsGateway,
     private val appShellSettingsGateway: AppShellSettingsGateway,
@@ -91,10 +81,8 @@ class ThemeConfigViewModel(
                 _uiState.update { it.copy(activeSheet = null) }
                 _uiState.update { it.copy(activeSheet = null) }
             is ThemeConfigIntent.ShowDialog ->
             is ThemeConfigIntent.ShowDialog ->
                 _uiState.update { it.copy(activeDialog = intent.dialog) }
                 _uiState.update { it.copy(activeDialog = intent.dialog) }
-
             ThemeConfigIntent.DismissDialog ->
             ThemeConfigIntent.DismissDialog ->
                 _uiState.update { it.copy(activeDialog = null) }
                 _uiState.update { it.copy(activeDialog = null) }
-
             ThemeConfigIntent.ResetDefaults -> resetDefaults()
             ThemeConfigIntent.ResetDefaults -> resetDefaults()
             is ThemeConfigIntent.SelectTheme -> selectTheme(intent.value)
             is ThemeConfigIntent.SelectTheme -> selectTheme(intent.value)
             is ThemeConfigIntent.SetThemeMode -> updateAppShell(
             is ThemeConfigIntent.SetThemeMode -> updateAppShell(
@@ -202,294 +190,8 @@ class ThemeConfigViewModel(
                     ?.delete()
                     ?.delete()
             }
             }
 
 
-            appShellSettingsGateway.updateAll(
-                listOf(
-                    AppShellSettingsUpdate.ThemeMode(defaultShell.themeMode),
-                    AppShellSettingsUpdate.FontScale(defaultShell.fontScale),
-                    AppShellSettingsUpdate.ComposeEngine(defaultShell.composeEngine),
-                    AppShellSettingsUpdate.MainNavigationOrder(defaultShell.mainNavigationOrder),
-                    AppShellSettingsUpdate.BooleanValue(
-                        AppShellBooleanSetting.ShowHome,
-                        defaultShell.showHome
-                    ),
-                    AppShellSettingsUpdate.BooleanValue(
-                        AppShellBooleanSetting.ShowDiscovery,
-                        defaultShell.showDiscovery
-                    ),
-                    AppShellSettingsUpdate.BooleanValue(
-                        AppShellBooleanSetting.ShowRss,
-                        defaultShell.showRss
-                    ),
-                    AppShellSettingsUpdate.BooleanValue(
-                        AppShellBooleanSetting.ShowStatusBar,
-                        defaultShell.showStatusBar
-                    ),
-                    AppShellSettingsUpdate.BooleanValue(
-                        AppShellBooleanSetting.SwipeAnimation,
-                        defaultShell.swipeAnimation
-                    ),
-                    AppShellSettingsUpdate.BooleanValue(
-                        AppShellBooleanSetting.PredictiveBack,
-                        defaultShell.predictiveBackEnabled
-                    ),
-                    AppShellSettingsUpdate.BooleanValue(
-                        AppShellBooleanSetting.ShowBottomView,
-                        defaultShell.showBottomView
-                    ),
-                    AppShellSettingsUpdate.BooleanValue(
-                        AppShellBooleanSetting.UseFloatingBottomBar,
-                        defaultShell.useFloatingBottomBar
-                    ),
-                    AppShellSettingsUpdate.BooleanValue(
-                        AppShellBooleanSetting.UseFloatingBottomBarLiquidGlass,
-                        defaultShell.useFloatingBottomBarLiquidGlass
-                    ),
-                    AppShellSettingsUpdate.BooleanValue(
-                        AppShellBooleanSetting.NavExtended,
-                        defaultShell.navExtended
-                    ),
-                    AppShellSettingsUpdate.StringValue(
-                        AppShellStringSetting.TabletInterface,
-                        defaultShell.tabletInterface
-                    ),
-                    AppShellSettingsUpdate.StringValue(
-                        AppShellStringSetting.LabelVisibilityMode,
-                        defaultShell.labelVisibilityMode
-                    ),
-                    AppShellSettingsUpdate.StringValue(
-                        AppShellStringSetting.DefaultHomePage,
-                        defaultShell.defaultHomePage
-                    ),
-                    AppShellSettingsUpdate.StringValue(
-                        AppShellStringSetting.NavIconHome,
-                        defaultShell.navIconHome
-                    ),
-                    AppShellSettingsUpdate.StringValue(
-                        AppShellStringSetting.NavIconBookshelf,
-                        defaultShell.navIconBookshelf
-                    ),
-                    AppShellSettingsUpdate.StringValue(
-                        AppShellStringSetting.NavIconExplore,
-                        defaultShell.navIconExplore
-                    ),
-                    AppShellSettingsUpdate.StringValue(
-                        AppShellStringSetting.NavIconRss,
-                        defaultShell.navIconRss
-                    ),
-                    AppShellSettingsUpdate.StringValue(
-                        AppShellStringSetting.NavIconMy,
-                        defaultShell.navIconMy
-                    ),
-                    AppShellSettingsUpdate.StringValue(
-                        AppShellStringSetting.LauncherIcon,
-                        defaultShell.launcherIcon
-                    ),
-                )
-            )
-            themeSettingsGateway.updateAll(
-                listOf(
-                    ThemeSettingsUpdate.AppTheme(defaultTheme.appTheme),
-                    ThemeSettingsUpdate.PureBlack(defaultTheme.isPureBlack),
-                    ThemeSettingsUpdate.PaletteStyle(defaultTheme.paletteStyle),
-                    ThemeSettingsUpdate.MaterialVersion(defaultTheme.materialVersion),
-                    ThemeSettingsUpdate.CustomContrast(defaultTheme.customContrast),
-                    ThemeSettingsUpdate.DeepPersonalization(defaultTheme.enableDeepPersonalization),
-                    ThemeSettingsUpdate.CustomPrimary(defaultTheme.customPrimary),
-                    ThemeSettingsUpdate.CustomNightPrimary(defaultTheme.customNightPrimary),
-                    ThemeSettingsUpdate.AppFontPath(null),
-                    ThemeSettingsUpdate.CustomColor(
-                        ThemeColorSlot.Primary,
-                        defaultTheme.themeColor
-                    ),
-                    ThemeSettingsUpdate.CustomColor(
-                        ThemeColorSlot.Secondary,
-                        defaultTheme.secondaryThemeColor
-                    ),
-                    ThemeSettingsUpdate.CustomColor(
-                        ThemeColorSlot.PrimaryText,
-                        defaultTheme.primaryTextColor
-                    ),
-                    ThemeSettingsUpdate.CustomColor(
-                        ThemeColorSlot.SecondaryText,
-                        defaultTheme.secondaryTextColor
-                    ),
-                    ThemeSettingsUpdate.CustomColor(
-                        ThemeColorSlot.Background,
-                        defaultTheme.themeBackgroundColor
-                    ),
-                    ThemeSettingsUpdate.CustomColor(
-                        ThemeColorSlot.LabelContainer,
-                        defaultTheme.labelContainerColor
-                    ),
-                    ThemeSettingsUpdate.CustomColor(
-                        ThemeColorSlot.PrimaryNight,
-                        defaultTheme.themeColorNight
-                    ),
-                    ThemeSettingsUpdate.CustomColor(
-                        ThemeColorSlot.SecondaryNight,
-                        defaultTheme.secondaryThemeColorNight
-                    ),
-                    ThemeSettingsUpdate.CustomColor(
-                        ThemeColorSlot.PrimaryTextNight,
-                        defaultTheme.primaryTextColorNight
-                    ),
-                    ThemeSettingsUpdate.CustomColor(
-                        ThemeColorSlot.SecondaryTextNight,
-                        defaultTheme.secondaryTextColorNight
-                    ),
-                    ThemeSettingsUpdate.CustomColor(
-                        ThemeColorSlot.BackgroundNight,
-                        defaultTheme.themeBackgroundColorNight
-                    ),
-                    ThemeSettingsUpdate.CustomColor(
-                        ThemeColorSlot.LabelContainerNight,
-                        defaultTheme.labelContainerColorNight
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.UseMiuixMonet,
-                        defaultTheme.useMiuixMonet
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.EnableBlur,
-                        defaultTheme.enableBlur
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.EnableProgressiveBlur,
-                        defaultTheme.enableProgressiveBlur
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.UseFlexibleTopAppBar,
-                        defaultTheme.useFlexibleTopAppBar
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.BookInfoFollowCoverColor,
-                        defaultTheme.bookInfoFollowCoverColor
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.EnableItemDivider,
-                        defaultTheme.enableItemDivider
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.OverrideBaseCardCornerRadius,
-                        defaultTheme.overrideBaseCardCornerRadius
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.OverrideBaseCardBorder,
-                        defaultTheme.overrideBaseCardBorder
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.DisableSplicedColumnGroupCornerRadius,
-                        defaultTheme.disableSplicedColumnGroupCornerRadius
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.EyeProtectionEnabled,
-                        defaultTheme.eyeProtectionEnabled
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.EyeProtectionSchedule,
-                        defaultTheme.eyeProtectionSchedule
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.ShowRefactorTip,
-                        defaultTheme.showRefactorTip
-                    ),
-                    ThemeSettingsUpdate.BooleanValue(
-                        ThemeBooleanSetting.EnableCustomTagColors,
-                        defaultTheme.enableCustomTagColors
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.ContainerOpacity,
-                        defaultTheme.containerOpacity
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.TopBarOpacity,
-                        defaultTheme.topBarOpacity
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.BottomBarOpacity,
-                        defaultTheme.bottomBarOpacity
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.TopBarBlurRadius,
-                        defaultTheme.topBarBlurRadius
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.BottomBarBlurRadius,
-                        defaultTheme.bottomBarBlurRadius
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.TopBarBlurAlpha,
-                        defaultTheme.topBarBlurAlpha
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.BottomBarBlurAlpha,
-                        defaultTheme.bottomBarBlurAlpha
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.BackgroundImageBlurring,
-                        defaultTheme.backgroundImageBlurring
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.BackgroundImageDarkBlurring,
-                        defaultTheme.backgroundImageDarkBlurring
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.ItemDividerColor,
-                        defaultTheme.itemDividerColor
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.BaseCardBorderColor,
-                        defaultTheme.baseCardBorderColor
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.BaseCardBorderColorNight,
-                        defaultTheme.baseCardBorderColorNight
-                    ),
-                    ThemeSettingsUpdate.IntValue(
-                        ThemeIntSetting.ColorTemperature,
-                        defaultTheme.colorTemperature
-                    ),
-                    ThemeSettingsUpdate.FloatValue(
-                        ThemeFloatSetting.BottomBarLensRadius,
-                        defaultTheme.bottomBarLensRadius
-                    ),
-                    ThemeSettingsUpdate.FloatValue(
-                        ThemeFloatSetting.ItemDividerWidth,
-                        defaultTheme.itemDividerWidth
-                    ),
-                    ThemeSettingsUpdate.FloatValue(
-                        ThemeFloatSetting.ItemDividerLength,
-                        defaultTheme.itemDividerLength
-                    ),
-                    ThemeSettingsUpdate.FloatValue(
-                        ThemeFloatSetting.BaseCardCornerRadius,
-                        defaultTheme.baseCardCornerRadius
-                    ),
-                    ThemeSettingsUpdate.FloatValue(
-                        ThemeFloatSetting.BaseCardBorderWidth,
-                        defaultTheme.baseCardBorderWidth
-                    ),
-                    ThemeSettingsUpdate.StringValue(
-                        ThemeStringSetting.BookInfoNetworkCoverBackground,
-                        defaultTheme.bookInfoNetworkCoverBackground
-                    ),
-                    ThemeSettingsUpdate.StringValue(
-                        ThemeStringSetting.BookInfoDefaultCoverBackground,
-                        defaultTheme.bookInfoDefaultCoverBackground
-                    ),
-                    ThemeSettingsUpdate.StringValue(ThemeStringSetting.BackgroundImageLight, null),
-                    ThemeSettingsUpdate.StringValue(ThemeStringSetting.BackgroundImageDark, null),
-                    ThemeSettingsUpdate.StringValue(
-                        ThemeStringSetting.EyeProtectionStartTime,
-                        defaultTheme.eyeProtectionStartTime
-                    ),
-                    ThemeSettingsUpdate.StringValue(
-                        ThemeStringSetting.EyeProtectionEndTime,
-                        defaultTheme.eyeProtectionEndTime
-                    ),
-                    ThemeSettingsUpdate.StringValue(ThemeStringSetting.CustomTagColorsJson, null),
-                )
-            )
+            appShellSettingsGateway.update { defaultShell }
+            themeSettingsGateway.update { defaultTheme }
             _effects.tryEmit(ThemeConfigEffect.ApplyDayNight)
             _effects.tryEmit(ThemeConfigEffect.ApplyDayNight)
             _effects.tryEmit(ThemeConfigEffect.NotifyMain)
             _effects.tryEmit(ThemeConfigEffect.NotifyMain)
             _effects.tryEmit(ThemeConfigEffect.ChangeLauncherIcon(defaultShell.launcherIcon))
             _effects.tryEmit(ThemeConfigEffect.ChangeLauncherIcon(defaultShell.launcherIcon))