Skip to content

Commit

Permalink
Force sheet content's alignment to TopCenter
Browse files Browse the repository at this point in the history
The alignment of the sheet is important as all calculations are based off TopCenter. If the user changes this the sheet breaks.
  • Loading branch information
alexstyl committed Aug 2, 2024
1 parent 607df47 commit 070d768
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/src/commonMain/kotlin/BottomSheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ public fun BottomSheet(
.onSizeChanged {
containerHeight = with(density) { it.height.toDp() }
state.containerHeight = it.height.toFloat()
},
contentAlignment = Alignment.TopCenter
}
) {
Box(
contentAlignment = Alignment.TopCenter,
Expand Down Expand Up @@ -294,6 +293,7 @@ public fun BottomSheet(
enabled = scope.enabled
)
.pointerInput(Unit) { detectTapGestures { } }
.align(Alignment.TopCenter)
.then(modifier)
) {
scope.content()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ fun ModalBottomSheetDemo() {
modifier = Modifier
.padding(top = 12.dp)
.let { if (isCompact) it else it.padding(horizontal = 56.dp) }
.align(Alignment.BottomCenter)
.statusBarsPadding()
.padding(WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal).asPaddingValues())
.shadow(4.dp, RoundedCornerShape(topStart = 28.dp, topEnd = 28.dp))
Expand Down
1 change: 0 additions & 1 deletion demo-sheet/src/commonMain/kotlin/BottomSheetDemo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ fun BottomSheetDemo() {
modifier = Modifier
.padding(top = 12.dp)
.let { if (isCompact) it else it.padding(horizontal = 56.dp) }
.align(Alignment.BottomCenter)
.statusBarsPadding()
.padding(WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal).asPaddingValues())
.shadow(4.dp, RoundedCornerShape(topStart = 28.dp, topEnd = 28.dp))
Expand Down

0 comments on commit 070d768

Please sign in to comment.