mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 08:17:04 +05:30
parent
d079a73e11
commit
2e503422c8
3 changed files with 12 additions and 2 deletions
|
@ -122,7 +122,7 @@ fun LobstersApp(
|
|||
) {
|
||||
NavHost(
|
||||
navController,
|
||||
startDestination = Destinations.Hottest.getRoute(),
|
||||
startDestination = Destinations.startDestination.getRoute(),
|
||||
modifier = Modifier.padding(top = 8.dp),
|
||||
) {
|
||||
composable(Destinations.Hottest.getRoute()) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.graphics.painter.Painter
|
||||
import androidx.navigation.NavController
|
||||
import dev.msfjarvis.claw.android.ui.AnimationDuration
|
||||
import dev.msfjarvis.claw.android.ui.navigation.Destinations
|
||||
|
||||
@Composable
|
||||
fun ClawNavigationBar(
|
||||
|
@ -53,7 +54,11 @@ fun ClawNavigationBar(
|
|||
selected = selectedIndex == index,
|
||||
onClick = {
|
||||
selectedIndex = index
|
||||
navController.navigate(navItem.route)
|
||||
if (navController.currentDestination?.route == navItem.route) return@NavigationBarItem
|
||||
navController.popBackStack(navController.graph.startDestinationRoute!!, false)
|
||||
if (navItem.route != Destinations.startDestination.getRoute()) {
|
||||
navController.navigate(navItem.route)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -12,4 +12,9 @@ sealed class Destinations(internal val route: String) {
|
|||
object Comments : Destinations("comments/%s") {
|
||||
fun getRoute(postId: String) = route.format(postId)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val startDestination
|
||||
get() = Hottest
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue