mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 18:47:03 +05:30
feat(android): add support for identifying read posts
This commit is contained in:
parent
9c32d6721b
commit
bc2365b08b
11 changed files with 62 additions and 10 deletions
|
@ -70,7 +70,7 @@ internal fun CommentsHeader(
|
|||
modifier = Modifier.padding(16.dp).fillMaxWidth(),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
PostTitle(title = postDetails.title)
|
||||
PostTitle(title = postDetails.title, isRead = false)
|
||||
TagRow(tags = postDetails.tags.toImmutableList())
|
||||
Spacer(Modifier.height(4.dp))
|
||||
|
||||
|
@ -78,7 +78,9 @@ internal fun CommentsHeader(
|
|||
PostLink(
|
||||
linkMetadata = linkMetadata,
|
||||
modifier =
|
||||
Modifier.clickable { postActions.viewPost(linkMetadata.url, postDetails.commentsUrl) },
|
||||
Modifier.clickable {
|
||||
postActions.viewPost(postDetails.shortId, linkMetadata.url, postDetails.commentsUrl)
|
||||
},
|
||||
)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ import kotlinx.collections.immutable.toImmutableList
|
|||
fun LobstersCard(
|
||||
post: SavedPost,
|
||||
isSaved: Boolean,
|
||||
isRead: Boolean,
|
||||
postActions: PostActions,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
|
@ -70,7 +71,7 @@ fun LobstersCard(
|
|||
modifier =
|
||||
modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { postActions.viewPost(post.url, post.commentsUrl) }
|
||||
.clickable { postActions.viewPost(post.shortId, post.url, post.commentsUrl) }
|
||||
.background(MaterialTheme.colorScheme.background)
|
||||
.padding(start = 16.dp, top = 16.dp, end = 4.dp, bottom = 16.dp),
|
||||
) {
|
||||
|
@ -81,6 +82,7 @@ fun LobstersCard(
|
|||
PostDetails(
|
||||
modifier = Modifier.weight(1f),
|
||||
post = post,
|
||||
isRead = isRead,
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier.wrapContentHeight(),
|
||||
|
@ -110,9 +112,9 @@ fun LobstersCard(
|
|||
}
|
||||
|
||||
@Composable
|
||||
fun PostDetails(post: SavedPost, modifier: Modifier = Modifier) {
|
||||
fun PostDetails(post: SavedPost, isRead: Boolean, modifier: Modifier = Modifier) {
|
||||
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
PostTitle(title = post.title)
|
||||
PostTitle(title = post.title, isRead = isRead)
|
||||
TagRow(tags = post.tags.toImmutableList())
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Submitter(
|
||||
|
@ -126,13 +128,14 @@ fun PostDetails(post: SavedPost, modifier: Modifier = Modifier) {
|
|||
@Composable
|
||||
internal fun PostTitle(
|
||||
title: String,
|
||||
isRead: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
modifier = modifier,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontWeight = if (isRead) FontWeight.Normal else FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
}
|
||||
|
@ -261,10 +264,11 @@ fun LobstersCardPreview() {
|
|||
tags = listOf("databases", "apis"),
|
||||
description = "",
|
||||
),
|
||||
isRead = true,
|
||||
isSaved = true,
|
||||
postActions =
|
||||
object : PostActions {
|
||||
override fun viewPost(postUrl: String, commentsUrl: String) {}
|
||||
override fun viewPost(postId: String, postUrl: String, commentsUrl: String) {}
|
||||
|
||||
override fun viewComments(postId: String) {}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import dev.msfjarvis.claw.model.LobstersPostDetails
|
|||
|
||||
@Stable
|
||||
interface PostActions {
|
||||
fun viewPost(postUrl: String, commentsUrl: String)
|
||||
fun viewPost(postId: String, postUrl: String, commentsUrl: String)
|
||||
|
||||
fun viewComments(postId: String)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue