动态详情页交互功能增加游客登录判断

This commit is contained in:
2025-09-05 15:21:09 +08:00
parent 9dceb99a98
commit 18a0bb8494

View File

@@ -423,12 +423,8 @@ fun PostScreen(
// 检查游客模式,如果是游客则跳转登录 // 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.FOLLOW_USER)) { if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.FOLLOW_USER)) {
debouncedNavigation { debouncedNavigation {
debouncedNavigation { navController.navigate(NavigationRoute.Login.route)
debouncedNavigation {
navController.navigate(NavigationRoute.Login.route)
}
} }
}
} else { } else {
scope.launch { scope.launch {
if (viewModel.moment?.followStatus == true) { if (viewModel.moment?.followStatus == true) {
@@ -450,17 +446,14 @@ fun PostScreen(
// 检查游客模式,如果是游客则跳转登录 // 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.REPORT_CONTENT)) { if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.REPORT_CONTENT)) {
debouncedNavigation { debouncedNavigation {
debouncedNavigation { navController.navigate(NavigationRoute.Login.route)
debouncedNavigation {
navController.navigate(NavigationRoute.Login.route)
}
} }
}
} else { } else {
showReportDialog = true showReportDialog = true
} }
} }
) )
LazyColumn( LazyColumn(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
@@ -943,7 +936,13 @@ fun Header(
.height(24.dp) .height(24.dp)
.padding(end = 8.dp) .padding(end = 8.dp)
.noRippleClickable { .noRippleClickable {
expanded = true if(GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.REPORT_CONTENT)){
debouncedNavigation{
navController.navigate(NavigationRoute.Login.route)
}
}else {
expanded = true
}
}, },
painter = painterResource(id = R.drawable.rider_pro_more_horizon), painter = painterResource(id = R.drawable.rider_pro_more_horizon),
contentDescription = "", contentDescription = "",
@@ -1436,10 +1435,18 @@ fun CommentItem(
AnimatedLikeIcon( AnimatedLikeIcon(
liked = commentEntity.liked, liked = commentEntity.liked,
onClick = { onClick = {
onLike(commentEntity) // 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
debouncedNavigation {
navController.navigate(NavigationRoute.Login.route)
}
} else {
onLike(commentEntity)
}
}, },
modifier = Modifier.size(16.dp) modifier = Modifier.size(16.dp)
) )
Spacer(modifier = Modifier.width(4.dp)) Spacer(modifier = Modifier.width(4.dp))
Text( Text(
text = commentEntity.likes.toString(), text = commentEntity.likes.toString(),
@@ -1462,24 +1469,28 @@ fun CommentItem(
tint = AppColors.nonActiveText tint = AppColors.nonActiveText
) )
Spacer(modifier = Modifier.width(4.dp)) Spacer(modifier = Modifier.width(4.dp))
Text( Text(
text = stringResource(R.string.reply), text = stringResource(R.string.reply),
fontSize = 12.sp, fontSize = 12.sp,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
color = AppColors.nonActiveText, color = AppColors.nonActiveText,
modifier = Modifier.noRippleClickable { modifier = Modifier.noRippleClickable {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.COMMENT_MOMENT)) {
debouncedNavigation {
navController.navigate(NavigationRoute.Login.route)
}
} else {
onReply( onReply(
commentEntity, commentEntity,
commentEntity.replyUserId, commentEntity.replyUserId,
commentEntity.replyUserNickname, commentEntity.replyUserNickname,
commentEntity.replyUserAvatar commentEntity.replyUserAvatar
) )
}, }
) },
)
} }
} }
} }
Spacer(modifier = Modifier.height(8.dp)) Spacer(modifier = Modifier.height(8.dp))
@@ -1538,6 +1549,8 @@ fun PostBottomBar(
momentEntity: MomentEntity? momentEntity: MomentEntity?
) { ) {
val AppColors = LocalAppTheme.current val AppColors = LocalAppTheme.current
val navController = LocalNavController.current
val debouncedNavigation = rememberDebouncedNavigation()
Column( Column(
modifier = Modifier.background( modifier = Modifier.background(
@@ -1567,7 +1580,14 @@ fun PostBottomBar(
.height(31.dp) .height(31.dp)
.padding(8.dp) .padding(8.dp)
.noRippleClickable { .noRippleClickable {
onCreateCommentClick() // 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.COMMENT_MOMENT)) {
debouncedNavigation {
navController.navigate(NavigationRoute.Login.route)
}
} else {
onCreateCommentClick()
}
} }
) { ) {
Row( Row(
@@ -1589,7 +1609,16 @@ fun PostBottomBar(
Spacer(modifier = Modifier.width(16.dp)) Spacer(modifier = Modifier.width(16.dp))
AnimatedLikeIcon( AnimatedLikeIcon(
liked = momentEntity?.liked == true, liked = momentEntity?.liked == true,
onClick = onLikeClick, onClick = {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
debouncedNavigation {
navController.navigate(NavigationRoute.Login.route)
}
} else {
onLikeClick()
}
},
modifier = Modifier.size(24.dp) modifier = Modifier.size(24.dp)
) )
Spacer(modifier = Modifier.width(4.dp)) Spacer(modifier = Modifier.width(4.dp))
@@ -1597,7 +1626,16 @@ fun PostBottomBar(
Spacer(modifier = Modifier.width(16.dp)) Spacer(modifier = Modifier.width(16.dp))
AnimatedFavouriteIcon( AnimatedFavouriteIcon(
isFavourite = momentEntity?.isFavorite == true, isFavourite = momentEntity?.isFavorite == true,
onClick = onFavoriteClick, onClick = {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
debouncedNavigation {
navController.navigate(NavigationRoute.Login.route)
}
} else {
onFavoriteClick()
}
},
modifier = Modifier.size(24.dp) modifier = Modifier.size(24.dp)
) )
Spacer(modifier = Modifier.width(4.dp)) Spacer(modifier = Modifier.width(4.dp))
@@ -1611,6 +1649,7 @@ fun PostBottomBar(
} }
@Composable @Composable
fun PostMenuModal( fun PostMenuModal(
onDeleteClick: () -> Unit = {}, onDeleteClick: () -> Unit = {},
@@ -1618,6 +1657,8 @@ fun PostMenuModal(
userId: Int? = 0 userId: Int? = 0
) { ) {
val AppColors = LocalAppTheme.current val AppColors = LocalAppTheme.current
val navController = LocalNavController.current
val debouncedNavigation = rememberDebouncedNavigation()
Row( Row(
modifier = Modifier modifier = Modifier
@@ -1627,11 +1668,11 @@ fun PostMenuModal(
.padding(vertical = 47.dp, horizontal = 20.dp) .padding(vertical = 47.dp, horizontal = 20.dp)
) { ) {
if(AppState.UserId == userId){ if(AppState.UserId == userId){
Row( Row(
modifier = Modifier modifier = Modifier
.size(60.dp), .size(60.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
Column( Column(
modifier = Modifier.padding(end = 16.dp), modifier = Modifier.padding(end = 16.dp),
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
@@ -1670,41 +1711,49 @@ fun PostMenuModal(
.size(60.dp), .size(60.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
Column( Column(
modifier = Modifier.padding(end = 16.dp), modifier = Modifier.padding(end = 16.dp),
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
Box( Box(
modifier = Modifier modifier = Modifier
.clip(CircleShape) .clip(CircleShape)
.noRippleClickable { .noRippleClickable {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.REPORT_CONTENT)) {
debouncedNavigation {
navController.navigate(NavigationRoute.Login.route)
}
} else {
onReportClick() onReportClick()
} }
) { }
Image( ) {
painter = painterResource(id = R.drawable.rider_pro_moment_report), Image(
contentDescription = "", painter = painterResource(id = R.drawable.rider_pro_moment_report),
modifier = Modifier.size(24.dp), contentDescription = "",
colorFilter = ColorFilter.tint( modifier = Modifier.size(24.dp),
AppColors.error colorFilter = ColorFilter.tint(
) AppColors.error
) )
}
Spacer(modifier = Modifier.height(8.dp))
Text(
text = stringResource(R.string.report),
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
color = AppColors.error
) )
} }
Spacer(modifier = Modifier.height(8.dp))
Text(
text = stringResource(R.string.report),
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
color = AppColors.error
)
} }
}
} }
} }
@Composable @Composable
fun MenuActionItem( fun MenuActionItem(
icon: Int? = null, icon: Int? = null,
@@ -1761,6 +1810,8 @@ fun CommentMenuModal(
) { ) {
val clipboard = LocalClipboardManager.current val clipboard = LocalClipboardManager.current
val AppColors = LocalAppTheme.current val AppColors = LocalAppTheme.current
val navController = LocalNavController.current
val debouncedNavigation = rememberDebouncedNavigation()
fun copyToClipboard() { fun copyToClipboard() {
commentEntity?.let { commentEntity?.let {
@@ -1860,7 +1911,16 @@ fun CommentMenuModal(
content = { content = {
AnimatedLikeIcon( AnimatedLikeIcon(
liked = it.liked, liked = it.liked,
onClick = onLikeClick, onClick = {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
debouncedNavigation {
navController.navigate(NavigationRoute.Login.route)
}
} else {
onLikeClick()
}
},
modifier = Modifier.size(24.dp) modifier = Modifier.size(24.dp)
) )
} }
@@ -1869,19 +1929,28 @@ fun CommentMenuModal(
} }
} }
//自己也可以回复自己 //自己也可以回复自己
Spacer(modifier = Modifier.width(48.dp)) Spacer(modifier = Modifier.width(48.dp))
MenuActionItem( MenuActionItem(
icon = R.drawable.rider_pro_comment, icon = R.drawable.rider_pro_comment,
text = stringResource(R.string.reply) text = stringResource(R.string.reply)
) { ) {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.COMMENT_MOMENT)) {
debouncedNavigation {
navController.navigate(NavigationRoute.Login.route)
}
} else {
onReplyClick() onReplyClick()
} }
}
} }
Spacer(modifier = Modifier.height(48.dp)) Spacer(modifier = Modifier.height(48.dp))
} }
} }
@Composable @Composable
fun OrderSelectionComponent( fun OrderSelectionComponent(
onSelected: (String) -> Unit = {} onSelected: (String) -> Unit = {}