Skip to content

Commit

Permalink
fix(bottomsheet): Add statusBar size on the content padding (#1335)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulcramer authored Oct 7, 2024
1 parent 3061147 commit 04bf3ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ private fun ConfiguredBottomSheet(
BottomSheetContentExamples.List -> ListContent(onHideBottomSheetClicked)
}
},
applyTempStatusBarPadding = true,
dragHandle = if (isDragHandlerEnabled) {
{ DragHandle() }
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.BottomSheetDefaults
import androidx.compose.material3.BottomSheetDefaults.ExpandedShape
Expand Down Expand Up @@ -102,13 +104,15 @@ public fun BottomSheet(
dragHandle: @Composable (() -> Unit)? = {
DragHandle()
},
applyTempStatusBarPadding: Boolean = false,
content: @Composable ColumnScope.() -> Unit,
) {
SparkModalBottomSheet(
onDismissRequest = onDismissRequest,
modifier = modifier.sparkUsageOverlay(),
sheetState = sheetState,
content = content,
applyTempStatusBarPadding = applyTempStatusBarPadding,
dragHandle = dragHandle,
)
}
Expand Down Expand Up @@ -152,6 +156,7 @@ internal fun SparkModalBottomSheet(
dragHandle: (@Composable () -> Unit)? = { DragHandle() },
contentWindowInsets: @Composable () -> WindowInsets = { BottomSheetDefaults.windowInsets },
properties: ModalBottomSheetProperties = ModalBottomSheetDefaults.properties,
applyTempStatusBarPadding: Boolean = false,
content: @Composable ColumnScope.() -> Unit,
) {
androidx.compose.material3.ModalBottomSheet(
Expand All @@ -166,9 +171,15 @@ internal fun SparkModalBottomSheet(
dragHandle = null,
) {
Box {
val systemBarTopInsets = WindowInsets.systemBars.asPaddingValues().calculateTopPadding()
val additionalTopPadding = if (applyTempStatusBarPadding) systemBarTopInsets else 0.dp
Column(
modifier = Modifier.padding(
top = if (dragHandle != null) ContentTopPadding else ContentTopPaddingNoHandle,
top = if (dragHandle != null) {
ContentTopPadding + additionalTopPadding
} else {
ContentTopPaddingNoHandle + additionalTopPadding
},
),
) {
content()
Expand Down

0 comments on commit 04bf3ed

Please sign in to comment.