mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 11:47:04 +05:30
all: introduce and migrate to ExtendedPostDetails
This commit is contained in:
parent
87b1377f38
commit
23298dd0f5
6 changed files with 60 additions and 15 deletions
|
@ -33,11 +33,11 @@ import dev.msfjarvis.claw.common.posts.TagRow
|
|||
import dev.msfjarvis.claw.common.res.ClawIcons
|
||||
import dev.msfjarvis.claw.common.ui.ThemedRichText
|
||||
import dev.msfjarvis.claw.model.Comment
|
||||
import dev.msfjarvis.claw.model.LobstersPostDetails
|
||||
import dev.msfjarvis.claw.model.ExtendedPostDetails
|
||||
|
||||
@Composable
|
||||
fun CommentsHeader(
|
||||
postDetails: LobstersPostDetails,
|
||||
postDetails: ExtendedPostDetails,
|
||||
postActions: PostActions,
|
||||
) {
|
||||
val htmlConverter = LocalHTMLConverter.current
|
||||
|
@ -52,11 +52,13 @@ fun CommentsHeader(
|
|||
TagRow(tags = postDetails.tags)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
|
||||
if (postDetails.url.isNotBlank()) {
|
||||
if (postDetails.linkMetadata.url.isNotBlank()) {
|
||||
PostLink(
|
||||
link = postDetails.url,
|
||||
link = postDetails.linkMetadata.url,
|
||||
modifier =
|
||||
Modifier.clickable { postActions.viewPost(postDetails.url, postDetails.commentsUrl) },
|
||||
Modifier.clickable {
|
||||
postActions.viewPost(postDetails.linkMetadata.url, postDetails.commentsUrl)
|
||||
},
|
||||
)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
}
|
||||
|
|
|
@ -21,11 +21,11 @@ import dev.msfjarvis.claw.common.NetworkState
|
|||
import dev.msfjarvis.claw.common.posts.PostActions
|
||||
import dev.msfjarvis.claw.common.ui.NetworkError
|
||||
import dev.msfjarvis.claw.common.ui.ProgressBar
|
||||
import dev.msfjarvis.claw.model.LobstersPostDetails
|
||||
import dev.msfjarvis.claw.model.ExtendedPostDetails
|
||||
|
||||
@Composable
|
||||
private fun CommentsPageInternal(
|
||||
details: LobstersPostDetails,
|
||||
details: ExtendedPostDetails,
|
||||
postActions: PostActions,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
|
@ -33,7 +33,7 @@ private fun CommentsPageInternal(
|
|||
LazyColumn(modifier = modifier, contentPadding = PaddingValues(bottom = 24.dp)) {
|
||||
item { CommentsHeader(postDetails = details, postActions = postActions) }
|
||||
|
||||
if (details.commentCount > 0) {
|
||||
if (details.comments.isNotEmpty()) {
|
||||
item {
|
||||
Text(
|
||||
text = "Comments",
|
||||
|
@ -67,7 +67,7 @@ private fun CommentsPageInternal(
|
|||
@Composable
|
||||
fun CommentsPage(
|
||||
postId: String,
|
||||
getDetails: suspend (String) -> LobstersPostDetails,
|
||||
getDetails: suspend (String) -> ExtendedPostDetails,
|
||||
postActions: PostActions,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
|
@ -79,7 +79,7 @@ fun CommentsPage(
|
|||
when (postDetails) {
|
||||
is NetworkState.Success<*> -> {
|
||||
CommentsPageInternal(
|
||||
(postDetails as NetworkState.Success<LobstersPostDetails>).data,
|
||||
(postDetails as NetworkState.Success<ExtendedPostDetails>).data,
|
||||
postActions,
|
||||
modifier.fillMaxSize(),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue