Browse Source

fix(reader): 排版弹层重开显示旧值 + 修正状态栏图标/下划线颜色刷新动作

- sheetConfig 与 styleConfig 同步重建(handleConfigUpdate 尾部、删除/预设/
  导入排版、日夜切换共 5 处),修复排版设置弹层重开时控件从旧快照初始化
- StatusIconDark: ReloadContent → UpdateSystemUi(真正生效的是
  setLightStatusBar(curStatusIconDark()),原动作既不生效又整章重排)
- UnderlineColor: UpdateStyle → UpdateContent+InvalidateTextPage+
  SubmitRenderTask,对齐 Underline/DottedLine 兄弟项,确保缓存页重绘新颜色
5151561 3 tháng trước cách đây
mục cha
commit
bf561ed427

+ 2 - 2
app/src/main/java/io/legado/app/ui/book/read/ReadBookContract.kt

@@ -1306,7 +1306,7 @@ sealed interface ConfigUpdate {
         override val actions = setOf(ConfigUpdateAction.UpdateContent, ConfigUpdateAction.UpdateChapterStyle, ConfigUpdateAction.UpdateLayout)
         override val actions = setOf(ConfigUpdateAction.UpdateContent, ConfigUpdateAction.UpdateChapterStyle, ConfigUpdateAction.UpdateLayout)
     }
     }
     data class UnderlineColor(val color: Int) : ConfigUpdate {
     data class UnderlineColor(val color: Int) : ConfigUpdate {
-        override val actions = setOf(ConfigUpdateAction.UpdateStyle)
+        override val actions = setOf(ConfigUpdateAction.UpdateContent, ConfigUpdateAction.InvalidateTextPage, ConfigUpdateAction.SubmitRenderTask)
     }
     }
 
 
     // --- Body padding ---
     // --- Body padding ---
@@ -1380,7 +1380,7 @@ sealed interface ConfigUpdate {
         override val actions = setOf(ConfigUpdateAction.UpdateBackgroundAlpha)
         override val actions = setOf(ConfigUpdateAction.UpdateBackgroundAlpha)
     }
     }
     data class StatusIconDark(val value: Boolean) : ConfigUpdate {
     data class StatusIconDark(val value: Boolean) : ConfigUpdate {
-        override val actions = setOf(ConfigUpdateAction.ReloadContent)
+        override val actions = setOf(ConfigUpdateAction.UpdateSystemUi)
     }
     }
     data class StyleName(val value: String) : ConfigUpdate {
     data class StyleName(val value: String) : ConfigUpdate {
         override val actions = emptySet<ConfigUpdateAction>()
         override val actions = emptySet<ConfigUpdateAction>()

+ 24 - 7
app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@@ -1461,6 +1461,7 @@ class ReadBookViewModel(
                     _uiState.update {
                     _uiState.update {
                         it.copy(
                         it.copy(
                             styleConfig = buildStyleConfig(),
                             styleConfig = buildStyleConfig(),
+                            sheetConfig = buildSheetConfig(),
                             activeSheet = null,
                             activeSheet = null,
                         )
                         )
                     }
                     }
@@ -1478,7 +1479,12 @@ class ReadBookViewModel(
                 if (!readBookStyleConfigRepository.applyPreset(intent.presetIndex)) {
                 if (!readBookStyleConfigRepository.applyPreset(intent.presetIndex)) {
                     return@onIntent
                     return@onIntent
                 }
                 }
-                _uiState.update { it.copy(styleConfig = buildStyleConfig()) }
+                _uiState.update {
+                    it.copy(
+                        styleConfig = buildStyleConfig(),
+                        sheetConfig = buildSheetConfig(),
+                    )
+                }
                 _effects.tryEmit(
                 _effects.tryEmit(
                     ReadBookEffect.UpdateReadViewConfig(
                     ReadBookEffect.UpdateReadViewConfig(
                         setOf(
                         setOf(
@@ -5495,12 +5501,17 @@ class ReadBookViewModel(
             }
             }
         }
         }
 
 
-        // Notify rendering layer
+        // Notify rendering layer. styleConfig and sheetConfig are both derived
+        // from ReadBookConfig, so keep them rebuilt together — otherwise the
+        // settings sheet re-seeds its controls from a stale sheetConfig on reopen.
+        _uiState.update {
+            it.copy(
+                styleConfig = buildStyleConfig(),
+                sheetConfig = buildSheetConfig(),
+            )
+        }
         if (update.actions.isNotEmpty()) {
         if (update.actions.isNotEmpty()) {
-            _uiState.update { it.copy(styleConfig = buildStyleConfig()) }
             _effects.tryEmit(ReadBookEffect.UpdateReadViewConfig(update.actions))
             _effects.tryEmit(ReadBookEffect.UpdateReadViewConfig(update.actions))
-        } else {
-            _uiState.update { it.copy(styleConfig = buildStyleConfig()) }
         }
         }
     }
     }
 
 
@@ -5967,7 +5978,8 @@ class ReadBookViewModel(
             }
             }
             it.copy(
             it.copy(
                 activeReminder = newActiveReminder,
                 activeReminder = newActiveReminder,
-                styleConfig = buildStyleConfig()
+                styleConfig = buildStyleConfig(),
+                sheetConfig = buildSheetConfig(),
             )
             )
         }
         }
         reminderQueue.removeAll { it.type is ReminderType.DayNightReminder }
         reminderQueue.removeAll { it.type is ReminderType.DayNightReminder }
@@ -6033,7 +6045,12 @@ class ReadBookViewModel(
                 val bytes = context.contentResolver.openInputStream(uri)?.use { it.readBytes() }
                 val bytes = context.contentResolver.openInputStream(uri)?.use { it.readBytes() }
                     ?: throw FileNotFoundException(uri.toString())
                     ?: throw FileNotFoundException(uri.toString())
                 readBookStyleConfigRepository.importCurrentStyle(bytes)
                 readBookStyleConfigRepository.importCurrentStyle(bytes)
-                _uiState.update { it.copy(styleConfig = buildStyleConfig()) }
+                _uiState.update {
+                    it.copy(
+                        styleConfig = buildStyleConfig(),
+                        sheetConfig = buildSheetConfig(),
+                    )
+                }
                 _effects.tryEmit(ReadBookEffect.UpdateReadViewConfig(
                 _effects.tryEmit(ReadBookEffect.UpdateReadViewConfig(
                     setOf(
                     setOf(
                         ConfigUpdateAction.UpdateBackground,
                         ConfigUpdateAction.UpdateBackground,