|
|
@@ -60,11 +60,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.constraintlayout.compose.ConstraintLayout
|
|
|
import io.legado.app.R
|
|
|
-import io.legado.app.domain.gateway.ThemeBooleanSetting
|
|
|
-import io.legado.app.domain.gateway.ThemeFloatSetting
|
|
|
-import io.legado.app.domain.gateway.ThemeIntSetting
|
|
|
-import io.legado.app.domain.gateway.ThemeSettingsUpdate
|
|
|
-import io.legado.app.domain.gateway.ThemeStringSetting
|
|
|
+import io.legado.app.domain.model.settings.ThemeSettings
|
|
|
import io.legado.app.ui.theme.LegadoTheme
|
|
|
import io.legado.app.ui.theme.ThemeEngine
|
|
|
import io.legado.app.ui.theme.ThemeResolver
|
|
|
@@ -99,15 +95,8 @@ fun ThemeConfigScreen(
|
|
|
val theme = state.theme
|
|
|
val scrollBehavior = GlassTopAppBarDefaults.defaultScrollBehavior()
|
|
|
val context = LocalContext.current
|
|
|
- fun updateTheme(setting: ThemeBooleanSetting, value: Boolean) = onIntent(
|
|
|
- ThemeConfigIntent.UpdateTheme(ThemeSettingsUpdate.BooleanValue(setting, value))
|
|
|
- )
|
|
|
- fun updateTheme(setting: ThemeIntSetting, value: Int) = onIntent(
|
|
|
- ThemeConfigIntent.UpdateTheme(ThemeSettingsUpdate.IntValue(setting, value))
|
|
|
- )
|
|
|
- fun updateTheme(setting: ThemeFloatSetting, value: Float) = onIntent(
|
|
|
- ThemeConfigIntent.UpdateTheme(ThemeSettingsUpdate.FloatValue(setting, value))
|
|
|
- )
|
|
|
+ fun updateTheme(transform: (ThemeSettings) -> ThemeSettings) =
|
|
|
+ onIntent(ThemeConfigIntent.UpdateTheme(transform))
|
|
|
val fontFolderState = remember(state.fontFolder) {
|
|
|
FontFolderState.Loaded(state.fontFolder.takeIf { it.isNotEmpty() }?.let(android.net.Uri::parse))
|
|
|
}
|
|
|
@@ -383,15 +372,8 @@ fun ThemeConfigScreen(
|
|
|
value = theme.bottomBarLensRadius,
|
|
|
defaultValue = 24f,
|
|
|
valueRange = 0f..50f,
|
|
|
- onValueChange = {
|
|
|
- onIntent(
|
|
|
- ThemeConfigIntent.UpdateTheme(
|
|
|
- ThemeSettingsUpdate.FloatValue(
|
|
|
- ThemeFloatSetting.BottomBarLensRadius,
|
|
|
- it,
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(bottomBarLensRadius = value) }
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
@@ -426,15 +408,8 @@ fun ThemeConfigScreen(
|
|
|
title = stringResource(R.string.book_info_follow_cover_color),
|
|
|
description = stringResource(R.string.book_info_follow_cover_color_summary),
|
|
|
checked = theme.bookInfoFollowCoverColor,
|
|
|
- onCheckedChange = {
|
|
|
- onIntent(
|
|
|
- ThemeConfigIntent.UpdateTheme(
|
|
|
- ThemeSettingsUpdate.BooleanValue(
|
|
|
- ThemeBooleanSetting.BookInfoFollowCoverColor,
|
|
|
- it,
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
+ onCheckedChange = { value ->
|
|
|
+ updateTheme { it.copy(bookInfoFollowCoverColor = value) }
|
|
|
}
|
|
|
)
|
|
|
DropdownListSettingItem(
|
|
|
@@ -442,15 +417,8 @@ fun ThemeConfigScreen(
|
|
|
selectedValue = theme.bookInfoNetworkCoverBackground,
|
|
|
displayEntries = stringArrayResource(R.array.book_info_background_blur_entries),
|
|
|
entryValues = stringArrayResource(R.array.book_info_background_blur_values),
|
|
|
- onValueChange = {
|
|
|
- onIntent(
|
|
|
- ThemeConfigIntent.UpdateTheme(
|
|
|
- ThemeSettingsUpdate.StringValue(
|
|
|
- ThemeStringSetting.BookInfoNetworkCoverBackground,
|
|
|
- it,
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(bookInfoNetworkCoverBackground = value) }
|
|
|
}
|
|
|
)
|
|
|
DropdownListSettingItem(
|
|
|
@@ -458,15 +426,8 @@ fun ThemeConfigScreen(
|
|
|
selectedValue = theme.bookInfoDefaultCoverBackground,
|
|
|
displayEntries = stringArrayResource(R.array.book_info_background_blur_entries),
|
|
|
entryValues = stringArrayResource(R.array.book_info_background_blur_values),
|
|
|
- onValueChange = {
|
|
|
- onIntent(
|
|
|
- ThemeConfigIntent.UpdateTheme(
|
|
|
- ThemeSettingsUpdate.StringValue(
|
|
|
- ThemeStringSetting.BookInfoDefaultCoverBackground,
|
|
|
- it,
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(bookInfoDefaultCoverBackground = value) }
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
@@ -476,15 +437,8 @@ fun ThemeConfigScreen(
|
|
|
title = stringResource(R.string.eye_protection_enabled),
|
|
|
description = stringResource(R.string.eye_protection_enabled_summary),
|
|
|
checked = theme.eyeProtectionEnabled,
|
|
|
- onCheckedChange = {
|
|
|
- onIntent(
|
|
|
- ThemeConfigIntent.UpdateTheme(
|
|
|
- ThemeSettingsUpdate.BooleanValue(
|
|
|
- ThemeBooleanSetting.EyeProtectionEnabled,
|
|
|
- it,
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
+ onCheckedChange = { value ->
|
|
|
+ updateTheme { it.copy(eyeProtectionEnabled = value) }
|
|
|
}
|
|
|
)
|
|
|
|
|
|
@@ -499,15 +453,8 @@ fun ThemeConfigScreen(
|
|
|
value = theme.colorTemperature.toFloat(),
|
|
|
defaultValue = 50f,
|
|
|
valueRange = 0f..100f,
|
|
|
- onValueChange = {
|
|
|
- onIntent(
|
|
|
- ThemeConfigIntent.UpdateTheme(
|
|
|
- ThemeSettingsUpdate.IntValue(
|
|
|
- ThemeIntSetting.ColorTemperature,
|
|
|
- it.toInt(),
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(colorTemperature = value.toInt()) }
|
|
|
}
|
|
|
)
|
|
|
|
|
|
@@ -515,15 +462,8 @@ fun ThemeConfigScreen(
|
|
|
title = stringResource(R.string.eye_protection_schedule),
|
|
|
description = stringResource(R.string.eye_protection_schedule_summary),
|
|
|
checked = theme.eyeProtectionSchedule,
|
|
|
- onCheckedChange = {
|
|
|
- onIntent(
|
|
|
- ThemeConfigIntent.UpdateTheme(
|
|
|
- ThemeSettingsUpdate.BooleanValue(
|
|
|
- ThemeBooleanSetting.EyeProtectionSchedule,
|
|
|
- it,
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
+ onCheckedChange = { value ->
|
|
|
+ updateTheme { it.copy(eyeProtectionSchedule = value) }
|
|
|
}
|
|
|
)
|
|
|
|
|
|
@@ -564,19 +504,15 @@ fun ThemeConfigScreen(
|
|
|
SwitchSettingItem(
|
|
|
title = stringResource(R.string.pure_black),
|
|
|
checked = theme.isPureBlack,
|
|
|
- onCheckedChange = {
|
|
|
- onIntent(
|
|
|
- ThemeConfigIntent.UpdateTheme(
|
|
|
- ThemeSettingsUpdate.PureBlack(it)
|
|
|
- )
|
|
|
- )
|
|
|
+ onCheckedChange = { value ->
|
|
|
+ updateTheme { it.copy(isPureBlack = value) }
|
|
|
}
|
|
|
)
|
|
|
SwitchSettingItem(
|
|
|
title = stringResource(R.string.use_flexible_top_bar),
|
|
|
checked = theme.useFlexibleTopAppBar,
|
|
|
- onCheckedChange = {
|
|
|
- updateTheme(ThemeBooleanSetting.UseFlexibleTopAppBar, it)
|
|
|
+ onCheckedChange = { value ->
|
|
|
+ updateTheme { it.copy(useFlexibleTopAppBar = value) }
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
@@ -589,8 +525,8 @@ fun ThemeConfigScreen(
|
|
|
SwitchSettingItem(
|
|
|
title = stringResource(R.string.is_blur_progressive_enable),
|
|
|
checked = theme.enableProgressiveBlur,
|
|
|
- onCheckedChange = {
|
|
|
- updateTheme(ThemeBooleanSetting.EnableProgressiveBlur, it)
|
|
|
+ onCheckedChange = { value ->
|
|
|
+ updateTheme { it.copy(enableProgressiveBlur = value) }
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
@@ -601,8 +537,8 @@ fun ThemeConfigScreen(
|
|
|
value = theme.topBarBlurRadius.toFloat(),
|
|
|
defaultValue = 24f,
|
|
|
valueRange = 0f..30f,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeIntSetting.TopBarBlurRadius, it.toInt())
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(topBarBlurRadius = value.toInt()) }
|
|
|
}
|
|
|
)
|
|
|
SliderSettingItem(
|
|
|
@@ -611,8 +547,8 @@ fun ThemeConfigScreen(
|
|
|
value = theme.bottomBarBlurRadius.toFloat(),
|
|
|
defaultValue = 8f,
|
|
|
valueRange = 0f..10f,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeIntSetting.BottomBarBlurRadius, it.toInt())
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(bottomBarBlurRadius = value.toInt()) }
|
|
|
}
|
|
|
)
|
|
|
SliderSettingItem(
|
|
|
@@ -620,8 +556,8 @@ fun ThemeConfigScreen(
|
|
|
value = theme.topBarBlurAlpha.toFloat(),
|
|
|
defaultValue = 73f,
|
|
|
valueRange = 0f..100f,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeIntSetting.TopBarBlurAlpha, it.toInt())
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(topBarBlurAlpha = value.toInt()) }
|
|
|
}
|
|
|
)
|
|
|
SliderSettingItem(
|
|
|
@@ -629,8 +565,8 @@ fun ThemeConfigScreen(
|
|
|
value = theme.bottomBarBlurAlpha.toFloat(),
|
|
|
defaultValue = 40f,
|
|
|
valueRange = 0f..100f,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeIntSetting.BottomBarBlurAlpha, it.toInt())
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(bottomBarBlurAlpha = value.toInt()) }
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
@@ -647,8 +583,8 @@ fun ThemeConfigScreen(
|
|
|
value = theme.topBarOpacity.toFloat(),
|
|
|
defaultValue = 100f,
|
|
|
valueRange = 0f..100f,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeIntSetting.TopBarOpacity, it.toInt())
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(topBarOpacity = value.toInt()) }
|
|
|
}
|
|
|
)
|
|
|
SliderSettingItem(
|
|
|
@@ -660,8 +596,8 @@ fun ThemeConfigScreen(
|
|
|
value = theme.bottomBarOpacity.toFloat(),
|
|
|
defaultValue = 100f,
|
|
|
valueRange = 0f..100f,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeIntSetting.BottomBarOpacity, it.toInt())
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(bottomBarOpacity = value.toInt()) }
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
@@ -676,8 +612,8 @@ fun ThemeConfigScreen(
|
|
|
value = theme.containerOpacity.toFloat(),
|
|
|
defaultValue = 100f,
|
|
|
valueRange = 0f..100f,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeIntSetting.ContainerOpacity, it.toInt())
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(containerOpacity = value.toInt()) }
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
@@ -703,8 +639,8 @@ fun ThemeConfigScreen(
|
|
|
value = theme.backgroundImageBlurring.toFloat(),
|
|
|
defaultValue = 0f,
|
|
|
valueRange = 0f..100f,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeIntSetting.BackgroundImageBlurring, it.toInt())
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(backgroundImageBlurring = value.toInt()) }
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
@@ -727,8 +663,8 @@ fun ThemeConfigScreen(
|
|
|
value = theme.backgroundImageDarkBlurring.toFloat(),
|
|
|
defaultValue = 0f,
|
|
|
valueRange = 0f..100f,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeIntSetting.BackgroundImageDarkBlurring, it.toInt())
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(backgroundImageDarkBlurring = value.toInt()) }
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
@@ -742,19 +678,18 @@ fun ThemeConfigScreen(
|
|
|
title = stringResource(R.string.disable_spliced_group_corner_radius),
|
|
|
description = stringResource(R.string.disable_spliced_group_corner_radius_summary),
|
|
|
checked = theme.disableSplicedColumnGroupCornerRadius,
|
|
|
- onCheckedChange = {
|
|
|
- updateTheme(
|
|
|
- ThemeBooleanSetting.DisableSplicedColumnGroupCornerRadius,
|
|
|
- it
|
|
|
- )
|
|
|
+ onCheckedChange = { value ->
|
|
|
+ updateTheme {
|
|
|
+ it.copy(disableSplicedColumnGroupCornerRadius = value)
|
|
|
+ }
|
|
|
}
|
|
|
)
|
|
|
SwitchSettingItem(
|
|
|
title = stringResource(R.string.base_card_corner_radius_override),
|
|
|
description = stringResource(R.string.base_card_override_summary),
|
|
|
checked = theme.overrideBaseCardCornerRadius,
|
|
|
- onCheckedChange = {
|
|
|
- updateTheme(ThemeBooleanSetting.OverrideBaseCardCornerRadius, it)
|
|
|
+ onCheckedChange = { value ->
|
|
|
+ updateTheme { it.copy(overrideBaseCardCornerRadius = value) }
|
|
|
}
|
|
|
)
|
|
|
AnimatedVisibility(visible = theme.overrideBaseCardCornerRadius) {
|
|
|
@@ -766,8 +701,8 @@ fun ThemeConfigScreen(
|
|
|
valueRange = 0f..40f,
|
|
|
steps = 79,
|
|
|
decimal = true,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeFloatSetting.BaseCardCornerRadius, it)
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(baseCardCornerRadius = value) }
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
@@ -775,8 +710,8 @@ fun ThemeConfigScreen(
|
|
|
title = stringResource(R.string.base_card_border_override),
|
|
|
description = stringResource(R.string.base_card_override_summary),
|
|
|
checked = theme.overrideBaseCardBorder,
|
|
|
- onCheckedChange = {
|
|
|
- updateTheme(ThemeBooleanSetting.OverrideBaseCardBorder, it)
|
|
|
+ onCheckedChange = { value ->
|
|
|
+ updateTheme { it.copy(overrideBaseCardBorder = value) }
|
|
|
}
|
|
|
)
|
|
|
AnimatedVisibility(visible = theme.overrideBaseCardBorder) {
|
|
|
@@ -789,8 +724,8 @@ fun ThemeConfigScreen(
|
|
|
valueRange = 0f..5f,
|
|
|
steps = 49,
|
|
|
decimal = true,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeFloatSetting.BaseCardBorderWidth, it)
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(baseCardBorderWidth = value) }
|
|
|
}
|
|
|
)
|
|
|
BaseCardBorderColorSettingItem(
|
|
|
@@ -820,8 +755,8 @@ fun ThemeConfigScreen(
|
|
|
SwitchSettingItem(
|
|
|
title = stringResource(R.string.show_divider_line),
|
|
|
checked = theme.enableItemDivider,
|
|
|
- onCheckedChange = {
|
|
|
- updateTheme(ThemeBooleanSetting.EnableItemDivider, it)
|
|
|
+ onCheckedChange = { value ->
|
|
|
+ updateTheme { it.copy(enableItemDivider = value) }
|
|
|
}
|
|
|
)
|
|
|
if (theme.enableItemDivider) {
|
|
|
@@ -833,8 +768,8 @@ fun ThemeConfigScreen(
|
|
|
valueRange = 0f..5f,
|
|
|
steps = 49,
|
|
|
decimal = true,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeFloatSetting.ItemDividerWidth, it)
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(itemDividerWidth = value) }
|
|
|
}
|
|
|
)
|
|
|
SliderSettingItem(
|
|
|
@@ -844,8 +779,8 @@ fun ThemeConfigScreen(
|
|
|
defaultValue = 80f,
|
|
|
valueRange = 30f..100f,
|
|
|
steps = 14,
|
|
|
- onValueChange = {
|
|
|
- updateTheme(ThemeFloatSetting.ItemDividerLength, it)
|
|
|
+ onValueChange = { value ->
|
|
|
+ updateTheme { it.copy(itemDividerLength = value) }
|
|
|
}
|
|
|
)
|
|
|
ClickableSettingItem(
|
|
|
@@ -945,8 +880,8 @@ fun ThemeConfigScreen(
|
|
|
show = state.activeSheet == ThemeConfigSheet.DividerColor,
|
|
|
initialColor = theme.itemDividerColor,
|
|
|
onDismissRequest = { onIntent(ThemeConfigIntent.DismissSheet) },
|
|
|
- onColorSelected = {
|
|
|
- updateTheme(ThemeIntSetting.ItemDividerColor, it)
|
|
|
+ onColorSelected = { value ->
|
|
|
+ updateTheme { it.copy(itemDividerColor = value) }
|
|
|
onIntent(ThemeConfigIntent.DismissSheet)
|
|
|
}
|
|
|
)
|
|
|
@@ -960,15 +895,14 @@ fun ThemeConfigScreen(
|
|
|
theme.baseCardBorderColor
|
|
|
},
|
|
|
onDismissRequest = { onIntent(ThemeConfigIntent.DismissSheet) },
|
|
|
- onColorSelected = {
|
|
|
- updateTheme(
|
|
|
+ onColorSelected = { value ->
|
|
|
+ updateTheme {
|
|
|
if (baseCardBorderColorSheet?.dark == true) {
|
|
|
- ThemeIntSetting.BaseCardBorderColorNight
|
|
|
+ it.copy(baseCardBorderColorNight = value)
|
|
|
} else {
|
|
|
- ThemeIntSetting.BaseCardBorderColor
|
|
|
- },
|
|
|
- it
|
|
|
- )
|
|
|
+ it.copy(baseCardBorderColor = value)
|
|
|
+ }
|
|
|
+ }
|
|
|
onIntent(ThemeConfigIntent.DismissSheet)
|
|
|
}
|
|
|
)
|