From 11bb2495ba9bcd555146bdcf2dd8b810d9287e35 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Tue, 18 Jun 2024 09:34:12 +0530 Subject: [PATCH] Improve previews, display date of comment --- .../newpipe/fragments/list/comments/Comment.kt | 15 +++++++++++---- .../fragments/list/comments/CommentReplies.kt | 3 +++ .../list/comments/CommentRepliesHeader.kt | 17 ++++++++--------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt index bdffa8561..78c9f88f4 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/Comment.kt @@ -33,6 +33,7 @@ import org.schabi.newpipe.R import org.schabi.newpipe.extractor.comments.CommentsInfoItem import org.schabi.newpipe.extractor.stream.Description import org.schabi.newpipe.ui.theme.AppTheme +import org.schabi.newpipe.util.Localization import org.schabi.newpipe.util.NavigationHelper import org.schabi.newpipe.util.image.ImageStrategy @@ -68,8 +69,11 @@ fun Comment(comment: CommentsInfoItem) { modifier = Modifier.clickable { isExpanded = !isExpanded }, verticalArrangement = Arrangement.spacedBy(4.dp) ) { + val date = Localization.relativeTimeOrTextual( + context, comment.uploadDate, comment.textualUploadDate + ) Text( - text = comment.uploaderName, + text = Localization.concatenateStrings(comment.uploaderName, date), color = MaterialTheme.colorScheme.secondary ) @@ -118,9 +122,9 @@ fun CommentsInfoItem( commentText: Description, uploaderName: String, textualUploadDate: String = "5 months ago", - likeCount: Int = 100, - isHeartedByUploader: Boolean = true, - isPinned: Boolean = true, + likeCount: Int = 0, + isHeartedByUploader: Boolean = false, + isPinned: Boolean = false, ) = CommentsInfoItem(serviceId, url, name).apply { this.commentText = commentText this.uploaderName = uploaderName @@ -137,6 +141,9 @@ private fun CommentPreview() { val comment = CommentsInfoItem( commentText = Description("Hello world!\n\nThis line should be hidden by default.", Description.PLAIN_TEXT), uploaderName = "Test", + likeCount = 100, + isPinned = true, + isHeartedByUploader = true ) AppTheme { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt index 05a6d1c3b..42813f087 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentReplies.kt @@ -42,6 +42,9 @@ private fun CommentRepliesPreview() { val comment = CommentsInfoItem( commentText = Description("Hello world!", Description.PLAIN_TEXT), uploaderName = "Test", + likeCount = 100, + isPinned = true, + isHeartedByUploader = true ) val reply1 = CommentsInfoItem( diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt index 5a2a3ede0..1853a134b 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesHeader.kt @@ -140,16 +140,15 @@ fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDispos @Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable fun CommentRepliesHeaderPreview() { - val disposables = CompositeDisposable() - val comment = CommentsInfoItem(1, "", "") - comment.commentText = Description("Hello world!", Description.PLAIN_TEXT) - comment.uploaderName = "Test" - comment.textualUploadDate = "5 months ago" - comment.likeCount = 100 - comment.isPinned = true - comment.isHeartedByUploader = true + val comment = CommentsInfoItem( + commentText = Description("Hello world!", Description.PLAIN_TEXT), + uploaderName = "Test", + likeCount = 100, + isPinned = true, + isHeartedByUploader = true + ) AppTheme { - CommentRepliesHeader(comment, disposables) + CommentRepliesHeader(comment, CompositeDisposable()) } }