mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 17:37:05 +05:30
android: add comments destination
This commit is contained in:
parent
e85e25aa50
commit
7f54e6ff1b
3 changed files with 12 additions and 1 deletions
|
@ -24,6 +24,7 @@ fun HottestPosts(
|
|||
toggleSave: suspend (SavedPost) -> Unit,
|
||||
reloadPosts: () -> Unit,
|
||||
launchUrl: (String) -> Unit,
|
||||
viewComments: (String) -> Unit,
|
||||
modifier: Modifier,
|
||||
) {
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
@ -40,6 +41,7 @@ fun HottestPosts(
|
|||
launchUrl = launchUrl,
|
||||
listState = listState,
|
||||
isSaved = isPostSaved,
|
||||
viewComments = viewComments,
|
||||
toggleSave = { coroutineScope.launch { toggleSave(it) } },
|
||||
modifier = Modifier.padding(top = 16.dp).then(modifier),
|
||||
)
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.google.accompanist.insets.ProvideWindowInsets
|
|||
import com.google.accompanist.insets.navigationBarsPadding
|
||||
import com.google.accompanist.insets.statusBarsPadding
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
import dev.msfjarvis.claw.android.comments.CommentsPage
|
||||
import dev.msfjarvis.claw.android.viewmodel.ClawViewModel
|
||||
import dev.msfjarvis.claw.common.theme.LobstersTheme
|
||||
import dev.msfjarvis.claw.common.urllauncher.UrlLauncher
|
||||
|
@ -92,9 +93,16 @@ fun LobstersApp(
|
|||
viewModel::toggleSave,
|
||||
viewModel::reloadPosts,
|
||||
urlLauncher::launch,
|
||||
{ navController.navigate("comments/$it") },
|
||||
Modifier.nestedScroll(nestedScrollConnection),
|
||||
)
|
||||
}
|
||||
composable("comments/{postId}") { backStackEntry ->
|
||||
CommentsPage(
|
||||
postId = requireNotNull(backStackEntry.arguments?.getString("postId")),
|
||||
getDetails = viewModel::getPostComments,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ fun NetworkPosts(
|
|||
launchUrl: (String) -> Unit,
|
||||
isSaved: suspend (SavedPost) -> Boolean,
|
||||
toggleSave: (SavedPost) -> Unit,
|
||||
viewComments: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
@ -42,7 +43,7 @@ fun NetworkPosts(
|
|||
post = dbModel,
|
||||
isSaved = saved,
|
||||
viewPost = { launchUrl(item.url.ifEmpty { item.commentsUrl }) },
|
||||
viewComments = { launchUrl(item.commentsUrl) },
|
||||
viewComments = { viewComments(item.shortId) },
|
||||
toggleSave = { toggleSave(dbModel) },
|
||||
modifier = Modifier.padding(bottom = 16.dp, start = 16.dp, end = 16.dp),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue