Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix map UI insets #85

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/src/main/java/ru/spbu/depnav/ui/component/MapSearchBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import androidx.compose.foundation.layout.calculateEndPadding
import androidx.compose.foundation.layout.calculateStartPadding
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.ArrowBack
Expand Down Expand Up @@ -95,7 +95,7 @@ fun MapSearchBar(
label = "Map search bar activation animation progress"
)

val (insetsStartPadding, insetsEndPadding) = with(WindowInsets.systemBars.asPaddingValues()) {
val (insetsStartPadding, insetsEndPadding) = with(WindowInsets.safeDrawing.asPaddingValues()) {
val layoutDirection = LocalLayoutDirection.current
calculateStartPadding(layoutDirection) to calculateEndPadding(layoutDirection)
}
Expand All @@ -116,7 +116,7 @@ fun MapSearchBar(
modifier = Modifier
.run {
if (active) padding(start = outerStartPadding, end = outerEndPadding)
else windowInsetsPadding(WindowInsets.systemBars.only(WindowInsetsSides.Horizontal))
else windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal))
}
.then(modifier),
placeholder = {
Expand Down Expand Up @@ -157,7 +157,7 @@ fun MapSearchBar(
.padding(
start = innerStartPadding,
end = innerEndPadding,
bottom = WindowInsets.systemBars
bottom = WindowInsets.safeDrawing
.asPaddingValues()
.calculateBottomPadding()
)
Expand Down
14 changes: 8 additions & 6 deletions app/src/main/java/ru/spbu/depnav/ui/screen/MapScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import androidx.compose.foundation.layout.exclude
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.shape.CornerSize
Expand Down Expand Up @@ -268,7 +268,7 @@ private fun BoxScope.AnimatedFloorSwitch(
visible = visible,
modifier = Modifier
.align(Alignment.TopEnd)
.safeContentPadding()
.safeDrawingPadding()
.padding(top = 64.dp) // Estimated search bar height
.padding(DEFAULT_PADDING),
enter = slideInHorizontally(initialOffsetX = horizontalOffset) + fadeIn(),
Expand All @@ -293,7 +293,7 @@ private fun BoxScope.AnimatedBottom(pinnedMarker: MarkerWithText?, showZoomInHin
) {
Surface(
modifier = Modifier
.windowInsetsPadding(WindowInsets.systemBars.only(WindowInsetsSides.Horizontal))
.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal))
.width(640.dp),
shape = MaterialTheme.shapes.large.copy(
bottomStart = CornerSize(0),
Expand All @@ -320,7 +320,9 @@ private fun BoxScope.AnimatedBottom(pinnedMarker: MarkerWithText?, showZoomInHin
description = markerText.description,
modifier = Modifier
.padding(DEFAULT_PADDING)
.windowInsetsPadding(WindowInsets.systemBars.only(WindowInsetsSides.Bottom))
.windowInsetsPadding(
WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)
)
) {
MarkerView(
title = markerText.title ?: stringResource(R.string.no_title),
Expand All @@ -337,7 +339,7 @@ private fun BoxScope.AnimatedBottom(pinnedMarker: MarkerWithText?, showZoomInHin
modifier = Modifier
.align(Alignment.BottomCenter)
.windowInsetsPadding(
WindowInsets.systemBars.run { exclude(only(WindowInsetsSides.Top)) }
WindowInsets.safeDrawing.run { exclude(only(WindowInsetsSides.Top)) }
),
enter = fadeIn(),
exit = fadeOut()
Expand Down
Loading