点赞列表显示评论点赞关联的动态

This commit is contained in:
2024-10-12 17:35:48 +08:00
parent dc363122c9
commit 7ec5abe362
3 changed files with 80 additions and 53 deletions

View File

@@ -132,6 +132,8 @@ data class NoticeComment(
val replyComment: NoticeComment?, val replyComment: NoticeComment?,
@SerializedName("postId") @SerializedName("postId")
val postId: Int, val postId: Int,
@SerializedName("post")
val post: NoticePost?,
) { ) {
fun toNoticeCommentEntity(): NoticeCommentEntity { fun toNoticeCommentEntity(): NoticeCommentEntity {
return NoticeCommentEntity( return NoticeCommentEntity(
@@ -139,7 +141,8 @@ data class NoticeComment(
content = content, content = content,
postId = postId, postId = postId,
time = ApiClient.dateFromApiString(time), time = ApiClient.dateFromApiString(time),
replyComment = replyComment?.toNoticeCommentEntity() replyComment = replyComment?.toNoticeCommentEntity(),
post = post?.toNoticePostEntity()
) )
} }
} }

View File

@@ -88,6 +88,8 @@ data class NoticeCommentEntity(
val replyComment: NoticeCommentEntity?, val replyComment: NoticeCommentEntity?,
// 动态 // 动态
val postId: Int, val postId: Int,
// 动态
val post : NoticePostEntity?,
) )
/** /**

View File

@@ -199,78 +199,100 @@ fun LikeCommentNoticeItem(
initImagePagerIndex = 0 initImagePagerIndex = 0
) )
} }
} }
) { ) {
Column( Row {
Column(
) { modifier = Modifier.weight(1f)
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.Top,
) { ) {
CustomAsyncImage( Row(
imageUrl = item.user.avatar, modifier = Modifier.fillMaxWidth(),
modifier = Modifier verticalAlignment = Alignment.Top,
.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) CustomAsyncImage(
Spacer(modifier = Modifier.height(2.dp)) imageUrl = item.user.avatar,
Text(stringResource(R.string.like_your_comment)) modifier = Modifier
Spacer(modifier = Modifier.height(2.dp)) .size(48.dp)
Row { .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( Text(
item.likeTime.timeAgo(context), text = MyProfileViewModel.nickName,
fontWeight = FontWeight.W600,
fontSize = 14.sp
)
Text(
text = item.comment?.content ?: "",
fontSize = 12.sp, fontSize = 12.sp,
color = Color(0x99000000) color = Color(0x99000000),
maxLines = 2
) )
} }
} }
} }
Spacer(modifier = Modifier.height(12.dp)) Spacer(modifier = Modifier.width(16.dp))
Row( if (item.comment?.replyComment?.post != null) {
modifier = Modifier.padding(start = 48.dp) item.comment.replyComment.post.let {
) {
Box(
modifier = Modifier
.size(24.dp)
.background(Color.Gray.copy(alpha = 0.1f))
) {
CustomAsyncImage( CustomAsyncImage(
context = context, context = context,
imageUrl = MyProfileViewModel.avatar, imageUrl = it.images[0].thumbnail,
contentDescription = "Comment Profile Picture", contentDescription = "Post Thumbnail",
modifier = Modifier.size(24.dp), modifier = Modifier.size(48.dp),
contentScale = ContentScale.Crop contentScale = ContentScale.Crop
) )
} }
Spacer(modifier = Modifier.width(8.dp)) } else {
Column( item.comment?.post?.let {
modifier = Modifier.weight(1f) CustomAsyncImage(
) { context = context,
Text( imageUrl = it.images[0].thumbnail,
text = MyProfileViewModel.nickName, contentDescription = "Post Thumbnail",
fontWeight = FontWeight.W600, modifier = Modifier.size(48.dp),
fontSize = 14.sp contentScale = ContentScale.Crop
)
Text(
text = item.comment?.content ?: "",
fontSize = 12.sp,
color = Color(0x99000000),
maxLines = 2
) )
} }
} }
} }
} }
} }