Skip to content

Commit

Permalink
Better navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanfallet committed Jan 19, 2024
1 parent 38f8d5d commit 3505cc0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ fun PostView(
}
},
onRepostClicked = { post ->
navigate.invoke("timeline/compose?repostOfId=${post.id}")
navigate.invoke("timelines/compose?repostOfId=${post.id}")
},
onReplyClicked = { post ->
navigate.invoke("timeline/compose?repliedToId=${post.id}")
navigate.invoke("timelines/compose?repliedToId=${post.id}")
}
)
}
Expand All @@ -85,10 +85,10 @@ fun PostView(
}
},
onRepostClicked = { post ->
navigate.invoke("timeline/compose?repostOfId=${post.id}")
navigate.invoke("timelines/compose?repostOfId=${post.id}")
},
onReplyClicked = { post ->
navigate.invoke("timeline/compose?repliedToId=${post.id}")
navigate.invoke("timelines/compose?repliedToId=${post.id}")
}
)
viewModel.loadMoreIfNeeded(it.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ fun TabNavigation(
) {
NavHost(
navController = navController,
startDestination = "timeline"
startDestination = "timelines"
) {
composable("timeline") {
composable("timelines") {
TimelineView(
id = "default",
viewedBy = viewedBy,
Expand All @@ -117,7 +117,7 @@ fun TabNavigation(
)
}
composable(
"timeline/compose?repliedToId={repliedToId}&repostOfId={repostOfId}",
"timelines/compose?repliedToId={repliedToId}&repostOfId={repostOfId}",
arguments = listOf(
navArgument("repliedToId") {
type = NavType.StringType
Expand All @@ -136,17 +136,17 @@ fun TabNavigation(
repostOfId = backStackEntry.arguments?.getString("repostOfId")
)
}
composable("timeline/user/{id}") { backStackEntry ->
composable("timelines/users/{userId}") { backStackEntry ->
ProfileView(
id = backStackEntry.arguments?.getString("id")!!,
id = backStackEntry.arguments?.getString("userId")!!,
viewedBy = viewedBy,
navigate = navController::navigate,
modifier = Modifier.padding(padding)
)
}
composable("timeline/post/{id}") { backStackEntry ->
composable("timelines/posts/{postId}") { backStackEntry ->
PostView(
id = backStackEntry.arguments?.getString("id")!!,
id = backStackEntry.arguments?.getString("postId")!!,
viewedBy = viewedBy,
navigate = navController::navigate,
modifier = Modifier.padding(padding)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fun TimelineView(
}
} else {
IconButton(
onClick = { navigate("timeline/compose") }
onClick = { navigate("timelines/compose") }
) {
Icon(
painter = painterResource(id = R.drawable.ic_baseline_create_24),
Expand Down Expand Up @@ -124,13 +124,13 @@ fun TimelineView(
viewedBy = viewedBy,
navigate = navigate,
onPostsClicked = { user ->
navigate.invoke("timeline/user/${user.id}/posts")
navigate.invoke("timelines/users/${user.id}/posts")
},
onFollowersClicked = { user ->
navigate.invoke("timeline/user/${user.id}/followers")
navigate.invoke("timelines/users/${user.id}/followers")
},
onFollowingClicked = { user ->
navigate.invoke("timeline/user/${user.id}/following")
navigate.invoke("timelines/users/${user.id}/following")
},
onEditClicked = {

Expand Down Expand Up @@ -158,10 +158,10 @@ fun TimelineView(
}
},
onRepostClicked = { post ->
navigate.invoke("timeline/compose?repostOfId=${post.id}")
navigate.invoke("timelines/compose?repostOfId=${post.id}")
},
onReplyClicked = { post ->
navigate.invoke("timeline/compose?repliedToId=${post.id}")
navigate.invoke("timelines/compose?repliedToId=${post.id}")
}
)
viewModel.loadMoreIfNeeded(it.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ fun ProfileView(
navigate = navigate,
onPostsClicked = {},
onFollowersClicked = { user ->
navigate.invoke("timeline/user/${user.id}/followers")
navigate.invoke("timelines/users/${user.id}/followers")
},
onFollowingClicked = { user ->
navigate.invoke("timeline/user/${user.id}/following")
navigate.invoke("timelines/users/${user.id}/following")
},
onEditClicked = {

Expand Down Expand Up @@ -97,10 +97,10 @@ fun ProfileView(
}
},
onRepostClicked = { post ->
navigate.invoke("timeline/compose?repostOfId=${post.id}")
navigate.invoke("timelines/compose?repostOfId=${post.id}")
},
onReplyClicked = { post ->
navigate.invoke("timeline/compose?repliedToId=${post.id}")
navigate.invoke("timelines/compose?repliedToId=${post.id}")
}
)
viewModel.loadMoreIfNeeded(it.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ fun PostCard(
Column(
verticalArrangement = Arrangement.spacedBy(12.dp),
modifier = Modifier.padding(16.dp).clickable {
navigate("timeline/post/${post.id}")
navigate("timelines/posts/${post.id}")
}
) {
Row {
post.user?.let { user ->
UserHeaderView(
user = user,
modifier = Modifier.clickable {
navigate("timeline/user/${user.id}")
navigate("timelines/users/${user.id}")
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun UserCard(
UserHeaderView(
user = user,
modifier = Modifier.clickable {
navigate("timeline/user/${user.id}")
navigate("timelines/users/${user.id}")
}
)
Spacer(modifier = Modifier.weight(1f))
Expand Down

0 comments on commit 3505cc0

Please sign in to comment.