diff --git a/designsystem/src/androidMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/bottomSheet/BottomSheetUtils.kt b/designsystem/src/androidMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/bottomSheet/BottomSheetUtils.kt new file mode 100644 index 000000000..960593a5f --- /dev/null +++ b/designsystem/src/androidMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/bottomSheet/BottomSheetUtils.kt @@ -0,0 +1,18 @@ +package org.hisp.dhis.mobile.ui.designsystem.component.internal.bottomSheet + +import android.annotation.SuppressLint +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.platform.LocalContext + +//TODO - hack to get navigation bar padding does not take into account IME padding (reflection) +//TODO - Should be remove when google publish https://issuetracker.google.com/issues/274872542 +@Composable +@SuppressLint("DiscouragedApi") +actual fun rememberDimensionByName(name: String): Int { + val resources = LocalContext.current.resources + return remember { + val id = resources.getIdentifier(name, "dimen", "android") + if (id == 0) 0 else resources.getDimensionPixelSize(id) + } +} \ No newline at end of file diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheet.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheet.kt index 1e854fc30..09c244744 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheet.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheet.kt @@ -6,12 +6,13 @@ import androidx.compose.foundation.gestures.ScrollableState import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.requiredHeight import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons @@ -34,6 +35,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import kotlinx.coroutines.launch +import org.hisp.dhis.mobile.ui.designsystem.component.internal.bottomSheet.rememberDimensionByName import org.hisp.dhis.mobile.ui.designsystem.theme.InternalSizeValues import org.hisp.dhis.mobile.ui.designsystem.theme.Shape import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing @@ -159,6 +161,11 @@ fun BottomSheetShell( ) { val sheetState = rememberModalBottomSheetState(true) val scope = rememberCoroutineScope() + + //TODO - hack to get navigation bar padding does not take into account IME padding (reflection) + //TODO - Should be remove when google publish https://issuetracker.google.com/issues/274872542 + val topInsets = WindowInsets(top = rememberDimensionByName("status_bar_height")) + val bottomInsets = WindowInsets(bottom = rememberDimensionByName("navigation_bar_height")) ModalBottomSheet( modifier = modifier, @@ -188,11 +195,13 @@ fun BottomSheetShell( } } }, + windowInsets = topInsets ) { val canScrollForward by derivedStateOf { contentScrollState.canScrollForward } Column( - modifier = Modifier.systemBarsPadding(), + modifier = Modifier + .padding(bottomInsets.asPaddingValues()) ) { Column( modifier = Modifier diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/bottomSheet/BottomSheetUtils.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/bottomSheet/BottomSheetUtils.kt new file mode 100644 index 000000000..1539758fa --- /dev/null +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/bottomSheet/BottomSheetUtils.kt @@ -0,0 +1,9 @@ +package org.hisp.dhis.mobile.ui.designsystem.component.internal.bottomSheet + +import androidx.compose.runtime.Composable + +//TODO - hack to get navigation bar padding does not take into account IME padding (reflection) +//TODO - Should be remove when google publish https://issuetracker.google.com/issues/274872542 + +@Composable +expect fun rememberDimensionByName(name: String): Int \ No newline at end of file diff --git a/designsystem/src/desktopMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/bottomSheet/BottomSheetUtils.kt b/designsystem/src/desktopMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/bottomSheet/BottomSheetUtils.kt new file mode 100644 index 000000000..e8e860ab3 --- /dev/null +++ b/designsystem/src/desktopMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/bottomSheet/BottomSheetUtils.kt @@ -0,0 +1,8 @@ +package org.hisp.dhis.mobile.ui.designsystem.component.internal.bottomSheet + +import androidx.compose.runtime.Composable + +//TODO - hack to get navigation bar padding does not take into account IME padding +//TODO - Should be remove when google published https://issuetracker.google.com/issues/274872542 +@Composable +actual fun rememberDimensionByName(name: String) = 0 \ No newline at end of file