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

Added like count

This commit is contained in:
Isira Seneviratne 2024-05-12 18:09:16 +05:30
parent e05d97732e
commit 8ce9a7e43c

View File

@ -3,15 +3,18 @@ package org.schabi.newpipe.fragments.list.comments
import android.widget.TextView import android.widget.TextView
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
@ -39,16 +42,20 @@ fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDispos
val context = LocalContext.current val context = LocalContext.current
Column(modifier = Modifier.padding(all = 8.dp)) { Column(modifier = Modifier.padding(all = 8.dp)) {
Row { Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
Row( Row(
modifier = Modifier modifier = Modifier
.padding(all = 8.dp) .padding(top = 8.dp, bottom = 8.dp, end = 8.dp)
.clickable { .clickable {
NavigationHelper.openCommentAuthorIfPresent( NavigationHelper.openCommentAuthorIfPresent(
context as FragmentActivity, context as FragmentActivity,
comment comment
) )
} },
verticalAlignment = Alignment.CenterVertically
) { ) {
if (ImageStrategy.shouldLoadImages()) { if (ImageStrategy.shouldLoadImages()) {
AsyncImage( AsyncImage(
@ -75,6 +82,18 @@ fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDispos
} }
} }
Spacer(modifier = Modifier.weight(1f))
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically
) {
Image(
painter = painterResource(R.drawable.ic_thumb_up),
contentDescription = stringResource(R.string.detail_likes_img_view_description)
)
Text(text = comment.likeCount.toString())
if (comment.isHeartedByUploader) { if (comment.isHeartedByUploader) {
Image( Image(
painter = painterResource(R.drawable.ic_heart), painter = painterResource(R.drawable.ic_heart),
@ -89,6 +108,7 @@ fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDispos
) )
} }
} }
}
AndroidView( AndroidView(
factory = { context -> factory = { context ->
@ -116,6 +136,9 @@ fun CommentRepliesHeaderPreview() {
comment.commentText = Description("Hello world!", Description.PLAIN_TEXT) comment.commentText = Description("Hello world!", Description.PLAIN_TEXT)
comment.uploaderName = "Test" comment.uploaderName = "Test"
comment.textualUploadDate = "5 months ago" comment.textualUploadDate = "5 months ago"
comment.likeCount = 100
comment.isPinned = true
comment.isHeartedByUploader = true
CommentRepliesHeader(comment, disposables) CommentRepliesHeader(comment, disposables)
} }