|
|
@ -27,7 +27,6 @@ import androidx.compose.foundation.layout.padding
|
|
|
|
import androidx.compose.foundation.layout.safeDrawing
|
|
|
|
import androidx.compose.foundation.layout.safeDrawing
|
|
|
|
import androidx.compose.foundation.layout.safeDrawingPadding
|
|
|
|
import androidx.compose.foundation.layout.safeDrawingPadding
|
|
|
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
|
|
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
|
|
|
import androidx.compose.material.ripple.LocalRippleTheme
|
|
|
|
|
|
|
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
@ -41,7 +40,6 @@ import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.material3.windowsizeclass.WindowSizeClass
|
|
|
|
import androidx.compose.material3.windowsizeclass.WindowSizeClass
|
|
|
|
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
|
|
|
|
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
|
|
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
import androidx.compose.runtime.remember
|
|
|
|
import androidx.compose.runtime.remember
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
@ -52,7 +50,6 @@ import androidx.navigation.NavDestination
|
|
|
|
import androidx.navigation.NavDestination.Companion.hierarchy
|
|
|
|
import androidx.navigation.NavDestination.Companion.hierarchy
|
|
|
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
|
|
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
|
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.ClearRippleTheme
|
|
|
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.component.NiaBackground
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.component.NiaBackground
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.theme.NiaTheme
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.theme.NiaTheme
|
|
|
|
import com.google.samples.apps.nowinandroid.navigation.NiaNavHost
|
|
|
|
import com.google.samples.apps.nowinandroid.navigation.NiaNavHost
|
|
|
@ -149,35 +146,33 @@ private fun NiABottomBar(
|
|
|
|
// Wrap the navigation bar in a surface so the color behind the system
|
|
|
|
// Wrap the navigation bar in a surface so the color behind the system
|
|
|
|
// 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) {
|
|
|
|
CompositionLocalProvider(LocalRippleTheme provides ClearRippleTheme) {
|
|
|
|
NavigationBar(
|
|
|
|
NavigationBar(
|
|
|
|
modifier = Modifier.windowInsetsPadding(
|
|
|
|
modifier = Modifier.windowInsetsPadding(
|
|
|
|
WindowInsets.safeDrawing.only(
|
|
|
|
WindowInsets.safeDrawing.only(
|
|
|
|
WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom
|
|
|
|
WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
tonalElevation = 0.dp
|
|
|
|
tonalElevation = 0.dp
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TOP_LEVEL_DESTINATIONS.forEach { destination ->
|
|
|
|
TOP_LEVEL_DESTINATIONS.forEach { destination ->
|
|
|
|
val selected =
|
|
|
|
val selected =
|
|
|
|
currentDestination?.hierarchy?.any { it.route == destination.route } == true
|
|
|
|
currentDestination?.hierarchy?.any { it.route == destination.route } == true
|
|
|
|
NavigationBarItem(
|
|
|
|
NavigationBarItem(
|
|
|
|
selected = selected,
|
|
|
|
selected = selected,
|
|
|
|
onClick = { onNavigateToTopLevelDestination(destination) },
|
|
|
|
onClick = { onNavigateToTopLevelDestination(destination) },
|
|
|
|
icon = {
|
|
|
|
icon = {
|
|
|
|
Icon(
|
|
|
|
Icon(
|
|
|
|
if (selected) {
|
|
|
|
if (selected) {
|
|
|
|
destination.selectedIcon
|
|
|
|
destination.selectedIcon
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
destination.unselectedIcon
|
|
|
|
destination.unselectedIcon
|
|
|
|
},
|
|
|
|
},
|
|
|
|
contentDescription = null
|
|
|
|
contentDescription = null
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
label = { Text(stringResource(destination.iconTextId)) }
|
|
|
|
label = { Text(stringResource(destination.iconTextId)) }
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|