1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 02:53:09 +01:00

Improve previews, display date of comment

This commit is contained in:
Isira Seneviratne 2024-06-18 09:34:12 +05:30
parent 341cc37ce7
commit 11bb2495ba
3 changed files with 22 additions and 13 deletions

View File

@ -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 {

View File

@ -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(

View File

@ -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())
}
}