refactor: 代码优化

This commit is contained in:
HapeLee committed 2026-06-12 03:22:13 +08:00
1 parent 81fc3ea7e4
commit d4745b55b4
6 files changed
+9 -24

No files matched your search

@@ -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 ->
@@ -74,29 +74,24 @@ fun HighlightRuleConfigSheet(
// Edit existing rule
val editingRuleValue = state.editingRule
if (show && editingRuleValue != null) {
HighlightRuleEditSheet(
show = true,
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,
show = show && state.showNewRule,
rule = null,
onDismissRequest = { onIntent(ReadBookIntent.DismissHighlightRuleEdit) },
onSave = { newRule ->
onIntent(ReadBookIntent.SaveHighlightRule(newRule))
},
)
}
// Delete confirmation
val deletingRule = state.deleteRule
@@ -83,9 +83,8 @@ fun ShadowSetSheet(
}
}
if (showColorPicker) {
ColorPickerSheet(
show = true,
show = showColorPicker,
initialColor = shadowColor,
onDismissRequest = { showColorPicker = false },
onColorSelected = { color ->
@@ -95,4 +94,3 @@ fun ShadowSetSheet(
},
)
}
}
@@ -150,9 +150,8 @@ internal fun SystemMenuPage(
}
// Floating sheets
if (showColorPicker) {
ColorPickerSheet(
show = true,
show = showColorPicker,
initialColor = colorPickerInitial,
onDismissRequest = { showColorPicker = false },
onColorSelected = { color ->
@@ -169,7 +168,6 @@ internal fun SystemMenuPage(
showColorPicker = false
},
)
}
BottomBarIconSheet(
show = showIconSheet,
@@ -381,9 +381,8 @@ internal fun TextEffectsPage(
}
// Color picker
if (showColorPicker) {
ColorPickerSheet(
show = true,
show = showColorPicker,
initialColor = colorPickerInitial,
onDismissRequest = { showColorPicker = false },
onColorSelected = { color ->
@@ -400,7 +399,6 @@ internal fun TextEffectsPage(
},
)
}
}
// ========== Title Settings (sub-page) ==========
@@ -527,9 +525,8 @@ internal fun TitleSettingsPage(
}
// Color picker
if (showColorPicker) {
ColorPickerSheet(
show = true,
show = showColorPicker,
initialColor = colorPickerInitial,
onDismissRequest = { showColorPicker = false },
onColorSelected = { color ->
@@ -542,4 +539,3 @@ internal fun TitleSettingsPage(
},
)
}
}
@@ -146,9 +146,8 @@ fun UnderlineConfigSheet(
}
// Color picker
if (showColorPicker) {
ColorPickerSheet(
show = true,
show = showColorPicker,
initialColor = underlineColor,
onDismissRequest = { showColorPicker = false },
onColorSelected = { color ->
@@ -158,4 +157,3 @@ fun UnderlineConfigSheet(
},
)
}
}