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
|
val initialColor = if (colorPickerIsNight) nightBgColor else dayBgColor
|
||||||
ColorPickerSheet(
|
ColorPickerSheet(
|
||||||
show = true,
|
show = showColorPicker,
|
||||||
initialColor = if (initialColor != 0) initialColor else if (colorPickerIsNight) 0xFF000000.toInt() else 0xFFEEEEEE.toInt(),
|
initialColor = if (initialColor != 0) initialColor else if (colorPickerIsNight) 0xFF000000.toInt() else 0xFFEEEEEE.toInt(),
|
||||||
onDismissRequest = { showColorPicker = false },
|
onDismissRequest = { showColorPicker = false },
|
||||||
onColorSelected = { color ->
|
onColorSelected = { color ->
|
||||||
|
|||||||
@@ -74,29 +74,24 @@ fun HighlightRuleConfigSheet(
|
|||||||
// Edit existing rule
|
// Edit existing rule
|
||||||
val editingRuleValue = state.editingRule
|
val editingRuleValue = state.editingRule
|
||||||
|
|
||||||
if (show && editingRuleValue != null) {
|
|
||||||
HighlightRuleEditSheet(
|
HighlightRuleEditSheet(
|
||||||
show = true,
|
show = show && editingRuleValue != null,
|
||||||
rule = editingRuleValue,
|
rule = editingRuleValue,
|
||||||
onDismissRequest = { onIntent(ReadBookIntent.DismissHighlightRuleEdit) },
|
onDismissRequest = { onIntent(ReadBookIntent.DismissHighlightRuleEdit) },
|
||||||
onSave = { updated ->
|
onSave = { updated ->
|
||||||
onIntent(ReadBookIntent.SaveHighlightRule(updated))
|
onIntent(ReadBookIntent.SaveHighlightRule(updated))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Add new rule
|
// Add new rule
|
||||||
if (show && state.showNewRule) {
|
|
||||||
HighlightRuleEditSheet(
|
HighlightRuleEditSheet(
|
||||||
show = true,
|
show = show && state.showNewRule,
|
||||||
rule = null,
|
rule = null,
|
||||||
onDismissRequest = { onIntent(ReadBookIntent.DismissHighlightRuleEdit) },
|
onDismissRequest = { onIntent(ReadBookIntent.DismissHighlightRuleEdit) },
|
||||||
onSave = { newRule ->
|
onSave = { newRule ->
|
||||||
onIntent(ReadBookIntent.SaveHighlightRule(newRule))
|
onIntent(ReadBookIntent.SaveHighlightRule(newRule))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
// Delete confirmation
|
// Delete confirmation
|
||||||
val deletingRule = state.deleteRule
|
val deletingRule = state.deleteRule
|
||||||
|
|||||||
@@ -83,9 +83,8 @@ fun ShadowSetSheet(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showColorPicker) {
|
|
||||||
ColorPickerSheet(
|
ColorPickerSheet(
|
||||||
show = true,
|
show = showColorPicker,
|
||||||
initialColor = shadowColor,
|
initialColor = shadowColor,
|
||||||
onDismissRequest = { showColorPicker = false },
|
onDismissRequest = { showColorPicker = false },
|
||||||
onColorSelected = { color ->
|
onColorSelected = { color ->
|
||||||
@@ -94,5 +93,4 @@ fun ShadowSetSheet(
|
|||||||
showColorPicker = false
|
showColorPicker = false
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -150,9 +150,8 @@ internal fun SystemMenuPage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Floating sheets
|
// Floating sheets
|
||||||
if (showColorPicker) {
|
|
||||||
ColorPickerSheet(
|
ColorPickerSheet(
|
||||||
show = true,
|
show = showColorPicker,
|
||||||
initialColor = colorPickerInitial,
|
initialColor = colorPickerInitial,
|
||||||
onDismissRequest = { showColorPicker = false },
|
onDismissRequest = { showColorPicker = false },
|
||||||
onColorSelected = { color ->
|
onColorSelected = { color ->
|
||||||
@@ -169,7 +168,6 @@ internal fun SystemMenuPage(
|
|||||||
showColorPicker = false
|
showColorPicker = false
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
BottomBarIconSheet(
|
BottomBarIconSheet(
|
||||||
show = showIconSheet,
|
show = showIconSheet,
|
||||||
|
|||||||
@@ -381,9 +381,8 @@ internal fun TextEffectsPage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Color picker
|
// Color picker
|
||||||
if (showColorPicker) {
|
|
||||||
ColorPickerSheet(
|
ColorPickerSheet(
|
||||||
show = true,
|
show = showColorPicker,
|
||||||
initialColor = colorPickerInitial,
|
initialColor = colorPickerInitial,
|
||||||
onDismissRequest = { showColorPicker = false },
|
onDismissRequest = { showColorPicker = false },
|
||||||
onColorSelected = { color ->
|
onColorSelected = { color ->
|
||||||
@@ -399,7 +398,6 @@ internal fun TextEffectsPage(
|
|||||||
showColorPicker = false
|
showColorPicker = false
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Title Settings (sub-page) ==========
|
// ========== Title Settings (sub-page) ==========
|
||||||
@@ -527,9 +525,8 @@ internal fun TitleSettingsPage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Color picker
|
// Color picker
|
||||||
if (showColorPicker) {
|
|
||||||
ColorPickerSheet(
|
ColorPickerSheet(
|
||||||
show = true,
|
show = showColorPicker,
|
||||||
initialColor = colorPickerInitial,
|
initialColor = colorPickerInitial,
|
||||||
onDismissRequest = { showColorPicker = false },
|
onDismissRequest = { showColorPicker = false },
|
||||||
onColorSelected = { color ->
|
onColorSelected = { color ->
|
||||||
@@ -541,5 +538,4 @@ internal fun TitleSettingsPage(
|
|||||||
showColorPicker = false
|
showColorPicker = false
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -146,9 +146,8 @@ fun UnderlineConfigSheet(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Color picker
|
// Color picker
|
||||||
if (showColorPicker) {
|
|
||||||
ColorPickerSheet(
|
ColorPickerSheet(
|
||||||
show = true,
|
show = showColorPicker,
|
||||||
initialColor = underlineColor,
|
initialColor = underlineColor,
|
||||||
onDismissRequest = { showColorPicker = false },
|
onDismissRequest = { showColorPicker = false },
|
||||||
onColorSelected = { color ->
|
onColorSelected = { color ->
|
||||||
@@ -157,5 +156,4 @@ fun UnderlineConfigSheet(
|
|||||||
showColorPicker = false
|
showColorPicker = false
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user