Skip to content

Commit 200f690

Browse files
committed
Fix content padding issue
1 parent e83dfb6 commit 200f690

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

app/src/main/java/com/example/superheroes/HeroesScreen.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import androidx.compose.animation.slideInVertically
2929
import androidx.compose.foundation.Image
3030
import androidx.compose.foundation.layout.Box
3131
import androidx.compose.foundation.layout.Column
32+
import androidx.compose.foundation.layout.PaddingValues
3233
import androidx.compose.foundation.layout.Row
3334
import androidx.compose.foundation.layout.Spacer
3435
import androidx.compose.foundation.layout.fillMaxWidth
@@ -63,7 +64,8 @@ import com.example.superheroes.ui.theme.SuperheroesTheme
6364
fun HeroesList(
6465
heroes: List<Hero>,
6566
modifier: Modifier = Modifier,
66-
) {
67+
contentPadding: PaddingValues = PaddingValues(0.dp),
68+
) {
6769
val visibleState = remember {
6870
MutableTransitionState(false).apply {
6971
// Start the animation immediately.
@@ -80,7 +82,7 @@ fun HeroesList(
8082
exit = fadeOut(),
8183
modifier = modifier
8284
) {
83-
LazyColumn {
85+
LazyColumn(contentPadding = contentPadding) {
8486
itemsIndexed(heroes) { index, hero ->
8587
HeroListItem(
8688
hero = hero,

app/src/main/java/com/example/superheroes/MainActivity.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ class MainActivity : ComponentActivity() {
6666
data source as a dependency and exposes heroes.
6767
*/
6868
val heroes = HeroesRepository.heroes
69-
HeroesList(heroes = heroes, Modifier.padding(it))
70-
69+
HeroesList(heroes = heroes, contentPadding = it)
7170
}
7271
}
7372

app/src/main/java/com/example/superheroes/ui/theme/Theme.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,17 @@ private fun setUpEdgeToEdge(view: View, darkTheme: Boolean) {
137137
val window = (view.context as Activity).window
138138
WindowCompat.setDecorFitsSystemWindows(window, false)
139139
window.statusBarColor = Color.Transparent.toArgb()
140-
val navigationBarColor = if (Build.VERSION.SDK_INT >= 26) {
141-
Color.Transparent.toArgb()
142-
}
143-
else {
144-
// Min sdk version for this app is 24, this block is for SDK versions 24 and 25
145-
Color(0x63000000).toArgb()
140+
val navigationBarColor = when {
141+
Build.VERSION.SDK_INT >= 29 -> {
142+
Color.Transparent.toArgb()
143+
}
144+
Build.VERSION.SDK_INT >= 26 -> {
145+
Color(0x00, 0x00, 0x00, 0x63).toArgb()
146+
}
147+
else -> {
148+
// Min sdk version for this app is 24, this block is for SDK versions 24 and 25
149+
Color(0x50000000).toArgb()
150+
}
146151
}
147152
window.navigationBarColor = navigationBarColor
148153
val controller = WindowCompat.getInsetsController(window, view)

0 commit comments

Comments
 (0)