Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation enhancements: Bottom Navigation, screen transitions, back button #670

Merged
merged 4 commits into from
Jun 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Resolve conflicts
nahwneeth committed Jun 15, 2023
commit e6c915716fa68d7e884a1106d2491865e2c90fda
33 changes: 22 additions & 11 deletions app/src/main/java/com/jerboa/nav/CommentNavigation.kt
Original file line number Diff line number Diff line change
@@ -59,29 +59,40 @@ fun NavGraphBuilder.commentScreen(
},
),
) {
val args = CommentArgs(it)

LaunchedEffect(Unit) {
val args = CommentArgs(it)
val commentId = args.id
postViewModel.fetchPost(
id = Either.Right(args.id),
id = Either.Right(commentId),
account = account,
clear = true,
clearPost = true,
clearComments = true,
ctx = ctx,
)
}
PostActivity(
navController = navController,
postViewModel = postViewModel,
accountViewModel = accountViewModel,
commentEditViewModel = commentEditViewModel,
commentReplyViewModel = commentReplyViewModel,
postEditViewModel = postEditViewModel,
appSettingsViewModel = appSettingsViewModel,
showCollapsedCommentContent = appSettings?.showCollapsedCommentContent
?: false,
showActionBarByDefault = appSettings?.showCommentActionBarByDefault
?: true,
showVotingArrowsInListView = appSettings?.showVotingArrowsInListView
?: true,
navController = navController,
showCollapsedCommentContent = appSettings?.showCollapsedCommentContent ?: false,
showActionBarByDefault = appSettings?.showCommentActionBarByDefault ?: true,
showVotingArrowsInListView = appSettings?.showVotingArrowsInListView ?: true,
onClickSortType = { commentSortType ->
val commentId = args.id
postViewModel.fetchPost(
id = Either.Right(commentId),
account = account,
clearPost = false,
clearComments = true,
ctx = ctx,
changeSortType = commentSortType,
)
},
selectedSortType = postViewModel.sortType.value,
siteViewModel = siteViewModel,
)
}
33 changes: 22 additions & 11 deletions app/src/main/java/com/jerboa/nav/PostNavigation.kt
Original file line number Diff line number Diff line change
@@ -59,12 +59,15 @@ fun NavGraphBuilder.postScreen(
},
),
) {
val args = PostArgs(it)

LaunchedEffect(Unit) {
val args = PostArgs(it)
val postId = args.id
postViewModel.fetchPost(
id = Either.Left(args.id),
id = Either.Left(postId),
account = account,
clear = true,
clearPost = true,
clearComments = true,
ctx = ctx,
)
}
@@ -74,15 +77,23 @@ fun NavGraphBuilder.postScreen(
commentEditViewModel = commentEditViewModel,
commentReplyViewModel = commentReplyViewModel,
postEditViewModel = postEditViewModel,
appSettingsViewModel = appSettingsViewModel,
showCollapsedCommentContent = appSettings?.showCollapsedCommentContent
?: false,
showActionBarByDefault = appSettings?.showCommentActionBarByDefault
?: false,
showVotingArrowsInListView = appSettings?.showVotingArrowsInListView
?: true,
navController = navController,
showCollapsedCommentContent = appSettings?.showCollapsedCommentContent ?: false,
showActionBarByDefault = appSettings?.showCommentActionBarByDefault ?: true,
showVotingArrowsInListView = appSettings?.showVotingArrowsInListView ?: true,
onClickSortType = { commentSortType ->
val postId = args.id
postViewModel.fetchPost(
id = Either.Left(postId),
account = account,
clearPost = false,
clearComments = true,
ctx = ctx,
changeSortType = commentSortType,
)
},
selectedSortType = postViewModel.sortType.value,
siteViewModel = siteViewModel,
navController = navController
)
}
}
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ import com.jerboa.ui.components.comment.edit.CommentEditViewModel
import com.jerboa.ui.components.comment.reply.CommentReplyViewModel
import com.jerboa.ui.components.comment.reply.ReplyItem
import com.jerboa.ui.components.common.CommentSortOptionsDialog
import com.jerboa.ui.components.common.DefaultBackButton
import com.jerboa.ui.components.common.getCurrentAccount
import com.jerboa.ui.components.common.simpleVerticalScrollbar
import com.jerboa.ui.components.home.SiteViewModel
@@ -155,14 +156,7 @@ fun PostActivity(
selectedSortType = selectedSortType,
)
},
navigationIcon = {
IconButton(onClick = { navController.popBackStack() }) {
Icon(
Icons.Outlined.ArrowBack,
contentDescription = "Back",
)
}
},
navigationIcon = { DefaultBackButton(navController) },
actions = {
IconButton(onClick = {
showSortOptions = !showSortOptions