Skip to content

Commit

Permalink
Added window insets to the the main screen
Browse files Browse the repository at this point in the history
Since the headder and the body (FlowRow) are sibling elements, we have
to explicitly exclude the top inset, which we get by combining the
bottom and the sides (horizontal). Tested with all the developer options
notch settings and with both gesture nav and 3 button nav.

I did not override the navigationBarStyle since the default actually
seems to work well. With three button nav, it has a partially
transparent light background that helps the buttons stand out when
content is behind them. With gesture nav, the bar stands out enough on
its own.

This fixes #1450.
  • Loading branch information
IanGClifton committed Aug 28, 2024
1 parent 2b26f39 commit 1b0c849
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowColumn
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
Expand Down Expand Up @@ -67,9 +72,13 @@ fun JetLaggedScreen(

val uiState =
viewModel.uiState.collectAsStateWithLifecycle()

val insets = WindowInsets.safeDrawing.only(
WindowInsetsSides.Bottom + WindowInsetsSides.Horizontal
)
FlowRow(
modifier = Modifier.fillMaxSize(),
modifier = Modifier
.fillMaxSize()
.windowInsetsPadding(insets),
horizontalArrangement = Arrangement.Center,
verticalArrangement = Arrangement.Center,
maxItemsInEachRow = 3
Expand Down

0 comments on commit 1b0c849

Please sign in to comment.