admin管理员组

文章数量:1434380

I have a full screen ModalBottomSheet (compose material3). The content inside bottomsheet is Lazycolumn. I make it non-dismissable but it is getting dismissed because of the inner scroll in LazyColumn

 val state = rememberModalBottomSheetState(
        skipPartiallyExpanded = true,
        confirmValueChange = {
            // Just to prevent the bottom sheet from hiding (Non-dismissible, Non-draggable)
            false
        },
    )

 var showBottomSheet by remember { mutableStateOf(false) }

    LaunchedEffect(isVisible) {
        if (isVisible) {
            showBottomSheet = true
        } else {
            scope.launch {
                state.hide()
            }.invokeOnCompletion {
                showBottomSheet = false
            }
        }
    }

    if (showBottomSheet) {
        ModalBottomSheet(
            sheetState = state,
            shape = RoundedCornerShape(topStart = 6.dp, topEnd = 6.dp),
            containerColor = Theme.colorScheme.surface,
            contentColor = Theme.colorScheme.onSurface,
            tonalElevation = 0.dp,
            dragHandle = {},
            windowInsets = WindowInsets(0, 0, 0, 0),
            onDismissRequest = {

            },
            properties = ModalBottomSheetProperties(
                isFocusable = false,
                securePolicy = ModalBottomSheetDefaults.properties().securePolicy,
                shouldDismissOnBackPress = false,
            ),
            modifier = modifier
                .fillMaxWidth()
                .constrainScreenWidth()
                ,
        ) {
            Box(
                modifier = Modifier
                    .fillMaxSize()

            )
            {
                LazyColumn(modifier = Modifier.padding(16.dp)) {
                    items(100) { index ->
                        Text("Item #$index", modifier = Modifier.padding(vertical = 4.dp))
                    }
                }
            }
        }
    }

How we can get a non-dismissable bottomsheet with scrollable content

本文标签: JetPack Compose ModalBottomSheet FullScreenStack Overflow