diff --git a/app/src/main/java/com/example/woof/MainActivity.kt b/app/src/main/java/com/example/woof/MainActivity.kt index 522dab9..17dc74e 100644 --- a/app/src/main/java/com/example/woof/MainActivity.kt +++ b/app/src/main/java/com/example/woof/MainActivity.kt @@ -29,6 +29,8 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -60,11 +62,18 @@ class MainActivity : ComponentActivity() { /** * Composable that displays an app bar and a list of dogs. */ +@OptIn(ExperimentalMaterial3Api::class) @Composable fun WoofApp() { - LazyColumn { - items(dogs) { - DogItem(dog = it) + + Scaffold { it -> + LazyColumn(contentPadding = it) { + items(dogs) { + DogItem( + dog = it, + modifier = Modifier.padding(dimensionResource(R.dimen.padding_small)) + ) + } } } } diff --git a/app/src/main/java/com/example/woof/ui/theme/Theme.kt b/app/src/main/java/com/example/woof/ui/theme/Theme.kt index d14dc94..a3a9f53 100644 --- a/app/src/main/java/com/example/woof/ui/theme/Theme.kt +++ b/app/src/main/java/com/example/woof/ui/theme/Theme.kt @@ -17,6 +17,7 @@ package com.example.woof.ui.theme import android.app.Activity import android.os.Build +import android.view.View import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme @@ -25,6 +26,7 @@ import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView @@ -61,9 +63,7 @@ fun WoofTheme( val view = LocalView.current if (!view.isInEditMode) { SideEffect { - val window = (view.context as Activity).window - window.statusBarColor = colorScheme.primary.toArgb() - WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme + setUpEdgeToEdge(view, darkTheme) } } @@ -73,4 +73,24 @@ fun WoofTheme( shapes = Shapes, content = content ) -} \ No newline at end of file +} + +/** + * Sets up edge-to-edge for the window of this [view]. The system icon colors are set to either + * light or dark depending on whether the [darkTheme] is enabled or not. + */ +private fun setUpEdgeToEdge(view: View, darkTheme: Boolean) { + val window = (view.context as Activity).window + WindowCompat.setDecorFitsSystemWindows(window, false) + window.statusBarColor = Color.Transparent.toArgb() + val navigationBarColor = when { + Build.VERSION.SDK_INT >= 29 -> Color.Transparent.toArgb() + Build.VERSION.SDK_INT >= 26 -> Color(0xFF, 0xFF, 0xFF, 0x63).toArgb() + // Min sdk version for this app is 24, this block is for SDK versions 24 and 25 + else -> Color(0x00,0x00, 0x00, 0x50).toArgb() + } + window.navigationBarColor = navigationBarColor + val controller = WindowCompat.getInsetsController(window, view) + controller.isAppearanceLightStatusBars = !darkTheme + controller.isAppearanceLightNavigationBars = !darkTheme +} diff --git a/build.gradle b/build.gradle index 6fd7164..7235ef1 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ */ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '8.0.0-beta05' apply false - id 'com.android.library' version '8.0.0-beta05' apply false + id 'com.android.application' version '8.1.0-rc01' apply false + id 'com.android.library' version '8.1.0-rc01' apply false id 'org.jetbrains.kotlin.android' version '1.8.10' apply false } \ No newline at end of file