HapeLee 3 kuukautta sitten
vanhempi
commit
b807e31d35

+ 15 - 14
app/src/main/java/io/legado/app/ui/book/read/sheet/HeaderFooterPage.kt

@@ -329,13 +329,6 @@ internal fun HeaderFooterPage(
                                 showColorPicker = true
                             },
                         )
-                        TinyClickableSettingItem(
-                            title = stringResource(R.string.reset_to_body_color),
-                            onClick = {
-                                onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TipHeaderColor(0)))
-                                onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TipHeaderColorNight(0)))
-                            },
-                        )
 
                         TinyClickableSettingItem(
                             title = stringResource(R.string.padding),
@@ -480,13 +473,6 @@ internal fun HeaderFooterPage(
                                 showColorPicker = true
                             },
                         )
-                        TinyClickableSettingItem(
-                            title = stringResource(R.string.reset_to_body_color),
-                            onClick = {
-                                onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TipFooterColor(0)))
-                                onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TipFooterColorNight(0)))
-                            },
-                        )
 
                         TinyClickableSettingItem(
                             title = stringResource(R.string.padding),
@@ -620,6 +606,21 @@ internal fun HeaderFooterPage(
             }
             showColorPicker = false
         },
+        onResetToDefault = {
+            when (colorPickerId) {
+                COLOR_HEADER, COLOR_HEADER_NIGHT -> {
+                    onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TipHeaderColor(0)))
+                    onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TipHeaderColorNight(0)))
+                }
+
+                COLOR_FOOTER, COLOR_FOOTER_NIGHT -> {
+                    onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TipFooterColor(0)))
+                    onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TipFooterColorNight(0)))
+                }
+
+                else -> { /* divider has no reset-to-body logic */ }
+            }
+        },
     )
 
     // Font selector for header/footer

+ 4 - 7
app/src/main/java/io/legado/app/ui/book/read/sheet/TextTitleSheet.kt

@@ -472,13 +472,6 @@ internal fun TitleSettingsPage(
                 showColorPicker = true
             },
         )
-        TinyClickableSettingItem(
-            title = stringResource(R.string.reset_to_body_color),
-            onClick = {
-                onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TitleColor(0)))
-                onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TitleColorNight(0)))
-            },
-        )
 
         // Title font
         TinyClickableSettingItem(
@@ -622,6 +615,10 @@ internal fun TitleSettingsPage(
             }
             showColorPicker = false
         },
+        onResetToDefault = {
+            onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TitleColor(0)))
+            onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TitleColorNight(0)))
+        },
     )
 }
 

+ 15 - 1
app/src/main/java/io/legado/app/ui/widget/components/dialog/ColorPickerSheet.kt

@@ -38,6 +38,7 @@ import io.legado.app.R
 import io.legado.app.ui.theme.LegadoTheme
 import io.legado.app.ui.widget.components.AppTextField
 import io.legado.app.ui.widget.components.button.ConfirmDismissButtonsRow
+import io.legado.app.ui.widget.components.button.SecondaryButton
 import io.legado.app.ui.widget.components.modalBottomSheet.AppModalBottomSheet
 import io.legado.app.ui.widget.components.text.AppText
 import io.legado.app.utils.isHex
@@ -51,7 +52,8 @@ fun ColorPickerSheet(
     show: Boolean,
     initialColor: Int,
     onDismissRequest: () -> Unit,
-    onColorSelected: (Int) -> Unit
+    onColorSelected: (Int) -> Unit,
+    onResetToDefault: (() -> Unit)? = null,
 ) {
     var currentColor by remember { mutableStateOf(Color(initialColor)) }
     var hexInput by remember { mutableStateOf(initialColor.asHexColorString()) }
@@ -137,6 +139,18 @@ fun ColorPickerSheet(
 
             Spacer(modifier = Modifier.height(16.dp))
 
+            if (onResetToDefault != null) {
+                SecondaryButton(
+                    onClick = {
+                        onResetToDefault()
+                        onDismissRequest()
+                    },
+                    modifier = Modifier.fillMaxWidth(),
+                    text = stringResource(R.string.reset_to_body_color)
+                )
+                Spacer(modifier = Modifier.height(12.dp))
+            }
+
             ConfirmDismissButtonsRow(
                 modifier = Modifier.fillMaxWidth(),
                 onDismiss = onDismissRequest,

+ 1 - 0
app/src/main/res/values-zh-rCN/strings.xml

@@ -1018,6 +1018,7 @@
     <string name="use_default_cover_s">总是显示默认封面(不显示网络封面)</string>
     <string name="title_font_size">字号</string>
     <string name="title_color">标题颜色</string>
+    <string name="reset_to_body_color">重置为正文颜色</string>
     <string name="title_margin_top">上边距</string>
     <string name="title_margin_bottom">下边距</string>
     <string name="show">显示</string>

+ 1 - 0
app/src/main/res/values-zh-rHK/strings.xml

@@ -2178,6 +2178,7 @@
     <string name="title_bar_layout">標題欄佈局</string>
     <string name="title_bar_mode">選單中的標題模式</string>
     <string name="title_color">標題顏色</string>
+    <string name="reset_to_body_color">重置為正文顏色</string>
     <string name="toc_disabled_format">%1$s 目錄已禁用</string>
     <string name="toc_rule_update_failed">章節規則更新失敗:%1$s</string>
     <string name="toc_rule_updated">章節規則已更新</string>

+ 1 - 0
app/src/main/res/values-zh-rTW/strings.xml

@@ -1528,6 +1528,7 @@
     <string name="image_style_text">文字吸附</string>
     <string name="image_style_single">單頁</string>
     <string name="title_color">標題顏色</string>
+    <string name="reset_to_body_color">重置為正文顏色</string>
     <string name="export_file_name_template_hint">{name} - {author}</string>
     <string name="export_file_name_template_help">可用變數:{name} 書名、{author} 作者、{group} 分組、{source} 來源、{remark} 備註。