Skip to content

Commit

Permalink
Fix: Add padding for system bars
Browse files Browse the repository at this point in the history
Added padding for system bars in RecipesList and RecipeDetailsSmall to prevent content from overlapping with system UI elements. Increased the
 minimum candidate height in RecipeDetailsSmall for better layout.
  • Loading branch information
SEAbdulbasit committed Jul 7, 2024
1 parent c9303bc commit 803c0c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion shared/src/commonMain/kotlin/details/RecipeDetailsSmall.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fun RecipeDetailsSmall(
}
}

val candidateHeight = maxOf(toolbarOffsetHeightPx.value, 200f)
val candidateHeight = maxOf(toolbarOffsetHeightPx.value, 300f)
val listState = rememberLazyListState()
val (fraction, setFraction) = remember { mutableStateOf(1f) }

Expand Down Expand Up @@ -231,6 +231,7 @@ fun RecipeDetailsSmall(
painter = painterResource(recipe.image),
contentDescription = null,
modifier = Modifier.aspectRatio(1f).align(Alignment.Center)
.windowInsetsPadding(WindowInsets.systemBars)
.padding(16.dp).rotate(imageRotation.value.toFloat())
.background(
Color.Transparent,
Expand Down
7 changes: 7 additions & 0 deletions shared/src/commonMain/kotlin/recipeslist/RecipesList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.animation.SharedTransitionScope
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyGridState
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
Expand Down Expand Up @@ -41,6 +45,9 @@ fun RecipesListScreen(
LazyVerticalGrid(
state = listState, columns = GridCells.Fixed(if (isLarge) 3 else 1)
) {
item {
Spacer(modifier = Modifier.windowInsetsPadding(WindowInsets.systemBars))
}
items(items.size) { item ->
val recipe = items[item]
RecipeListItemWrapper(
Expand Down

0 comments on commit 803c0c7

Please sign in to comment.