Replace accompanist/insets

Replaces the insets support from accompanist with the in-progress support from Compose itself.
This is a pretty simple change on the usage side, since we only used it in one place.

Change-Id: I05ce768d13fcdeb6471012dde774636526cf35f3
pull/2/head
Alex Vanyo 3 years ago
parent 9f11f6ae8b
commit a36c0da93a

@ -147,7 +147,6 @@ dependencies {
implementation libs.material3
implementation libs.accompanist.flowlayout
implementation libs.accompanist.insets
implementation libs.androidx.compose.foundation.layout
// TODO (M3): Remove this dependency when all components are available

@ -17,8 +17,11 @@
package com.google.samples.apps.nowinandroid.ui
import androidx.annotation.StringRes
import androidx.compose.foundation.layout.captionBarPadding
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AutoStories
import androidx.compose.material.icons.filled.Bookmarks
@ -45,8 +48,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.google.accompanist.insets.ProvideWindowInsets
import com.google.accompanist.insets.systemBarsPadding
import com.google.samples.apps.nowinandroid.R
import com.google.samples.apps.nowinandroid.ui.theme.NiaTheme
@ -54,31 +55,29 @@ import com.google.samples.apps.nowinandroid.ui.theme.NiaTheme
@Composable
fun NiaApp() {
NiaTheme {
ProvideWindowInsets {
val navController = rememberNavController()
val navigationActions = remember(navController) {
NiaNavigationActions(navController)
}
val navController = rememberNavController()
val navigationActions = remember(navController) {
NiaNavigationActions(navController)
}
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute =
navBackStackEntry?.destination?.route ?: NiaDestinations.FOR_YOU_ROUTE
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute =
navBackStackEntry?.destination?.route ?: NiaDestinations.FOR_YOU_ROUTE
Scaffold(
modifier = Modifier,
bottomBar = {
// TODO: Only show on small screens
NiABottomBar(navigationActions, currentRoute)
},
) { padding ->
Surface(Modifier.fillMaxSize()) {
NiaNavGraph(
navController = navController,
modifier = Modifier
.systemBarsPadding(bottom = false)
.padding(padding)
)
}
Scaffold(
modifier = Modifier,
bottomBar = {
// TODO: Only show on small screens
NiABottomBar(navigationActions, currentRoute)
},
) { padding ->
Surface(Modifier.fillMaxSize()) {
NiaNavGraph(
navController = navController,
modifier = Modifier
.statusBarsPadding()
.padding(padding)
)
}
}
}
@ -93,7 +92,7 @@ private fun NiABottomBar(
// navigation is equal to the container color of the navigation bar.
Surface(color = MaterialTheme.colorScheme.surface) {
NavigationBar(
modifier = Modifier.systemBarsPadding(top = false),
modifier = Modifier.navigationBarsPadding().captionBarPadding(),
tonalElevation = 0.dp
) {
TOP_LEVEL_DESTINATIONS.forEach { dst ->

@ -4,7 +4,7 @@ androidDesugarJdkLibs = "1.1.5"
androidGradlePlugin = "7.0.3"
androidxActivity = "1.4.0"
androidxAppCompat = "1.3.0"
androidxCompose = "1.1.0-beta04"
androidxCompose = "1.2.0-SNAPSHOT"
androidxComposeMaterial3 = "1.0.0-alpha03"
androidxCore = "1.7.0"
androidxDataStore = "1.0.0"
@ -17,12 +17,12 @@ androidxTestExt = "1.1.2"
hilt = "2.40.5"
jacoco = "0.8.7"
junit4 = "4.13"
kotlin = "1.6.0"
kotlin = "1.6.10"
kotlinxCoroutines = "1.6.0"
kotlinxCoroutinesTest = "1.6.0"
kotlinxDatetime = "0.3.1"
kotlinxSerializationJson = "1.3.1"
ksp = "1.6.0-1.0.1"
ksp = "1.6.10-1.0.2"
ktlint = "0.43.0"
material3 = "1.5.0-alpha05"
mockk = "1.12.1"
@ -34,7 +34,6 @@ turbine = "0.7.0"
[libraries]
accompanist-flowlayout = { group = "com.google.accompanist", name = "accompanist-flowlayout", version.ref = "accompanist" }
accompanist-insets = { group = "com.google.accompanist", name = "accompanist-insets", version.ref = "accompanist" }
android-desugarJdkLibs = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "androidDesugarJdkLibs" }
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidxActivity" }

@ -24,6 +24,7 @@ dependencyResolutionManagement {
google()
mavenCentral()
gradlePluginPortal()
maven { url "https://androidx.dev/snapshots/builds/8143371/artifacts/repository" }
}
}
rootProject.name = "nowinandroid"

Loading…
Cancel
Save