fix: 关闭悬浮底栏时LiquidGlass回退导致卡死
将LiquidGlass→Haze回退逻辑从SystemMenuPage的双Intent分发移至 ViewModel的FloatingBottomBar处理器中,确保readMenuFloatingBottomBar 和readMenuBottomBarBlurMode在同一_uiState.update中原子更新, 避免渲染管线看到floating=false+blurMode=LiquidGlass的非法中间状态。
This commit is contained in:
@@ -2531,10 +2531,26 @@ class ReadBookViewModel(
|
||||
}
|
||||
is ConfigUpdate.FloatingBottomBar -> {
|
||||
ReadBookConfig.readMenuFloatingBottomBar = update.value
|
||||
val needsBlurFallback = !update.value &&
|
||||
ReadBookConfig.readMenuBottomBarBlurMode == ReadMenuBlurMode.LiquidGlass
|
||||
if (needsBlurFallback) {
|
||||
ReadBookConfig.readMenuBottomBarBlurMode = ReadMenuBlurMode.Haze
|
||||
}
|
||||
viewModelScope.launch {
|
||||
readSettingsRepository.setReadMenuFloatingBottomBar(update.value)
|
||||
if (needsBlurFallback) {
|
||||
readSettingsRepository.setReadMenuBottomBarBlurMode(ReadMenuBlurMode.Haze)
|
||||
}
|
||||
}
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
menuConfig = it.menuConfig.copy(
|
||||
readMenuFloatingBottomBar = update.value,
|
||||
readMenuBottomBarBlurMode = if (needsBlurFallback) ReadMenuBlurMode.Haze
|
||||
else it.menuConfig.readMenuBottomBarBlurMode,
|
||||
)
|
||||
)
|
||||
}
|
||||
_uiState.update { it.copy(menuConfig = it.menuConfig.copy(readMenuFloatingBottomBar = update.value)) }
|
||||
}
|
||||
is ConfigUpdate.MenuTopBarBlurMode -> {
|
||||
val mode = update.value.coerceIn(0, 2).let {
|
||||
|
||||
@@ -525,15 +525,6 @@ private fun BottomBarTab(
|
||||
title = stringResource(R.string.read_menu_floating_bottom_bar),
|
||||
checked = floatingBottomBar,
|
||||
onCheckedChange = {
|
||||
if (!it && preferences.readMenuBottomBarBlurMode == ReadMenuBlurMode.LiquidGlass) {
|
||||
onIntent(
|
||||
ReadBookIntent.UpdateConfig(
|
||||
ConfigUpdate.MenuBottomBarBlurMode(
|
||||
ReadMenuBlurMode.Haze
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.FloatingBottomBar(it)))
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user