更新代码
This commit is contained in:
@@ -61,7 +61,7 @@ sealed class NavigationRoute(
|
||||
data object LocationDetail : NavigationRoute("LocationDetail/{x}/{y}")
|
||||
data object OfficialPhoto : NavigationRoute("OfficialPhoto")
|
||||
data object OfficialPhotographer : NavigationRoute("OfficialPhotographer")
|
||||
data object Post : NavigationRoute("Post/{id}/{highlightCommentId}")
|
||||
data object Post : NavigationRoute("Post/{id}/{highlightCommentId}/{initImagePagerIndex}")
|
||||
data object ModificationList : NavigationRoute("ModificationList")
|
||||
data object MyMessage : NavigationRoute("MyMessage")
|
||||
data object Comments : NavigationRoute("Comments")
|
||||
@@ -137,19 +137,23 @@ fun NavigationController(
|
||||
route = NavigationRoute.Post.route,
|
||||
arguments = listOf(
|
||||
navArgument("id") { type = NavType.StringType },
|
||||
navArgument("highlightCommentId") { type = NavType.IntType }
|
||||
navArgument("highlightCommentId") { type = NavType.IntType },
|
||||
navArgument("initImagePagerIndex") { type = NavType.IntType }
|
||||
),
|
||||
) { backStackEntry ->
|
||||
CompositionLocalProvider(
|
||||
LocalAnimatedContentScope provides this,
|
||||
) {
|
||||
val id = backStackEntry.arguments?.getString("id")
|
||||
val highlightCommentId = backStackEntry.arguments?.getInt("highlightCommentId")?.let {
|
||||
if (it == 0) null else it
|
||||
}
|
||||
val highlightCommentId =
|
||||
backStackEntry.arguments?.getInt("highlightCommentId")?.let {
|
||||
if (it == 0) null else it
|
||||
}
|
||||
val initIndex = backStackEntry.arguments?.getInt("initImagePagerIndex")
|
||||
PostScreen(
|
||||
id!!,
|
||||
highlightCommentId
|
||||
highlightCommentId,
|
||||
initImagePagerIndex = initIndex
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -364,4 +368,17 @@ fun Navigation(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun NavHostController.navigateToPost(
|
||||
id: Int,
|
||||
highlightCommentId: Int? = 0,
|
||||
initImagePagerIndex: Int? = null
|
||||
) {
|
||||
navigate(
|
||||
route = NavigationRoute.Post.route
|
||||
.replace("{id}", id.toString())
|
||||
.replace("{highlightCommentId}", highlightCommentId.toString())
|
||||
.replace("{initImagePagerIndex}", initImagePagerIndex.toString())
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user