Last active
August 9, 2024 16:30
-
-
Save EfeBudak/4ab456f44509b0160858a875206ab0b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val bottomSheetState = rememberStandardBottomSheetState() | |
val scaffoldState = rememberBottomSheetScaffoldState(bottomSheetState) | |
BottomSheetScaffold( | |
modifier = Modifier.fillMaxSize(), | |
scaffoldState = scaffoldState, | |
sheetContainerColor = Color.Transparent, | |
sheetContent = { | |
// Put whatever the sheet you want in here | |
} | |
) { innerPadding -> | |
Box( | |
modifier = Modifier | |
.fillMaxSize() | |
.padding(innerPadding) | |
) { | |
var composableHeight by remember { mutableStateOf(0) } // the height I mentioned | |
Box( | |
modifier = Modifier | |
.fillMaxWidth() | |
// `.padding(16.dp)` is messing with the `.offset`. Use it after the `.offset` call | |
.onSizeChanged { composableHeight = it.height } // Dear Modifier, thanks for having such a good function | |
.offset { | |
IntOffset( | |
x = 0, | |
y = bottomSheetState.requireOffset().roundToInt() - composableHeight, // these values represent pixels | |
) | |
} | |
.padding(16.dp) | |
) { | |
FloatingActionButton( | |
modifier = Modifier.align(Alignment.CenterEnd), | |
onClick = { /*TODO*/ } | |
) { | |
Image( | |
painter = painterResource(id = R.drawable.ic_launcher_foreground), | |
contentDescription = null | |
) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment