mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 19:57:04 +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,
|
toggleSave: suspend (SavedPost) -> Unit,
|
||||||
reloadPosts: () -> Unit,
|
reloadPosts: () -> Unit,
|
||||||
launchUrl: (String) -> Unit,
|
launchUrl: (String) -> Unit,
|
||||||
|
viewComments: (String) -> Unit,
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
) {
|
) {
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
@ -40,6 +41,7 @@ fun HottestPosts(
|
||||||
launchUrl = launchUrl,
|
launchUrl = launchUrl,
|
||||||
listState = listState,
|
listState = listState,
|
||||||
isSaved = isPostSaved,
|
isSaved = isPostSaved,
|
||||||
|
viewComments = viewComments,
|
||||||
toggleSave = { coroutineScope.launch { toggleSave(it) } },
|
toggleSave = { coroutineScope.launch { toggleSave(it) } },
|
||||||
modifier = Modifier.padding(top = 16.dp).then(modifier),
|
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.navigationBarsPadding
|
||||||
import com.google.accompanist.insets.statusBarsPadding
|
import com.google.accompanist.insets.statusBarsPadding
|
||||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||||
|
import dev.msfjarvis.claw.android.comments.CommentsPage
|
||||||
import dev.msfjarvis.claw.android.viewmodel.ClawViewModel
|
import dev.msfjarvis.claw.android.viewmodel.ClawViewModel
|
||||||
import dev.msfjarvis.claw.common.theme.LobstersTheme
|
import dev.msfjarvis.claw.common.theme.LobstersTheme
|
||||||
import dev.msfjarvis.claw.common.urllauncher.UrlLauncher
|
import dev.msfjarvis.claw.common.urllauncher.UrlLauncher
|
||||||
|
@ -92,9 +93,16 @@ fun LobstersApp(
|
||||||
viewModel::toggleSave,
|
viewModel::toggleSave,
|
||||||
viewModel::reloadPosts,
|
viewModel::reloadPosts,
|
||||||
urlLauncher::launch,
|
urlLauncher::launch,
|
||||||
|
{ navController.navigate("comments/$it") },
|
||||||
Modifier.nestedScroll(nestedScrollConnection),
|
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,
|
launchUrl: (String) -> Unit,
|
||||||
isSaved: suspend (SavedPost) -> Boolean,
|
isSaved: suspend (SavedPost) -> Boolean,
|
||||||
toggleSave: (SavedPost) -> Unit,
|
toggleSave: (SavedPost) -> Unit,
|
||||||
|
viewComments: (String) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
@ -42,7 +43,7 @@ fun NetworkPosts(
|
||||||
post = dbModel,
|
post = dbModel,
|
||||||
isSaved = saved,
|
isSaved = saved,
|
||||||
viewPost = { launchUrl(item.url.ifEmpty { item.commentsUrl }) },
|
viewPost = { launchUrl(item.url.ifEmpty { item.commentsUrl }) },
|
||||||
viewComments = { launchUrl(item.commentsUrl) },
|
viewComments = { viewComments(item.shortId) },
|
||||||
toggleSave = { toggleSave(dbModel) },
|
toggleSave = { toggleSave(dbModel) },
|
||||||
modifier = Modifier.padding(bottom = 16.dp, start = 16.dp, end = 16.dp),
|
modifier = Modifier.padding(bottom = 16.dp, start = 16.dp, end = 16.dp),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue