fix:nav高度获取边界问题修改

This commit is contained in:
fansan
2026-06-17 23:56:45 +08:00
parent f891e95f5e
commit fab44fabea
@@ -6,10 +6,8 @@ import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.SizeTransform import androidx.compose.animation.SizeTransform
import androidx.compose.animation.animateContentSize import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.animateDpAsState import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally import androidx.compose.animation.slideInHorizontally
@@ -73,6 +71,7 @@ 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
@@ -413,11 +412,13 @@ private fun ReadBookMenuSurface(
} }
val isFloating = state.menuConfig.readMenuFloatingBottomBar val isFloating = state.menuConfig.readMenuFloatingBottomBar
val currentNavBarHeight = with(density) { WindowInsets.navigationBars.getBottom(this).toDp() } val currentNavBarHeight = with(density) { WindowInsets.navigationBars.getBottom(this).toDp() }
var maxNavBarHeightValue by rememberSaveable { mutableFloatStateOf(0f) } var lastValidNavBarHeightValue by rememberSaveable { mutableFloatStateOf(currentNavBarHeight.value) }
if (currentNavBarHeight.value > maxNavBarHeightValue) { SideEffect {
maxNavBarHeightValue = currentNavBarHeight.value if (currentNavBarHeight.value > 0f) {
lastValidNavBarHeightValue = currentNavBarHeight.value
} }
val navBarHeight = if (currentNavBarHeight.value > 0f) currentNavBarHeight else maxNavBarHeightValue.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
val mainHorizontalMargin = val mainHorizontalMargin =