diff --git a/app/src/main/java/io/legado/app/ui/book/read/sheet/BgTextConfigSheet.kt b/app/src/main/java/io/legado/app/ui/book/read/sheet/BgTextConfigSheet.kt index 610fdf8a4..a98ee4591 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/sheet/BgTextConfigSheet.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/sheet/BgTextConfigSheet.kt @@ -215,10 +215,10 @@ fun BgTextConfigSheet( } } - if (showColorPicker) { + run { val initialColor = if (colorPickerIsNight) nightBgColor else dayBgColor ColorPickerSheet( - show = true, + show = showColorPicker, initialColor = if (initialColor != 0) initialColor else if (colorPickerIsNight) 0xFF000000.toInt() else 0xFFEEEEEE.toInt(), onDismissRequest = { showColorPicker = false }, onColorSelected = { color -> diff --git a/app/src/main/java/io/legado/app/ui/book/read/sheet/HighlightRuleConfigSheet.kt b/app/src/main/java/io/legado/app/ui/book/read/sheet/HighlightRuleConfigSheet.kt index 4b859094d..05682cb3b 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/sheet/HighlightRuleConfigSheet.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/sheet/HighlightRuleConfigSheet.kt @@ -74,29 +74,24 @@ fun HighlightRuleConfigSheet( // Edit existing rule val editingRuleValue = state.editingRule - if (show && editingRuleValue != null) { - HighlightRuleEditSheet( - show = true, - rule = editingRuleValue, - onDismissRequest = { onIntent(ReadBookIntent.DismissHighlightRuleEdit) }, - onSave = { updated -> - onIntent(ReadBookIntent.SaveHighlightRule(updated)) - }, - ) - } - + HighlightRuleEditSheet( + show = show && editingRuleValue != null, + rule = editingRuleValue, + onDismissRequest = { onIntent(ReadBookIntent.DismissHighlightRuleEdit) }, + onSave = { updated -> + onIntent(ReadBookIntent.SaveHighlightRule(updated)) + }, + ) // Add new rule - if (show && state.showNewRule) { - HighlightRuleEditSheet( - show = true, - rule = null, - onDismissRequest = { onIntent(ReadBookIntent.DismissHighlightRuleEdit) }, - onSave = { newRule -> - onIntent(ReadBookIntent.SaveHighlightRule(newRule)) - }, - ) - } + HighlightRuleEditSheet( + show = show && state.showNewRule, + rule = null, + onDismissRequest = { onIntent(ReadBookIntent.DismissHighlightRuleEdit) }, + onSave = { newRule -> + onIntent(ReadBookIntent.SaveHighlightRule(newRule)) + }, + ) // Delete confirmation val deletingRule = state.deleteRule diff --git a/app/src/main/java/io/legado/app/ui/book/read/sheet/ShadowSetSheet.kt b/app/src/main/java/io/legado/app/ui/book/read/sheet/ShadowSetSheet.kt index 1294c71d0..f58940681 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/sheet/ShadowSetSheet.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/sheet/ShadowSetSheet.kt @@ -83,16 +83,14 @@ fun ShadowSetSheet( } } - if (showColorPicker) { - ColorPickerSheet( - show = true, - initialColor = shadowColor, - onDismissRequest = { showColorPicker = false }, - onColorSelected = { color -> - shadowColor = color - onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.ShadowColor(color))) - showColorPicker = false - }, - ) - } + ColorPickerSheet( + show = showColorPicker, + initialColor = shadowColor, + onDismissRequest = { showColorPicker = false }, + onColorSelected = { color -> + shadowColor = color + onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.ShadowColor(color))) + showColorPicker = false + }, + ) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/sheet/SystemMenuPage.kt b/app/src/main/java/io/legado/app/ui/book/read/sheet/SystemMenuPage.kt index cbfe9c1bf..5a5ddafba 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/sheet/SystemMenuPage.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/sheet/SystemMenuPage.kt @@ -150,26 +150,24 @@ internal fun SystemMenuPage( } // Floating sheets - if (showColorPicker) { - ColorPickerSheet( - show = true, - initialColor = colorPickerInitial, - onDismissRequest = { showColorPicker = false }, - onColorSelected = { color -> - when (colorPickerId) { - COLOR_BG -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MenuBgColor(color))) - COLOR_MENU_ACCENT -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MenuAccentColor(color))) - COLOR_MENU_CONTAINER -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MenuContainerColor(color))) - COLOR_BG_NIGHT -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MenuBgColorNight(color))) - COLOR_MENU_ACCENT_NIGHT -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MenuAccentColorNight(color))) - COLOR_MENU_CONTAINER_NIGHT -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MenuContainerColorNight(color))) - COLOR_BORDER -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.BorderColor(color))) - COLOR_BORDER_NIGHT -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.BorderColorNight(color))) - } - showColorPicker = false - }, - ) - } + ColorPickerSheet( + show = showColorPicker, + initialColor = colorPickerInitial, + onDismissRequest = { showColorPicker = false }, + onColorSelected = { color -> + when (colorPickerId) { + COLOR_BG -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MenuBgColor(color))) + COLOR_MENU_ACCENT -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MenuAccentColor(color))) + COLOR_MENU_CONTAINER -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MenuContainerColor(color))) + COLOR_BG_NIGHT -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MenuBgColorNight(color))) + COLOR_MENU_ACCENT_NIGHT -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MenuAccentColorNight(color))) + COLOR_MENU_CONTAINER_NIGHT -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MenuContainerColorNight(color))) + COLOR_BORDER -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.BorderColor(color))) + COLOR_BORDER_NIGHT -> onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.BorderColorNight(color))) + } + showColorPicker = false + }, + ) BottomBarIconSheet( show = showIconSheet, diff --git a/app/src/main/java/io/legado/app/ui/book/read/sheet/TextTitleSheet.kt b/app/src/main/java/io/legado/app/ui/book/read/sheet/TextTitleSheet.kt index c05ad6c38..bafccfceb 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/sheet/TextTitleSheet.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/sheet/TextTitleSheet.kt @@ -381,25 +381,23 @@ internal fun TextEffectsPage( } // Color picker - if (showColorPicker) { - ColorPickerSheet( - show = true, - initialColor = colorPickerInitial, - onDismissRequest = { showColorPicker = false }, - onColorSelected = { color -> - when (colorPickerId) { - COLOR_TEXT -> { - onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TextColor(color))) - } - - COLOR_ACCENT -> { - onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TextAccentColor(color))) - } + ColorPickerSheet( + show = showColorPicker, + initialColor = colorPickerInitial, + onDismissRequest = { showColorPicker = false }, + onColorSelected = { color -> + when (colorPickerId) { + COLOR_TEXT -> { + onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TextColor(color))) } - showColorPicker = false - }, - ) - } + + COLOR_ACCENT -> { + onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TextAccentColor(color))) + } + } + showColorPicker = false + }, + ) } // ========== Title Settings (sub-page) ========== @@ -527,19 +525,17 @@ internal fun TitleSettingsPage( } // Color picker - if (showColorPicker) { - ColorPickerSheet( - show = true, - initialColor = colorPickerInitial, - onDismissRequest = { showColorPicker = false }, - onColorSelected = { color -> - when (colorPickerId) { - COLOR_TITLE -> { - onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TitleColor(color))) - } + ColorPickerSheet( + show = showColorPicker, + initialColor = colorPickerInitial, + onDismissRequest = { showColorPicker = false }, + onColorSelected = { color -> + when (colorPickerId) { + COLOR_TITLE -> { + onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TitleColor(color))) } - showColorPicker = false - }, - ) - } + } + showColorPicker = false + }, + ) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/sheet/UnderlineConfigSheet.kt b/app/src/main/java/io/legado/app/ui/book/read/sheet/UnderlineConfigSheet.kt index 5c3bc5e43..9b1bc17dc 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/sheet/UnderlineConfigSheet.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/sheet/UnderlineConfigSheet.kt @@ -146,16 +146,14 @@ fun UnderlineConfigSheet( } // Color picker - if (showColorPicker) { - ColorPickerSheet( - show = true, - initialColor = underlineColor, - onDismissRequest = { showColorPicker = false }, - onColorSelected = { color -> - underlineColor = color - onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.UnderlineColor(color))) - showColorPicker = false - }, - ) - } + ColorPickerSheet( + show = showColorPicker, + initialColor = underlineColor, + onDismissRequest = { showColorPicker = false }, + onColorSelected = { color -> + underlineColor = color + onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.UnderlineColor(color))) + showColorPicker = false + }, + ) }