mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 09:57:04 +05:30
parent
d079a73e11
commit
2e503422c8
3 changed files with 12 additions and 2 deletions
|
@ -122,7 +122,7 @@ fun LobstersApp(
|
||||||
) {
|
) {
|
||||||
NavHost(
|
NavHost(
|
||||||
navController,
|
navController,
|
||||||
startDestination = Destinations.Hottest.getRoute(),
|
startDestination = Destinations.startDestination.getRoute(),
|
||||||
modifier = Modifier.padding(top = 8.dp),
|
modifier = Modifier.padding(top = 8.dp),
|
||||||
) {
|
) {
|
||||||
composable(Destinations.Hottest.getRoute()) {
|
composable(Destinations.Hottest.getRoute()) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.painter.Painter
|
import androidx.compose.ui.graphics.painter.Painter
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import dev.msfjarvis.claw.android.ui.AnimationDuration
|
import dev.msfjarvis.claw.android.ui.AnimationDuration
|
||||||
|
import dev.msfjarvis.claw.android.ui.navigation.Destinations
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ClawNavigationBar(
|
fun ClawNavigationBar(
|
||||||
|
@ -53,7 +54,11 @@ fun ClawNavigationBar(
|
||||||
selected = selectedIndex == index,
|
selected = selectedIndex == index,
|
||||||
onClick = {
|
onClick = {
|
||||||
selectedIndex = index
|
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") {
|
object Comments : Destinations("comments/%s") {
|
||||||
fun getRoute(postId: String) = route.format(postId)
|
fun getRoute(postId: String) = route.format(postId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val startDestination
|
||||||
|
get() = Hottest
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue