From 1620668966cc9793cec97ab68149bbc7d5120874 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sun, 16 Jun 2024 18:29:29 +0530 Subject: [PATCH] Add comment ellipsis --- .../newpipe/fragments/list/comments/Comment.kt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 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 b293adedc..8b1726fff 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 @@ -24,6 +24,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentActivity @@ -77,6 +78,7 @@ fun Comment(comment: CommentsInfoItem) { // If the comment is expanded, we display all its content // otherwise we only display the first two lines maxLines = if (isExpanded) Int.MAX_VALUE else 2, + overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.bodyMedium ) @@ -108,18 +110,12 @@ fun Comment(comment: CommentsInfoItem) { } } -@Preview( - name = "Light mode", - uiMode = Configuration.UI_MODE_NIGHT_NO -) -@Preview( - name = "Dark mode", - uiMode = Configuration.UI_MODE_NIGHT_YES -) +@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable fun CommentPreview() { val comment = CommentsInfoItem(1, "", "") - comment.commentText = Description("Hello world!", Description.PLAIN_TEXT) + comment.commentText = Description("Hello world!\n\nThis line should be hidden by default.", Description.PLAIN_TEXT) comment.uploaderName = "Test" comment.likeCount = 100 comment.isHeartedByUploader = true