mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 01:17:05 +05:30
chore: migrate to data object
This commit is contained in:
parent
8e50cb3e77
commit
53f0656353
4 changed files with 19 additions and 19 deletions
|
@ -45,7 +45,7 @@ fun rememberPostActions(
|
|||
viewModel.markPostAsRead(postId)
|
||||
val currentRoute = navController.currentDestination?.route
|
||||
val newRoute =
|
||||
Destinations.Comments.route.replace(Destinations.Comments.placeholder, postId)
|
||||
Destinations.Comments.route.replace(Destinations.Comments.PLACEHOLDER, postId)
|
||||
if (currentRoute != Destinations.Comments.route) navController.navigate(newRoute)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,34 +9,34 @@ package dev.msfjarvis.claw.android.ui.navigation
|
|||
sealed class Destinations {
|
||||
abstract val route: String
|
||||
|
||||
object Hottest : Destinations() {
|
||||
data object Hottest : Destinations() {
|
||||
override val route = "hottest"
|
||||
}
|
||||
|
||||
object Newest : Destinations() {
|
||||
data object Newest : Destinations() {
|
||||
override val route = "newest"
|
||||
}
|
||||
|
||||
object Saved : Destinations() {
|
||||
data object Saved : Destinations() {
|
||||
override val route = "saved"
|
||||
}
|
||||
|
||||
object Comments : Destinations() {
|
||||
const val placeholder = "{postId}"
|
||||
override val route = "comments/$placeholder"
|
||||
data object Comments : Destinations() {
|
||||
const val PLACEHOLDER = "{postId}"
|
||||
override val route = "comments/$PLACEHOLDER"
|
||||
}
|
||||
|
||||
object User : Destinations() {
|
||||
const val placeholder = "{username}"
|
||||
override val route = "user/$placeholder"
|
||||
data object User : Destinations() {
|
||||
const val PLACEHOLDER = "{username}"
|
||||
override val route = "user/$PLACEHOLDER"
|
||||
}
|
||||
|
||||
object DataTransfer : Destinations() {
|
||||
override val route: String = "datatransfer"
|
||||
data object DataTransfer : Destinations() {
|
||||
override val route = "datatransfer"
|
||||
}
|
||||
|
||||
object Search : Destinations() {
|
||||
override val route: String = "search"
|
||||
data object Search : Destinations() {
|
||||
override val route = "search"
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -120,7 +120,7 @@ fun LobstersPostsScreen(
|
|||
LaunchedEffect(false) {
|
||||
if (postIdOverride != null) {
|
||||
navController.navigate(
|
||||
Destinations.Comments.route.replace(Destinations.Comments.placeholder, postIdOverride)
|
||||
Destinations.Comments.route.replace(Destinations.Comments.PLACEHOLDER, postIdOverride)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -284,8 +284,8 @@ fun LobstersPostsScreen(
|
|||
arguments = listOf(navArgument("postId") { type = NavType.StringType }),
|
||||
deepLinks =
|
||||
listOf(
|
||||
navDeepLink { uriPattern = "$uri/s/${Destinations.Comments.placeholder}/.*" },
|
||||
navDeepLink { uriPattern = "$uri/s/${Destinations.Comments.placeholder}" },
|
||||
navDeepLink { uriPattern = "$uri/s/${Destinations.Comments.PLACEHOLDER}/.*" },
|
||||
navDeepLink { uriPattern = "$uri/s/${Destinations.Comments.PLACEHOLDER}" },
|
||||
),
|
||||
) { backStackEntry ->
|
||||
val postId =
|
||||
|
@ -305,7 +305,7 @@ fun LobstersPostsScreen(
|
|||
route = Destinations.User.route,
|
||||
arguments = listOf(navArgument("username") { type = NavType.StringType }),
|
||||
deepLinks =
|
||||
listOf(navDeepLink { uriPattern = "$uri/u/${Destinations.User.placeholder}" }),
|
||||
listOf(navDeepLink { uriPattern = "$uri/u/${Destinations.User.PLACEHOLDER}" }),
|
||||
) { backStackEntry ->
|
||||
val username =
|
||||
requireNotNull(backStackEntry.arguments?.getString("username")) {
|
||||
|
|
|
@ -11,5 +11,5 @@ internal sealed class NetworkState {
|
|||
|
||||
class Error(val error: Throwable, val description: String) : NetworkState()
|
||||
|
||||
object Loading : NetworkState()
|
||||
data object Loading : NetworkState()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue