fix:修改样式名称时,bottomsheet被抬高的问题

This commit is contained in:
fansan
2026-06-22 18:54:55 +08:00
parent bea1095b0a
commit 97e5784b7e
2 changed files with 10 additions and 1 deletions
@@ -11,6 +11,8 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
@@ -89,6 +91,7 @@ fun BgTextConfigSheet(
onDismissRequest() onDismissRequest()
}, },
title = styleName, title = styleName,
contentWindowInsets = { WindowInsets.navigationBars },
) { ) {
Column( Column(
modifier = Modifier modifier = Modifier
@@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.material3.BottomSheetDefaults import androidx.compose.material3.BottomSheetDefaults
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
@@ -47,6 +48,7 @@ fun AppModalBottomSheet(
title: String? = null, title: String? = null,
startAction: @Composable (() -> Unit)? = null, startAction: @Composable (() -> Unit)? = null,
endAction: @Composable (() -> Unit)? = null, endAction: @Composable (() -> Unit)? = null,
contentWindowInsets: @Composable () -> WindowInsets = { BottomSheetDefaults.modalWindowInsets },
content: @Composable ColumnScope.() -> Unit content: @Composable ColumnScope.() -> Unit
) { ) {
val colorScheme = LocalLegadoThemeColors.current.colorScheme val colorScheme = LocalLegadoThemeColors.current.colorScheme
@@ -115,7 +117,8 @@ fun AppModalBottomSheet(
sheetState = sheetState, sheetState = sheetState,
containerColor = sheetContainerColor, containerColor = sheetContainerColor,
contentColor = sheetContentColor, contentColor = sheetContentColor,
dragHandle = { BottomSheetDefaults.DragHandle(color = sheetDragHandleColor) } dragHandle = { BottomSheetDefaults.DragHandle(color = sheetDragHandleColor) },
contentWindowInsets = contentWindowInsets
) { ) {
Column( Column(
modifier = Modifier modifier = Modifier
@@ -173,6 +176,7 @@ fun AppModalBottomSheet(
* 专为 nullable 数据设计的 AppModalBottomSheet 重载。 * 专为 nullable 数据设计的 AppModalBottomSheet 重载。
* 当 [data] 不为 null 时显示弹窗;当 [data] 变为 null 时,自动缓存最后一次数据并播放退出动画。 * 当 [data] 不为 null 时显示弹窗;当 [data] 变为 null 时,自动缓存最后一次数据并播放退出动画。
*/ */
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
@Composable @Composable
fun <T> AppModalBottomSheet( fun <T> AppModalBottomSheet(
data: T?, data: T?,
@@ -181,6 +185,7 @@ fun <T> AppModalBottomSheet(
title: String? = null, title: String? = null,
startAction: @Composable (() -> Unit)? = null, startAction: @Composable (() -> Unit)? = null,
endAction: @Composable (() -> Unit)? = null, endAction: @Composable (() -> Unit)? = null,
contentWindowInsets: @Composable () -> WindowInsets = { BottomSheetDefaults.modalWindowInsets },
content: @Composable ColumnScope.(T) -> Unit content: @Composable ColumnScope.(T) -> Unit
) { ) {
var cachedData by remember { mutableStateOf(data) } var cachedData by remember { mutableStateOf(data) }
@@ -197,6 +202,7 @@ fun <T> AppModalBottomSheet(
title = title, title = title,
startAction = startAction, startAction = startAction,
endAction = endAction, endAction = endAction,
contentWindowInsets = contentWindowInsets,
content = { content = {
if (currentData != null) { if (currentData != null) {
content(currentData) content(currentData)