fix:代码优化

This commit is contained in:
fansan committed 2026-06-18 00:24:39 +08:00
1 parent ee7fbe305f
commit 8b743298ec
1 file changed
+1 -4
@@ -71,7 +71,6 @@ import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableIntStateOf
@@ -415,11 +414,9 @@ private fun ReadBookMenuSurface(
val orientation = LocalConfiguration.current.orientation val orientation = LocalConfiguration.current.orientation
val currentNavBarHeight = with(density) { WindowInsets.navigationBars.getBottom(this).toDp() } val currentNavBarHeight = with(density) { WindowInsets.navigationBars.getBottom(this).toDp() }
var lastValidNavBarHeightValue by rememberSaveable(orientation) { mutableFloatStateOf(currentNavBarHeight.value) } var lastValidNavBarHeightValue by rememberSaveable(orientation) { mutableFloatStateOf(currentNavBarHeight.value) }
SideEffect { if (currentNavBarHeight.value > 0f && lastValidNavBarHeightValue != currentNavBarHeight.value) {
if (currentNavBarHeight.value > 0f) {
lastValidNavBarHeightValue = currentNavBarHeight.value lastValidNavBarHeightValue = currentNavBarHeight.value
} }
}
val navBarHeight = if (currentNavBarHeight.value > 0f) currentNavBarHeight else lastValidNavBarHeightValue.dp val navBarHeight = if (currentNavBarHeight.value > 0f) currentNavBarHeight else lastValidNavBarHeightValue.dp
val floatingHorizontalMargin = if (isFloating) 16.dp else 0.dp val floatingHorizontalMargin = if (isFloating) 16.dp else 0.dp
val floatingBottomMargin = if (isFloating) 16.dp + navBarHeight else 0.dp val floatingBottomMargin = if (isFloating) 16.dp + navBarHeight else 0.dp