mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 07:37:03 +05:30
Revert "android: inline routes"
This makes the handling in `PostActions#viewComments` slightly weird and isn't
worth it until that abstraction is removed.
This reverts commit de28ae2d95
.
This commit is contained in:
parent
c556f26d77
commit
5b0d953210
4 changed files with 18 additions and 12 deletions
|
@ -84,12 +84,12 @@ fun LobstersApp(
|
||||||
listOf(
|
listOf(
|
||||||
NavigationItem(
|
NavigationItem(
|
||||||
label = "Hottest",
|
label = "Hottest",
|
||||||
route = Destinations.Hottest.route,
|
route = Destinations.Hottest.getRoute(),
|
||||||
icon = painterResource(R.drawable.ic_whatshot_24dp),
|
icon = painterResource(R.drawable.ic_whatshot_24dp),
|
||||||
) { coroutineScope.launch { networkListState.animateScrollToItem(index = 0) } },
|
) { coroutineScope.launch { networkListState.animateScrollToItem(index = 0) } },
|
||||||
NavigationItem(
|
NavigationItem(
|
||||||
label = "Saved",
|
label = "Saved",
|
||||||
route = Destinations.Saved.route,
|
route = Destinations.Saved.getRoute(),
|
||||||
icon = painterResource(commonR.drawable.ic_favorite_24dp),
|
icon = painterResource(commonR.drawable.ic_favorite_24dp),
|
||||||
) { coroutineScope.launch { savedListState.animateScrollToItem(index = 0) } },
|
) { coroutineScope.launch { savedListState.animateScrollToItem(index = 0) } },
|
||||||
)
|
)
|
||||||
|
@ -139,11 +139,11 @@ fun LobstersApp(
|
||||||
) { paddingValues ->
|
) { paddingValues ->
|
||||||
NavHost(
|
NavHost(
|
||||||
navController,
|
navController,
|
||||||
startDestination = Destinations.startDestination.route,
|
startDestination = Destinations.startDestination.getRoute(),
|
||||||
) {
|
) {
|
||||||
val uri = LobstersApi.BASE_URL
|
val uri = LobstersApi.BASE_URL
|
||||||
composable(
|
composable(
|
||||||
route = Destinations.Hottest.route,
|
route = Destinations.Hottest.getRoute(),
|
||||||
deepLinks =
|
deepLinks =
|
||||||
listOf(navDeepLink { uriPattern = uri }, navDeepLink { uriPattern = "$uri/" }),
|
listOf(navDeepLink { uriPattern = uri }, navDeepLink { uriPattern = "$uri/" }),
|
||||||
) {
|
) {
|
||||||
|
@ -157,7 +157,7 @@ fun LobstersApp(
|
||||||
modifier = Modifier.padding(bottom = paddingValues.calculateBottomPadding()),
|
modifier = Modifier.padding(bottom = paddingValues.calculateBottomPadding()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
composable(Destinations.Saved.route) {
|
composable(Destinations.Saved.getRoute()) {
|
||||||
setWebUri(null)
|
setWebUri(null)
|
||||||
DatabasePosts(
|
DatabasePosts(
|
||||||
items = savedPosts,
|
items = savedPosts,
|
||||||
|
@ -168,7 +168,7 @@ fun LobstersApp(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
composable(
|
composable(
|
||||||
route = Destinations.Comments.route,
|
route = Destinations.Comments.getRoute("{postId}"),
|
||||||
arguments = listOf(navArgument("postId") { type = NavType.StringType }),
|
arguments = listOf(navArgument("postId") { type = NavType.StringType }),
|
||||||
deepLinks =
|
deepLinks =
|
||||||
listOf(
|
listOf(
|
||||||
|
|
|
@ -38,7 +38,7 @@ fun ClawNavigationBar(
|
||||||
return@NavigationBarItem
|
return@NavigationBarItem
|
||||||
}
|
}
|
||||||
navController.popBackStack(navController.graph.startDestinationRoute!!, false)
|
navController.popBackStack(navController.graph.startDestinationRoute!!, false)
|
||||||
if (navItem.route != Destinations.startDestination.route) {
|
if (navItem.route != Destinations.startDestination.getRoute()) {
|
||||||
navController.navigate(navItem.route)
|
navController.navigate(navItem.route)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ fun rememberPostActions(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun viewComments(postId: String) {
|
override fun viewComments(postId: String) {
|
||||||
navController.navigate(Destinations.Comments.route)
|
navController.navigate(Destinations.Comments.getRoute(postId))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun viewCommentsPage(commentsUrl: String) {
|
override fun viewCommentsPage(commentsUrl: String) {
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
package dev.msfjarvis.claw.android.ui.navigation
|
package dev.msfjarvis.claw.android.ui.navigation
|
||||||
|
|
||||||
sealed class Destinations(val route: String) {
|
sealed class Destinations(internal val route: String) {
|
||||||
object Hottest : Destinations("hottest")
|
object Hottest : Destinations("hottest") {
|
||||||
|
fun getRoute() = route
|
||||||
|
}
|
||||||
|
|
||||||
object Saved : Destinations("saved")
|
object Saved : Destinations("saved") {
|
||||||
|
fun getRoute() = route
|
||||||
|
}
|
||||||
|
|
||||||
object Comments : Destinations("comments/{postId}")
|
object Comments : Destinations("comments/%s") {
|
||||||
|
fun getRoute(postId: String) = route.format(postId)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val startDestination
|
val startDestination
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue