|
|
@@ -309,6 +309,19 @@ fun ThemeConfigScreen(
|
|
|
description = stringResource(R.string.theme_pack_s),
|
|
|
onClick = onNavigateToThemeManage
|
|
|
)
|
|
|
+ ClickableSettingItem(
|
|
|
+ title = stringResource(R.string.background_image),
|
|
|
+ description = "日间/夜间背景图与背景虚化",
|
|
|
+ onClick = {
|
|
|
+ onIntent(
|
|
|
+ ThemeConfigIntent.ShowSheet(
|
|
|
+ ThemeConfigSheet.BackgroundImage(
|
|
|
+ BackgroundImageTarget.App
|
|
|
+ )
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
SplicedColumnGroup(title = stringResource(R.string.main_activity)) {
|
|
|
@@ -608,56 +621,6 @@ fun ThemeConfigScreen(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- SplicedColumnGroup(title = stringResource(R.string.background_image)) {
|
|
|
- val hasLightBg = !theme.backgroundImageLight.isNullOrBlank()
|
|
|
- ClickableSettingItem(
|
|
|
- title = stringResource(R.string.day),
|
|
|
- description = if (hasLightBg) stringResource(R.string.click_to_delete) else stringResource(
|
|
|
- R.string.select_image
|
|
|
- ),
|
|
|
- onClick = {
|
|
|
- onIntent(
|
|
|
- ThemeConfigIntent.ShowSheet(ThemeConfigSheet.Background(false))
|
|
|
- )
|
|
|
- }
|
|
|
- )
|
|
|
-
|
|
|
- if (hasLightBg) {
|
|
|
- SliderSettingItem(
|
|
|
- title = stringResource(R.string.background_image_blurring),
|
|
|
- value = theme.backgroundImageBlurring.toFloat(),
|
|
|
- defaultValue = 0f,
|
|
|
- valueRange = 0f..100f,
|
|
|
- onValueChange = { value ->
|
|
|
- updateTheme { it.copy(backgroundImageBlurring = value.toInt()) }
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- val hasDarkBg = !theme.backgroundImageDark.isNullOrBlank()
|
|
|
- ClickableSettingItem(
|
|
|
- title = stringResource(R.string.night),
|
|
|
- description = if (hasDarkBg) stringResource(R.string.click_to_delete) else stringResource(
|
|
|
- R.string.select_image
|
|
|
- ),
|
|
|
- onClick = {
|
|
|
- onIntent(
|
|
|
- ThemeConfigIntent.ShowSheet(ThemeConfigSheet.Background(true))
|
|
|
- )
|
|
|
- }
|
|
|
- )
|
|
|
-
|
|
|
- if (hasDarkBg) {
|
|
|
- SliderSettingItem(
|
|
|
- title = stringResource(R.string.background_image_blurring),
|
|
|
- value = theme.backgroundImageDarkBlurring.toFloat(),
|
|
|
- defaultValue = 0f,
|
|
|
- valueRange = 0f..100f,
|
|
|
- onValueChange = { value ->
|
|
|
- updateTheme { it.copy(backgroundImageDarkBlurring = value.toInt()) }
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
// Container settings
|
|
|
@@ -672,66 +635,46 @@ fun ThemeConfigScreen(
|
|
|
}
|
|
|
)
|
|
|
AnimatedVisibility(visible = theme.enableContainerBackgroundImage) {
|
|
|
- Column {
|
|
|
- ContainerBackgroundSettingItem(
|
|
|
- title = "大容器日间背景图片",
|
|
|
- path = theme.largeContainerBackgroundImageLight,
|
|
|
- onClick = {
|
|
|
- onIntent(ThemeConfigIntent.RequestContainerBackgroundImage(ContainerBackgroundTarget.LargeContainer, false))
|
|
|
- },
|
|
|
- onRemove = {
|
|
|
- onIntent(ThemeConfigIntent.RemoveContainerBackground(ContainerBackgroundTarget.LargeContainer, false))
|
|
|
+ Column(
|
|
|
+ verticalArrangement = Arrangement.spacedBy(2.dp)
|
|
|
+ ) {
|
|
|
+ ClickableSettingItem(
|
|
|
+ title = "大容器背景图片",
|
|
|
+ description = if (theme.largeContainerBackgroundImageLight.isNullOrBlank() &&
|
|
|
+ theme.largeContainerBackgroundImageDark.isNullOrBlank()
|
|
|
+ ) {
|
|
|
+ stringResource(R.string.select_image)
|
|
|
+ } else {
|
|
|
+ "已选择"
|
|
|
},
|
|
|
- )
|
|
|
- ContainerBackgroundSettingItem(
|
|
|
- title = "大容器夜间背景图片",
|
|
|
- path = theme.largeContainerBackgroundImageDark,
|
|
|
onClick = {
|
|
|
- onIntent(ThemeConfigIntent.RequestContainerBackgroundImage(ContainerBackgroundTarget.LargeContainer, true))
|
|
|
- },
|
|
|
- onRemove = {
|
|
|
- onIntent(ThemeConfigIntent.RemoveContainerBackground(ContainerBackgroundTarget.LargeContainer, true))
|
|
|
- },
|
|
|
- )
|
|
|
- SliderSettingItem(
|
|
|
- title = "大容器背景图透明度",
|
|
|
- description = "${theme.appColumnBackgroundOpacity}%",
|
|
|
- value = theme.appColumnBackgroundOpacity.toFloat(),
|
|
|
- defaultValue = 100f,
|
|
|
- valueRange = 0f..100f,
|
|
|
- onValueChange = { value ->
|
|
|
- updateTheme { it.copy(appColumnBackgroundOpacity = value.toInt()) }
|
|
|
- }
|
|
|
- )
|
|
|
- SliderSettingItem(
|
|
|
- title = "项目背景图透明度",
|
|
|
- description = "${theme.glassCardBackgroundOpacity}%",
|
|
|
- value = theme.glassCardBackgroundOpacity.toFloat(),
|
|
|
- defaultValue = 100f,
|
|
|
- valueRange = 0f..100f,
|
|
|
- onValueChange = { value ->
|
|
|
- updateTheme { it.copy(glassCardBackgroundOpacity = value.toInt()) }
|
|
|
+ onIntent(
|
|
|
+ ThemeConfigIntent.ShowSheet(
|
|
|
+ ThemeConfigSheet.BackgroundImage(
|
|
|
+ BackgroundImageTarget.LargeContainer
|
|
|
+ )
|
|
|
+ )
|
|
|
+ )
|
|
|
}
|
|
|
)
|
|
|
- ContainerBackgroundSettingItem(
|
|
|
- title = "项目日间背景图片",
|
|
|
- path = theme.itemBackgroundImageLight,
|
|
|
- onClick = {
|
|
|
- onIntent(ThemeConfigIntent.RequestContainerBackgroundImage(ContainerBackgroundTarget.Item, false))
|
|
|
- },
|
|
|
- onRemove = {
|
|
|
- onIntent(ThemeConfigIntent.RemoveContainerBackground(ContainerBackgroundTarget.Item, false))
|
|
|
+ ClickableSettingItem(
|
|
|
+ title = "项目背景图片",
|
|
|
+ description = if (theme.itemBackgroundImageLight.isNullOrBlank() &&
|
|
|
+ theme.itemBackgroundImageDark.isNullOrBlank()
|
|
|
+ ) {
|
|
|
+ stringResource(R.string.select_image)
|
|
|
+ } else {
|
|
|
+ "已选择"
|
|
|
},
|
|
|
- )
|
|
|
- ContainerBackgroundSettingItem(
|
|
|
- title = "项目夜间背景图片",
|
|
|
- path = theme.itemBackgroundImageDark,
|
|
|
onClick = {
|
|
|
- onIntent(ThemeConfigIntent.RequestContainerBackgroundImage(ContainerBackgroundTarget.Item, true))
|
|
|
- },
|
|
|
- onRemove = {
|
|
|
- onIntent(ThemeConfigIntent.RemoveContainerBackground(ContainerBackgroundTarget.Item, true))
|
|
|
- },
|
|
|
+ onIntent(
|
|
|
+ ThemeConfigIntent.ShowSheet(
|
|
|
+ ThemeConfigSheet.BackgroundImage(
|
|
|
+ BackgroundImageTarget.Item
|
|
|
+ )
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
@@ -932,14 +875,106 @@ fun ThemeConfigScreen(
|
|
|
}
|
|
|
|
|
|
|
|
|
+ val backgroundImageSheet = state.activeSheet as? ThemeConfigSheet.BackgroundImage
|
|
|
+ val backgroundImageTarget = backgroundImageSheet?.target
|
|
|
+ fun requestImage(dark: Boolean) {
|
|
|
+ when (backgroundImageTarget) {
|
|
|
+ BackgroundImageTarget.App ->
|
|
|
+ onIntent(ThemeConfigIntent.RequestBackgroundImage(dark))
|
|
|
+
|
|
|
+ BackgroundImageTarget.LargeContainer ->
|
|
|
+ onIntent(
|
|
|
+ ThemeConfigIntent.RequestContainerBackgroundImage(
|
|
|
+ ContainerBackgroundTarget.LargeContainer,
|
|
|
+ dark
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ BackgroundImageTarget.Item ->
|
|
|
+ onIntent(
|
|
|
+ ThemeConfigIntent.RequestContainerBackgroundImage(
|
|
|
+ ContainerBackgroundTarget.Item,
|
|
|
+ dark
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ null -> Unit
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ fun removeImage(dark: Boolean) {
|
|
|
+ when (backgroundImageTarget) {
|
|
|
+ BackgroundImageTarget.App ->
|
|
|
+ onIntent(ThemeConfigIntent.RemoveBackground(dark))
|
|
|
+
|
|
|
+ BackgroundImageTarget.LargeContainer ->
|
|
|
+ onIntent(
|
|
|
+ ThemeConfigIntent.RemoveContainerBackground(
|
|
|
+ ContainerBackgroundTarget.LargeContainer,
|
|
|
+ dark
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ BackgroundImageTarget.Item ->
|
|
|
+ onIntent(
|
|
|
+ ThemeConfigIntent.RemoveContainerBackground(
|
|
|
+ ContainerBackgroundTarget.Item,
|
|
|
+ dark
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ null -> Unit
|
|
|
+ }
|
|
|
+ }
|
|
|
BackgroundImageManageSheet(
|
|
|
- isDarkTheme = (state.activeSheet as? ThemeConfigSheet.Background)?.dark,
|
|
|
- currentPath = (state.activeSheet as? ThemeConfigSheet.Background)?.let {
|
|
|
- if (it.dark) theme.backgroundImageDark else theme.backgroundImageLight
|
|
|
- },
|
|
|
+ show = backgroundImageSheet != null,
|
|
|
onDismissRequest = { onIntent(ThemeConfigIntent.DismissSheet) },
|
|
|
- onSelectImage = { onIntent(ThemeConfigIntent.RequestBackgroundImage(it)) },
|
|
|
- onRemoveImage = { onIntent(ThemeConfigIntent.RemoveBackground(it)) },
|
|
|
+ title = when (backgroundImageTarget) {
|
|
|
+ BackgroundImageTarget.App -> stringResource(R.string.background_image)
|
|
|
+ BackgroundImageTarget.LargeContainer -> "大容器背景图片"
|
|
|
+ BackgroundImageTarget.Item -> "项目背景图片"
|
|
|
+ null -> ""
|
|
|
+ },
|
|
|
+ lightPath = when (backgroundImageTarget) {
|
|
|
+ BackgroundImageTarget.App -> theme.backgroundImageLight
|
|
|
+ BackgroundImageTarget.LargeContainer -> theme.largeContainerBackgroundImageLight
|
|
|
+ BackgroundImageTarget.Item -> theme.itemBackgroundImageLight
|
|
|
+ null -> null
|
|
|
+ },
|
|
|
+ darkPath = when (backgroundImageTarget) {
|
|
|
+ BackgroundImageTarget.App -> theme.backgroundImageDark
|
|
|
+ BackgroundImageTarget.LargeContainer -> theme.largeContainerBackgroundImageDark
|
|
|
+ BackgroundImageTarget.Item -> theme.itemBackgroundImageDark
|
|
|
+ null -> null
|
|
|
+ },
|
|
|
+ extraOption = when (backgroundImageTarget) {
|
|
|
+ BackgroundImageTarget.App -> BackgroundImageExtraOption.Blur(
|
|
|
+ lightTitle = "日间背景图片虚化",
|
|
|
+ darkTitle = "夜间背景图片虚化",
|
|
|
+ lightValue = theme.backgroundImageBlurring,
|
|
|
+ darkValue = theme.backgroundImageDarkBlurring,
|
|
|
+ onLightChange = { value -> updateTheme { it.copy(backgroundImageBlurring = value) } },
|
|
|
+ onDarkChange = { value -> updateTheme { it.copy(backgroundImageDarkBlurring = value) } },
|
|
|
+ )
|
|
|
+
|
|
|
+ BackgroundImageTarget.LargeContainer -> BackgroundImageExtraOption.Opacity(
|
|
|
+ title = "大容器背景图透明度",
|
|
|
+ value = theme.appColumnBackgroundOpacity,
|
|
|
+ onValueChange = { value -> updateTheme { it.copy(appColumnBackgroundOpacity = value) } },
|
|
|
+ )
|
|
|
+
|
|
|
+ BackgroundImageTarget.Item -> BackgroundImageExtraOption.Opacity(
|
|
|
+ title = "项目背景图透明度",
|
|
|
+ value = theme.glassCardBackgroundOpacity,
|
|
|
+ onValueChange = { value -> updateTheme { it.copy(glassCardBackgroundOpacity = value) } },
|
|
|
+ )
|
|
|
+
|
|
|
+ null -> null
|
|
|
+ },
|
|
|
+ onSelectLight = { requestImage(false) },
|
|
|
+ onSelectDark = { requestImage(true) },
|
|
|
+ onRemoveLight = { removeImage(false) },
|
|
|
+ onRemoveDark = { removeImage(true) },
|
|
|
)
|
|
|
|
|
|
MainNavigationSettingsSheet(
|
|
|
@@ -1022,31 +1057,6 @@ fun ThemeConfigScreen(
|
|
|
|
|
|
}
|
|
|
|
|
|
-@Composable
|
|
|
-private fun ContainerBackgroundSettingItem(
|
|
|
- title: String,
|
|
|
- path: String?,
|
|
|
- onClick: () -> Unit,
|
|
|
- onRemove: () -> Unit,
|
|
|
-) {
|
|
|
- ClickableSettingItem(
|
|
|
- title = title,
|
|
|
- description = if (path.isNullOrBlank()) "选择图片" else "已选择",
|
|
|
- onClick = onClick,
|
|
|
- trailingContent = if (path.isNullOrBlank()) {
|
|
|
- null
|
|
|
- } else {
|
|
|
- {
|
|
|
- SmallPlainButton(
|
|
|
- onClick = onRemove,
|
|
|
- icon = Icons.Default.Delete,
|
|
|
- contentDescription = stringResource(R.string.clear),
|
|
|
- )
|
|
|
- }
|
|
|
- },
|
|
|
- )
|
|
|
-}
|
|
|
-
|
|
|
@Composable
|
|
|
private fun BaseCardBorderColorSettingItem(
|
|
|
title: String,
|