From b1e8f25c6c60052b66fbd34938044899553025ba Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Sun, 30 Jun 2024 15:29:00 +0200 Subject: [PATCH] Enable edge to edge --- appcompose/src/main/AndroidManifest.xml | 3 ++- .../com/readrops/app/compose/MainActivity.kt | 19 +++++++++++++++++++ .../readrops/app/compose/home/HomeScreen.kt | 9 ++++++++- .../readrops/app/compose/item/ItemScreen.kt | 2 ++ gradle/libs.versions.toml | 2 +- 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/appcompose/src/main/AndroidManifest.xml b/appcompose/src/main/AndroidManifest.xml index eda1d5cd..fcd27393 100644 --- a/appcompose/src/main/AndroidManifest.xml +++ b/appcompose/src/main/AndroidManifest.xml @@ -25,7 +25,8 @@ + android:exported="true" + android:windowSoftInputMode="adjustResize"> diff --git a/appcompose/src/main/java/com/readrops/app/compose/MainActivity.kt b/appcompose/src/main/java/com/readrops/app/compose/MainActivity.kt index 38bac770..72cb52f2 100644 --- a/appcompose/src/main/java/com/readrops/app/compose/MainActivity.kt +++ b/appcompose/src/main/java/com/readrops/app/compose/MainActivity.kt @@ -1,8 +1,15 @@ package com.readrops.app.compose +import android.graphics.Color import android.os.Bundle import androidx.activity.ComponentActivity +import androidx.activity.SystemBarStyle import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.NavigationBarDefaults +import androidx.compose.material3.surfaceColorAtElevation +import androidx.compose.ui.graphics.toArgb import cafe.adriel.voyager.navigator.CurrentScreen import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.navigator.NavigatorDisposeBehavior @@ -27,6 +34,18 @@ class MainActivity : ComponentActivity(), KoinComponent { setContent { KoinAndroidContext { ReadropsTheme { + val navigationBarElevation = NavigationBarDefaults.Elevation + + enableEdgeToEdge( + statusBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT), + navigationBarStyle = SystemBarStyle.light( + MaterialTheme.colorScheme.surfaceColorAtElevation(navigationBarElevation) + .toArgb(), + MaterialTheme.colorScheme.surfaceColorAtElevation(navigationBarElevation) + .toArgb() + ) + ) + Navigator( screen = if (accountExists) HomeScreen() else AccountSelectionScreen(), disposeBehavior = NavigatorDisposeBehavior( diff --git a/appcompose/src/main/java/com/readrops/app/compose/home/HomeScreen.kt b/appcompose/src/main/java/com/readrops/app/compose/home/HomeScreen.kt index 7a5322f3..f23aefd2 100644 --- a/appcompose/src/main/java/com/readrops/app/compose/home/HomeScreen.kt +++ b/appcompose/src/main/java/com/readrops/app/compose/home/HomeScreen.kt @@ -1,7 +1,10 @@ package com.readrops.app.compose.home +import android.annotation.SuppressLint import androidx.activity.compose.BackHandler import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.consumeWindowInsets +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.AccountCircle @@ -29,6 +32,7 @@ import com.readrops.app.compose.util.components.AndroidScreen class HomeScreen : AndroidScreen() { + @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") @Composable override fun Content() { val navigator = LocalNavigator.currentOrThrow @@ -91,7 +95,10 @@ class HomeScreen : AndroidScreen() { }, ) { paddingValues -> Box( - modifier = Modifier.padding(paddingValues) + modifier = Modifier + .fillMaxSize() + .padding(paddingValues) + .consumeWindowInsets(paddingValues) ) { CurrentTab() } diff --git a/appcompose/src/main/java/com/readrops/app/compose/item/ItemScreen.kt b/appcompose/src/main/java/com/readrops/app/compose/item/ItemScreen.kt index 965d1e52..899e47db 100644 --- a/appcompose/src/main/java/com/readrops/app/compose/item/ItemScreen.kt +++ b/appcompose/src/main/java/com/readrops/app/compose/item/ItemScreen.kt @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.IntrinsicSize import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size @@ -144,6 +145,7 @@ class ItemScreen( state = state.bottomBarState, accentColor = accentColor, modifier = Modifier + .navigationBarsPadding() .height(bottomBarHeight) .offset { if (isScrollable) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a358ade3..ac495b8e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,7 +19,7 @@ compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } # specify material3 version is required for gradle to find the dependency compose-material3 = { module = "androidx.compose.material3:material3", version = "1.2.1" } -compose-activity = "androidx.activity:activity-compose:1.8.2" +compose-activity = "androidx.activity:activity-compose:1.9.0" voyager-navigator = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyager" } voyager-screenmodel = { module = "cafe.adriel.voyager:voyager-screenmodel", version.ref = "voyager" }