Skip to content

Commit b132b8b

Browse files
committed
完善二级视频评论查看
1 parent 8eb3fb9 commit b132b8b

File tree

13 files changed

+996
-205
lines changed

13 files changed

+996
-205
lines changed

app/src/main/kotlin/dev/aaa1115910/bv/mobile/component/reply/CommentItem.kt

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ fun CommentItem(
6363
comment: Comment,
6464
previewerState: ImagePreviewerState,
6565
showReplies: Boolean = true,
66-
onShowPreviewer: (newPictures: List<Comment.Picture>, afterSetPictures: () -> Unit) -> Unit
66+
onShowPreviewer: (newPictures: List<Comment.Picture>, afterSetPictures: () -> Unit) -> Unit,
67+
onShowReply: (rpid: Long) -> Unit = {}
6768
) {
6869
Surface(
6970
modifier = modifier
@@ -142,7 +143,8 @@ fun CommentItem(
142143
if (showReplies && comment.replies.isNotEmpty()) {
143144
CommentReplies(
144145
replies = comment.replies,
145-
repliesCount = comment.repliesCount
146+
repliesCount = comment.repliesCount,
147+
onOpenCommentSheet = { onShowReply(comment.rpid) }
146148
)
147149
}
148150
}
@@ -222,7 +224,7 @@ private fun CommentPictures(
222224
modifier: Modifier = Modifier,
223225
pictures: List<Comment.Picture>,
224226
previewerState: ImagePreviewerState,
225-
onShowPreviewer: (newPictures: List<Comment.Picture>, afterSetPictures: () -> Unit) -> Unit
227+
onShowPreviewer: (newPictures: List<Comment.Picture>, afterSetPictures: () -> Unit) -> Unit,
226228
) {
227229
val scope = rememberCoroutineScope()
228230
val imageBaseShape = MaterialTheme.shapes.medium
@@ -255,7 +257,7 @@ private fun CommentPictures(
255257
TransformImageView(
256258
modifier = Modifier.clickable { onClickPicture(0, itemState) },
257259
painter = rememberAsyncImagePainter(pictures.first().url),
258-
key = pictures.first().url,
260+
key = pictures.first().key,
259261
itemState = itemState,
260262
previewerState = previewerState,
261263
)
@@ -289,7 +291,7 @@ private fun CommentPictures(
289291
TransformImageView(
290292
modifier = Modifier.clickable { onClickPicture(index, itemState) },
291293
painter = rememberAsyncImagePainter(picture.url),
292-
key = picture.url,
294+
key = picture.key,
293295
itemState = itemState,
294296
previewerState = previewerState,
295297
)
@@ -324,7 +326,7 @@ private fun CommentPictures(
324326
TransformImageView(
325327
modifier = Modifier.clickable { onClickPicture(index, itemState) },
326328
painter = rememberAsyncImagePainter(picture.url),
327-
key = picture.url,
329+
key = picture.key,
328330
itemState = itemState,
329331
previewerState = previewerState,
330332
)
@@ -358,17 +360,18 @@ fun CommentReplies(
358360
modifier: Modifier = Modifier,
359361
replies: List<Comment>,
360362
repliesCount: Int,
361-
onOpenCommentSheet: (replies: List<Comment>) -> Unit = {}
363+
onOpenCommentSheet: () -> Unit
362364
) {
363365
Surface(
364366
color = MaterialTheme.colorScheme.surfaceVariant,
365-
shape = MaterialTheme.shapes.medium
367+
shape = MaterialTheme.shapes.medium,
368+
onClick = onOpenCommentSheet
366369
) {
367370
Column(
368371
modifier = modifier.padding(8.dp),
369372
verticalArrangement = Arrangement.spacedBy(4.dp)
370373
) {
371-
replies.take(2).forEach { reply ->
374+
replies.forEach { reply ->
372375
val replyContent = if (reply.content.firstOrNull()?.startsWith("回复") == true) {
373376
listOf("${reply.member.name} ")
374377
} else {
@@ -381,7 +384,7 @@ fun CommentReplies(
381384
showMoreButton = false
382385
)
383386
}
384-
if (replies.size > 2) {
387+
if (repliesCount > replies.size) {
385388
Text(
386389
text = "$repliesCount 条回复",
387390
style = MaterialTheme.typography.bodySmall
@@ -449,7 +452,8 @@ private class CommentItemPreviewParameterProvider :
449452
Comment.Picture(
450453
url = "",
451454
width = 0,
452-
height = 0
455+
height = 0,
456+
key = ""
453457
)
454458
),
455459
replies = emptyList(),
@@ -465,8 +469,8 @@ private class CommentItemPreviewParameterProvider :
465469
timeDesc = "4小时前",
466470
emotes = emptyList(),
467471
pictures = listOf(
468-
Comment.Picture(url = "", width = 0, height = 0),
469-
Comment.Picture(url = "", width = 0, height = 0)
472+
Comment.Picture(url = "", width = 0, height = 0, key = "1"),
473+
Comment.Picture(url = "", width = 0, height = 0, key = "2")
470474
),
471475
replies = emptyList(),
472476
repliesCount = 0
@@ -481,9 +485,9 @@ private class CommentItemPreviewParameterProvider :
481485
timeDesc = "4小时前",
482486
emotes = emptyList(),
483487
pictures = listOf(
484-
Comment.Picture(url = "", width = 0, height = 0),
485-
Comment.Picture(url = "", width = 0, height = 0),
486-
Comment.Picture(url = "", width = 0, height = 0)
488+
Comment.Picture(url = "", width = 0, height = 0, key = "1"),
489+
Comment.Picture(url = "", width = 0, height = 0, key = "2"),
490+
Comment.Picture(url = "", width = 0, height = 0, key = "3")
487491
),
488492
replies = emptyList(),
489493
repliesCount = 0
@@ -498,10 +502,10 @@ private class CommentItemPreviewParameterProvider :
498502
timeDesc = "4小时前",
499503
emotes = emptyList(),
500504
pictures = listOf(
501-
Comment.Picture(url = "", width = 0, height = 0),
502-
Comment.Picture(url = "", width = 0, height = 0),
503-
Comment.Picture(url = "", width = 0, height = 0),
504-
Comment.Picture(url = "", width = 0, height = 0)
505+
Comment.Picture(url = "", width = 0, height = 0, key = "1"),
506+
Comment.Picture(url = "", width = 0, height = 0, key = "2"),
507+
Comment.Picture(url = "", width = 0, height = 0, key = "3"),
508+
Comment.Picture(url = "", width = 0, height = 0, key = "4")
505509
),
506510
replies = emptyList(),
507511
repliesCount = 0
@@ -516,10 +520,10 @@ private class CommentItemPreviewParameterProvider :
516520
timeDesc = "4小时前",
517521
emotes = emptyList(),
518522
pictures = listOf(
519-
Comment.Picture(url = "", width = 0, height = 0),
520-
Comment.Picture(url = "", width = 0, height = 0),
521-
Comment.Picture(url = "", width = 0, height = 0),
522-
Comment.Picture(url = "", width = 0, height = 0)
523+
Comment.Picture(url = "", width = 0, height = 0, key = "1"),
524+
Comment.Picture(url = "", width = 0, height = 0, key = "2"),
525+
Comment.Picture(url = "", width = 0, height = 0, key = "3"),
526+
Comment.Picture(url = "", width = 0, height = 0, key = "4")
523527
),
524528
replies = listOf(
525529
Comment(

0 commit comments

Comments
 (0)