refactor: 代码优化
This commit is contained in:
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 ->
|
||||
@@ -94,5 +93,4 @@ fun ShadowSetSheet(
|
||||
showColorPicker = false
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -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 ->
|
||||
@@ -399,7 +398,6 @@ internal fun TextEffectsPage(
|
||||
showColorPicker = false
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 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 ->
|
||||
@@ -541,5 +538,4 @@ internal fun TitleSettingsPage(
|
||||
showColorPicker = false
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -146,9 +146,8 @@ fun UnderlineConfigSheet(
|
||||
}
|
||||
|
||||
// Color picker
|
||||
if (showColorPicker) {
|
||||
ColorPickerSheet(
|
||||
show = true,
|
||||
show = showColorPicker,
|
||||
initialColor = underlineColor,
|
||||
onDismissRequest = { showColorPicker = false },
|
||||
onColorSelected = { color ->
|
||||
@@ -157,5 +156,4 @@ fun UnderlineConfigSheet(
|
||||
showColorPicker = false
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user