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