mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 02:53:09 +01:00
Better handle unknown values for comment & like count
This commit is contained in:
parent
802a094154
commit
412e1d602a
@ -135,26 +135,28 @@ fun Comment(comment: CommentsInfoItem) {
|
|||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = Modifier.padding(start = 1.dp, top = 6.dp, end = 4.dp, bottom = 6.dp)
|
modifier = Modifier.padding(start = 1.dp, top = 6.dp, end = 4.dp, bottom = 6.dp)
|
||||||
) {
|
) {
|
||||||
Image(
|
// do not show anything if the like count is unknown
|
||||||
painter = painterResource(R.drawable.ic_thumb_up),
|
if (comment.likeCount >= 0) {
|
||||||
contentDescription = stringResource(R.string.detail_likes_img_view_description),
|
Image(
|
||||||
modifier = Modifier
|
painter = painterResource(R.drawable.ic_thumb_up),
|
||||||
.padding(end = 4.dp)
|
contentDescription = stringResource(R.string.detail_likes_img_view_description),
|
||||||
.size(20.dp),
|
modifier = Modifier
|
||||||
)
|
.padding(end = 4.dp)
|
||||||
Text(
|
.size(20.dp),
|
||||||
text = Localization.likeCount(context, comment.likeCount),
|
)
|
||||||
maxLines = 1,
|
Text(
|
||||||
style = MaterialTheme.typography.labelMedium,
|
text = Localization.likeCount(context, comment.likeCount),
|
||||||
)
|
maxLines = 1,
|
||||||
|
style = MaterialTheme.typography.labelMedium,
|
||||||
|
modifier = Modifier.padding(end = 8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (comment.isHeartedByUploader) {
|
if (comment.isHeartedByUploader) {
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(R.drawable.ic_heart),
|
painter = painterResource(R.drawable.ic_heart),
|
||||||
contentDescription = stringResource(R.string.detail_heart_img_view_description),
|
contentDescription = stringResource(R.string.detail_heart_img_view_description),
|
||||||
modifier = Modifier
|
modifier = Modifier.size(20.dp),
|
||||||
.padding(start = 8.dp)
|
|
||||||
.size(20.dp),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,9 @@ import androidx.compose.foundation.lazy.LazyColumn
|
|||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.ModalBottomSheet
|
import androidx.compose.material3.ModalBottomSheet
|
||||||
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
@ -14,6 +16,7 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
||||||
|
import androidx.compose.ui.res.pluralStringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.paging.LoadState
|
import androidx.paging.LoadState
|
||||||
@ -78,7 +81,7 @@ private fun CommentRepliesDialog(
|
|||||||
CommentRepliesHeader(comment = parentComment)
|
CommentRepliesHeader(comment = parentComment)
|
||||||
HorizontalDivider(
|
HorizontalDivider(
|
||||||
thickness = 1.dp,
|
thickness = 1.dp,
|
||||||
modifier = Modifier.padding(start = 24.dp, end = 24.dp, bottom = 8.dp)
|
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 8.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +100,18 @@ private fun CommentRepliesDialog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (comments.itemCount >= 0) {
|
||||||
|
item {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp),
|
||||||
|
text = pluralStringResource(
|
||||||
|
R.plurals.replies, comments.itemCount, comments.itemCount
|
||||||
|
),
|
||||||
|
maxLines = 1,
|
||||||
|
style = MaterialTheme.typography.titleMedium
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
items(comments.itemCount) {
|
items(comments.itemCount) {
|
||||||
Comment(comment = comments[it]!!)
|
Comment(comment = comments[it]!!)
|
||||||
}
|
}
|
||||||
|
@ -83,14 +83,17 @@ fun CommentRepliesHeader(comment: CommentsInfoItem) {
|
|||||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Image(
|
// do not show anything if the like count is unknown
|
||||||
painter = painterResource(R.drawable.ic_thumb_up),
|
if (comment.likeCount >= 0) {
|
||||||
contentDescription = stringResource(R.string.detail_likes_img_view_description)
|
Image(
|
||||||
)
|
painter = painterResource(R.drawable.ic_thumb_up),
|
||||||
Text(
|
contentDescription = stringResource(R.string.detail_likes_img_view_description)
|
||||||
text = Localization.likeCount(context, comment.likeCount),
|
)
|
||||||
maxLines = 1,
|
Text(
|
||||||
)
|
text = Localization.likeCount(context, comment.likeCount),
|
||||||
|
maxLines = 1,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (comment.isHeartedByUploader) {
|
if (comment.isHeartedByUploader) {
|
||||||
Image(
|
Image(
|
||||||
|
@ -14,7 +14,6 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
||||||
import androidx.compose.ui.res.pluralStringResource
|
import androidx.compose.ui.res.pluralStringResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
@ -84,12 +83,17 @@ private fun CommentSection(
|
|||||||
NoItemsMessage(R.string.no_comments)
|
NoItemsMessage(R.string.no_comments)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
item {
|
// do not show anything if the comment count is unknown
|
||||||
Text(
|
if (count >= 0) {
|
||||||
modifier = Modifier.padding(start = 8.dp),
|
item {
|
||||||
text = pluralStringResource(R.plurals.comments, count, count),
|
Text(
|
||||||
fontWeight = FontWeight.Bold
|
modifier = Modifier
|
||||||
)
|
.padding(start = 12.dp, end = 12.dp, bottom = 4.dp),
|
||||||
|
text = pluralStringResource(R.plurals.comments, count, count),
|
||||||
|
maxLines = 1,
|
||||||
|
style = MaterialTheme.typography.titleMedium
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
when (comments.loadState.refresh) {
|
when (comments.loadState.refresh) {
|
||||||
|
Loading…
Reference in New Issue
Block a user