From 7ec5abe3620f61a7d401006f9d474aea010872b7 Mon Sep 17 00:00:00 2001 From: AllenTom Date: Sat, 12 Oct 2024 17:35:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E8=B5=9E=E5=88=97=E8=A1=A8=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E8=AF=84=E8=AE=BA=E7=82=B9=E8=B5=9E=E5=85=B3=E8=81=94?= =?UTF-8?q?=E7=9A=84=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aiosman/riderpro/data/AccountService.kt | 5 +- .../com/aiosman/riderpro/entity/Account.kt | 2 + .../com/aiosman/riderpro/ui/like/LikePage.kt | 126 ++++++++++-------- 3 files changed, 80 insertions(+), 53 deletions(-) diff --git a/app/src/main/java/com/aiosman/riderpro/data/AccountService.kt b/app/src/main/java/com/aiosman/riderpro/data/AccountService.kt index 30618e3..d08c60b 100644 --- a/app/src/main/java/com/aiosman/riderpro/data/AccountService.kt +++ b/app/src/main/java/com/aiosman/riderpro/data/AccountService.kt @@ -132,6 +132,8 @@ data class NoticeComment( val replyComment: NoticeComment?, @SerializedName("postId") val postId: Int, + @SerializedName("post") + val post: NoticePost?, ) { fun toNoticeCommentEntity(): NoticeCommentEntity { return NoticeCommentEntity( @@ -139,7 +141,8 @@ data class NoticeComment( content = content, postId = postId, time = ApiClient.dateFromApiString(time), - replyComment = replyComment?.toNoticeCommentEntity() + replyComment = replyComment?.toNoticeCommentEntity(), + post = post?.toNoticePostEntity() ) } } diff --git a/app/src/main/java/com/aiosman/riderpro/entity/Account.kt b/app/src/main/java/com/aiosman/riderpro/entity/Account.kt index bf72fdf..51cf502 100644 --- a/app/src/main/java/com/aiosman/riderpro/entity/Account.kt +++ b/app/src/main/java/com/aiosman/riderpro/entity/Account.kt @@ -88,6 +88,8 @@ data class NoticeCommentEntity( val replyComment: NoticeCommentEntity?, // 动态 val postId: Int, + // 动态 + val post : NoticePostEntity?, ) /** diff --git a/app/src/main/java/com/aiosman/riderpro/ui/like/LikePage.kt b/app/src/main/java/com/aiosman/riderpro/ui/like/LikePage.kt index d3067ef..ddec22e 100644 --- a/app/src/main/java/com/aiosman/riderpro/ui/like/LikePage.kt +++ b/app/src/main/java/com/aiosman/riderpro/ui/like/LikePage.kt @@ -199,78 +199,100 @@ fun LikeCommentNoticeItem( initImagePagerIndex = 0 ) } - } ) { - Column( - - ) { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.Top, + Row { + Column( + modifier = Modifier.weight(1f) ) { - CustomAsyncImage( - imageUrl = item.user.avatar, - modifier = Modifier - .size(48.dp) - .clip(CircleShape), - contentDescription = stringResource(R.string.like_your_comment) - ) - Spacer(modifier = Modifier.width(12.dp)) - Column( - modifier = Modifier - .weight(1f) + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.Top, ) { - Text(item.user.nickName, fontWeight = FontWeight.Bold, fontSize = 16.sp) - Spacer(modifier = Modifier.height(2.dp)) - Text(stringResource(R.string.like_your_comment)) - Spacer(modifier = Modifier.height(2.dp)) - Row { + CustomAsyncImage( + imageUrl = item.user.avatar, + modifier = Modifier + .size(48.dp) + .clip(CircleShape), + contentDescription = stringResource(R.string.like_your_comment) + ) + Spacer(modifier = Modifier.width(12.dp)) + Column( + modifier = Modifier + .weight(1f) + ) { + Text(item.user.nickName, fontWeight = FontWeight.Bold, fontSize = 16.sp) + Spacer(modifier = Modifier.height(2.dp)) + Text(stringResource(R.string.like_your_comment)) + Spacer(modifier = Modifier.height(2.dp)) + Row { + Text( + item.likeTime.timeAgo(context), + fontSize = 12.sp, + color = Color(0x99000000) + ) + } + } + } + Spacer(modifier = Modifier.height(12.dp)) + Row( + modifier = Modifier.padding(start = 48.dp) + ) { + Box( + modifier = Modifier + .size(24.dp) + .background(Color.Gray.copy(alpha = 0.1f)) + ) { + CustomAsyncImage( + context = context, + imageUrl = MyProfileViewModel.avatar, + contentDescription = "Comment Profile Picture", + modifier = Modifier.size(24.dp), + contentScale = ContentScale.Crop + ) + } + Spacer(modifier = Modifier.width(8.dp)) + Column( + modifier = Modifier.weight(1f) + ) { Text( - item.likeTime.timeAgo(context), + text = MyProfileViewModel.nickName, + fontWeight = FontWeight.W600, + fontSize = 14.sp + ) + Text( + text = item.comment?.content ?: "", fontSize = 12.sp, - color = Color(0x99000000) + color = Color(0x99000000), + maxLines = 2 ) } } } - Spacer(modifier = Modifier.height(12.dp)) - Row( - modifier = Modifier.padding(start = 48.dp) - ) { - Box( - modifier = Modifier - .size(24.dp) - .background(Color.Gray.copy(alpha = 0.1f)) - ) { + Spacer(modifier = Modifier.width(16.dp)) + if (item.comment?.replyComment?.post != null) { + item.comment.replyComment.post.let { CustomAsyncImage( context = context, - imageUrl = MyProfileViewModel.avatar, - contentDescription = "Comment Profile Picture", - modifier = Modifier.size(24.dp), + imageUrl = it.images[0].thumbnail, + contentDescription = "Post Thumbnail", + modifier = Modifier.size(48.dp), contentScale = ContentScale.Crop ) } - Spacer(modifier = Modifier.width(8.dp)) - Column( - modifier = Modifier.weight(1f) - ) { - Text( - text = MyProfileViewModel.nickName, - fontWeight = FontWeight.W600, - fontSize = 14.sp - ) - Text( - text = item.comment?.content ?: "", - fontSize = 12.sp, - color = Color(0x99000000), - maxLines = 2 + } else { + item.comment?.post?.let { + CustomAsyncImage( + context = context, + imageUrl = it.images[0].thumbnail, + contentDescription = "Post Thumbnail", + modifier = Modifier.size(48.dp), + contentScale = ContentScale.Crop ) } } } - } } \ No newline at end of file