Enhance AI Agent Profile Interaction
This commit introduces several enhancements to how AI agent profiles are displayed and interacted with:
**Profile Display:**
- **AI Account Distinction:** Profile pages now differentiate between regular user accounts and AI agent accounts.
- AI agent profiles will not display the "Agents" tab in their profile.
- The profile header height is adjusted for AI accounts.
- **Navigation Parameter:** An `isAiAccount` boolean parameter is added to the `AccountProfile` navigation route to indicate if the profile being viewed belongs to an AI.
**Interaction & Navigation:**
- **Avatar Click Navigation:**
- Clicking an AI agent's avatar in various lists (Hot Agents, My Agents, User Agents Row, User Agents List) now navigates to the agent's dedicated profile page.
- When navigating to an agent's profile from an agent list, `isAiAccount` is set to `true`.
- **Chat Initiation:** Clicking the chat button on AI agent cards in the "Agent" tab (both Hot and My Agents) now correctly initiates a chat with the respective AI.
- **ViewModel Updates:**
- `AgentViewModel`, `MineAgentViewModel`, and `HotAgentViewModel` now include a `goToProfile` function to handle navigation to agent profiles, correctly passing the `isAiAccount` flag.
**Code Refinements:**
- Click handlers for agent avatars and chat buttons are now wrapped with `DebounceUtils.simpleDebounceClick` to prevent multiple rapid clicks.
- The `UserContentPageIndicator` now conditionally hides the "Agent" tab based on the `isAiAccount` status.
- `UserAgentsRow` and `UserAgentsList` now accept an `onAvatarClick` callback for navigating to agent profiles.
- `AgentItem` (used in `UserAgentsRow`) and `UserAgentCard` (used in `UserAgentsList`) now handle avatar clicks.
- The general `Agent` composable (used in `AiPostComposable`) now also supports an `onAvatarClick` callback.
This commit is contained in:
@@ -59,6 +59,8 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.aiosman.ravenow.AppState
|
||||
import com.aiosman.ravenow.AppStore
|
||||
import com.aiosman.ravenow.GuestLoginCheckOut
|
||||
import com.aiosman.ravenow.GuestLoginCheckOutScene
|
||||
import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.Messaging
|
||||
@@ -238,10 +240,14 @@ fun IndexScreen() {
|
||||
modifier = Modifier.noRippleClickable {
|
||||
coroutineScope.launch {
|
||||
drawerState.close()
|
||||
Messaging.unregisterDevice(context)
|
||||
// 只有非游客用户才需要取消注册推送设备
|
||||
if (!AppStore.isGuest) {
|
||||
Messaging.unregisterDevice(context)
|
||||
}
|
||||
AppStore.apply {
|
||||
token = null
|
||||
rememberMe = false
|
||||
isGuest = false // 清除游客状态
|
||||
saveData()
|
||||
}
|
||||
// 删除推送渠道
|
||||
@@ -280,10 +286,32 @@ fun IndexScreen() {
|
||||
.padding(top = 2.dp)
|
||||
.noRippleClickable {
|
||||
if (it.route === NavigationItem.Add.route) {
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CREATE_POST)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
return@noRippleClickable
|
||||
}
|
||||
NewPostViewModel.asNewPost()
|
||||
navController.navigate(NavigationRoute.NewPost.route)
|
||||
return@noRippleClickable
|
||||
}
|
||||
|
||||
// 检查消息tab的游客模式
|
||||
if (it.route === NavigationItem.Notification.route) {
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.VIEW_MESSAGES)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
return@noRippleClickable
|
||||
}
|
||||
}
|
||||
|
||||
// 检查我的tab的游客模式
|
||||
if (it.route === NavigationItem.Profile.route) {
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.VIEW_PROFILE)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
return@noRippleClickable
|
||||
}
|
||||
}
|
||||
|
||||
coroutineScope.launch {
|
||||
pagerState.scrollToPage(idx)
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import androidx.navigation.NavHostController
|
||||
import com.aiosman.ravenow.AppStore
|
||||
import com.aiosman.ravenow.GuestLoginCheckOut
|
||||
import com.aiosman.ravenow.GuestLoginCheckOutScene
|
||||
import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
@@ -70,7 +73,9 @@ fun Agent() {
|
||||
val navigationBarPaddings =
|
||||
WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding() + 48.dp
|
||||
val statusBarPaddingValues = WindowInsets.systemBars.asPaddingValues()
|
||||
var pagerState = rememberPagerState { 2 }
|
||||
// 游客模式下只显示热门Agent,正常用户显示我的Agent和热门Agent
|
||||
val tabCount = if (AppStore.isGuest) 1 else 2
|
||||
var pagerState = rememberPagerState { tabCount }
|
||||
var scope = rememberCoroutineScope()
|
||||
|
||||
val viewModel: AgentViewModel = viewModel()
|
||||
@@ -137,10 +142,15 @@ fun Agent() {
|
||||
.size(36.dp)
|
||||
.noRippleClickable {
|
||||
if (DebounceUtils.simpleDebounceClick(lastClickTime, 500L) {
|
||||
// 导航到添加智能体页面
|
||||
navController.navigate(
|
||||
NavigationRoute.AddAgent.route
|
||||
)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CREATE_AGENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
// 导航到添加智能体页面
|
||||
navController.navigate(
|
||||
NavigationRoute.AddAgent.route
|
||||
)
|
||||
}
|
||||
}) {
|
||||
lastClickTime = System.currentTimeMillis()
|
||||
}
|
||||
@@ -205,27 +215,33 @@ fun Agent() {
|
||||
color = AppColors.text
|
||||
)
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
TabItem(
|
||||
text = stringResource(R.string.agent_mine),
|
||||
isSelected = pagerState.currentPage == 0,
|
||||
onClick = {
|
||||
if (DebounceUtils.simpleDebounceClick(lastClickTime, 300L) {
|
||||
scope.launch {
|
||||
pagerState.animateScrollToPage(0)
|
||||
|
||||
// 只有非游客用户才显示"我的Agent"tab
|
||||
if (!AppStore.isGuest) {
|
||||
TabItem(
|
||||
text = stringResource(R.string.agent_mine),
|
||||
isSelected = pagerState.currentPage == 0,
|
||||
onClick = {
|
||||
if (DebounceUtils.simpleDebounceClick(lastClickTime, 300L) {
|
||||
scope.launch {
|
||||
pagerState.animateScrollToPage(0)
|
||||
}
|
||||
}) {
|
||||
lastClickTime = System.currentTimeMillis()
|
||||
}
|
||||
}) {
|
||||
lastClickTime = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
)
|
||||
TabSpacer()
|
||||
)
|
||||
TabSpacer()
|
||||
}
|
||||
|
||||
TabItem(
|
||||
text = stringResource(R.string.agent_hot),
|
||||
isSelected = pagerState.currentPage == 1,
|
||||
isSelected = if (AppStore.isGuest) pagerState.currentPage == 0 else pagerState.currentPage == 1,
|
||||
onClick = {
|
||||
if (DebounceUtils.simpleDebounceClick(lastClickTime, 300L) {
|
||||
scope.launch {
|
||||
pagerState.animateScrollToPage(1)
|
||||
val targetPage = if (AppStore.isGuest) 0 else 1
|
||||
pagerState.animateScrollToPage(targetPage)
|
||||
}
|
||||
}) {
|
||||
lastClickTime = System.currentTimeMillis()
|
||||
@@ -261,23 +277,24 @@ fun Agent() {
|
||||
.weight(1f),
|
||||
beyondBoundsPageCount = 1 // 预加载相邻页面,避免切换时重新加载
|
||||
) {
|
||||
when (it) {
|
||||
0 -> {
|
||||
MineAgent()
|
||||
if (AppStore.isGuest) {
|
||||
// 游客模式下只显示热门Agent
|
||||
when (it) {
|
||||
0 -> {
|
||||
HotAgent()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 正常用户显示我的Agent和热门Agent
|
||||
when (it) {
|
||||
0 -> {
|
||||
MineAgent()
|
||||
}
|
||||
|
||||
1 -> {
|
||||
HotAgent()
|
||||
1 -> {
|
||||
HotAgent()
|
||||
}
|
||||
}
|
||||
|
||||
2 -> {
|
||||
|
||||
}
|
||||
|
||||
3 -> {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.aiosman.ravenow.AppStore
|
||||
import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
@@ -62,7 +63,9 @@ fun MomentsList() {
|
||||
val navigationBarPaddings =
|
||||
WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding() + 48.dp
|
||||
val statusBarPaddingValues = WindowInsets.systemBars.asPaddingValues()
|
||||
var pagerState = rememberPagerState { 4 }
|
||||
// 游客模式下不显示timeline,只显示3个tab:Explore、Dynamic、Hot
|
||||
val tabCount = if (AppStore.isGuest) 3 else 4
|
||||
var pagerState = rememberPagerState { tabCount }
|
||||
var scope = rememberCoroutineScope()
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -141,36 +144,40 @@ fun MomentsList() {
|
||||
)
|
||||
|
||||
}
|
||||
//关注tab
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.noRippleClickable {
|
||||
scope.launch {
|
||||
pagerState.animateScrollToPage(2)
|
||||
}
|
||||
},
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.index_following),
|
||||
fontSize = if (pagerState.currentPage == 2)18.sp else 16.sp,
|
||||
color = if (pagerState.currentPage == 2) AppColors.text else Color(0X993c3c43),
|
||||
fontWeight = FontWeight.W600)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
|
||||
Image(
|
||||
painter = painterResource(
|
||||
if (pagerState.currentPage == 2) R.mipmap.tab_indicator_selected
|
||||
else R.drawable.tab_indicator_unselected
|
||||
),
|
||||
contentDescription = "tab indicator",
|
||||
|
||||
// 只有非游客用户才显示"关注"tab
|
||||
if (!AppStore.isGuest) {
|
||||
//关注tab
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.width(34.dp)
|
||||
.height(4.dp)
|
||||
)
|
||||
.noRippleClickable {
|
||||
scope.launch {
|
||||
pagerState.animateScrollToPage(2)
|
||||
}
|
||||
},
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.index_following),
|
||||
fontSize = if (pagerState.currentPage == 2)18.sp else 16.sp,
|
||||
color = if (pagerState.currentPage == 2) AppColors.text else Color(0X993c3c43),
|
||||
fontWeight = FontWeight.W600)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
|
||||
Image(
|
||||
painter = painterResource(
|
||||
if (pagerState.currentPage == 2) R.mipmap.tab_indicator_selected
|
||||
else R.drawable.tab_indicator_unselected
|
||||
),
|
||||
contentDescription = "tab indicator",
|
||||
modifier = Modifier
|
||||
.width(34.dp)
|
||||
.height(4.dp)
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
//热门tab
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
@@ -178,7 +185,8 @@ fun MomentsList() {
|
||||
modifier = Modifier
|
||||
.noRippleClickable {
|
||||
scope.launch {
|
||||
pagerState.animateScrollToPage(3)
|
||||
val targetPage = if (AppStore.isGuest) 2 else 3
|
||||
pagerState.animateScrollToPage(targetPage)
|
||||
}
|
||||
},
|
||||
verticalArrangement = Arrangement.Center,
|
||||
@@ -186,14 +194,14 @@ fun MomentsList() {
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.index_hot),
|
||||
fontSize = if (pagerState.currentPage == 3)18.sp else 16.sp,
|
||||
color = if (pagerState.currentPage == 3) AppColors.text else Color(0X993c3c43),
|
||||
fontSize = if ((AppStore.isGuest && pagerState.currentPage == 2) || (!AppStore.isGuest && pagerState.currentPage == 3)) 18.sp else 16.sp,
|
||||
color = if ((AppStore.isGuest && pagerState.currentPage == 2) || (!AppStore.isGuest && pagerState.currentPage == 3)) AppColors.text else Color(0X993c3c43),
|
||||
fontWeight = FontWeight.W600)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
|
||||
Image(
|
||||
painter = painterResource(
|
||||
if (pagerState.currentPage == 3) R.mipmap.tab_indicator_selected
|
||||
if ((AppStore.isGuest && pagerState.currentPage == 2) || (!AppStore.isGuest && pagerState.currentPage == 3)) R.mipmap.tab_indicator_selected
|
||||
else R.drawable.tab_indicator_unselected
|
||||
),
|
||||
contentDescription = "tab indicator",
|
||||
@@ -228,22 +236,35 @@ fun MomentsList() {
|
||||
.fillMaxWidth()
|
||||
.weight(1f)
|
||||
) {
|
||||
when (it) {
|
||||
0 -> {
|
||||
Explore()
|
||||
if (AppStore.isGuest) {
|
||||
// 游客模式:Explore(0), Dynamic(1), Hot(2)
|
||||
when (it) {
|
||||
0 -> {
|
||||
Explore()
|
||||
}
|
||||
1 -> {
|
||||
Dynamic()
|
||||
}
|
||||
2 -> {
|
||||
HotMomentsList()
|
||||
}
|
||||
}
|
||||
1 -> {
|
||||
Dynamic()
|
||||
} else {
|
||||
// 正常用户:Explore(0), Dynamic(1), Timeline(2), Hot(3)
|
||||
when (it) {
|
||||
0 -> {
|
||||
Explore()
|
||||
}
|
||||
1 -> {
|
||||
Dynamic()
|
||||
}
|
||||
2 -> {
|
||||
TimelineMomentsList()
|
||||
}
|
||||
3 -> {
|
||||
HotMomentsList()
|
||||
}
|
||||
}
|
||||
|
||||
2 -> {
|
||||
TimelineMomentsList()
|
||||
}
|
||||
|
||||
3 -> {
|
||||
HotMomentsList()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,10 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.aiosman.ravenow.GuestLoginCheckOut
|
||||
import com.aiosman.ravenow.GuestLoginCheckOutScene
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.ui.NavigationRoute
|
||||
import com.aiosman.ravenow.ui.composables.MomentCard
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -28,6 +32,7 @@ import kotlinx.coroutines.launch
|
||||
fun Dynamic() {
|
||||
val model = DynamicViewModel
|
||||
var moments = model.moments
|
||||
val navController = LocalNavController.current
|
||||
|
||||
val scope = rememberCoroutineScope()
|
||||
val state = rememberPullRefreshState(model.refreshing, onRefresh = {
|
||||
@@ -73,30 +78,50 @@ fun Dynamic() {
|
||||
val momentItem = moments[idx] ?: return@items
|
||||
MomentCard(momentEntity = momentItem,
|
||||
onAddComment = {
|
||||
scope.launch {
|
||||
model.onAddComment(momentItem.id)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.COMMENT_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
scope.launch {
|
||||
model.onAddComment(momentItem.id)
|
||||
}
|
||||
}
|
||||
},
|
||||
onLikeClick = {
|
||||
scope.launch {
|
||||
if (momentItem.liked) {
|
||||
model.dislikeMoment(momentItem.id)
|
||||
} else {
|
||||
model.likeMoment(momentItem.id)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
scope.launch {
|
||||
if (momentItem.liked) {
|
||||
model.dislikeMoment(momentItem.id)
|
||||
} else {
|
||||
model.likeMoment(momentItem.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onFavoriteClick = {
|
||||
scope.launch {
|
||||
if (momentItem.isFavorite) {
|
||||
model.unfavoriteMoment(momentItem.id)
|
||||
} else {
|
||||
model.favoriteMoment(momentItem.id)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
scope.launch {
|
||||
if (momentItem.isFavorite) {
|
||||
model.unfavoriteMoment(momentItem.id)
|
||||
} else {
|
||||
model.favoriteMoment(momentItem.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onFollowClick = {
|
||||
model.followAction(momentItem)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.FOLLOW_USER)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
model.followAction(momentItem)
|
||||
}
|
||||
},
|
||||
showFollowButton = true
|
||||
)
|
||||
|
||||
@@ -54,6 +54,8 @@ import androidx.compose.ui.res.stringResource
|
||||
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.aiosman.ravenow.AppStore
|
||||
import com.aiosman.ravenow.GuestLoginCheckOut
|
||||
import com.aiosman.ravenow.GuestLoginCheckOutScene
|
||||
import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
@@ -236,8 +238,13 @@ fun Explore() {
|
||||
shape = RoundedCornerShape(8.dp)
|
||||
)
|
||||
.clickable {
|
||||
viewModel.createSingleChat(agentItem.openId)
|
||||
viewModel.goToChatAi(agentItem.openId, navController = navController)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CHAT_WITH_AGENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
viewModel.createSingleChat(agentItem.openId)
|
||||
viewModel.goToChatAi(agentItem.openId, navController = navController)
|
||||
}
|
||||
},
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
@@ -353,19 +360,24 @@ fun Explore() {
|
||||
},
|
||||
shape = RoundedCornerShape(12.dp))
|
||||
.clickable {
|
||||
// 调用加入房间接口
|
||||
viewModel.joinRoom(
|
||||
trtcId = roomItem.trtcId.toString(),
|
||||
name = roomItem.title,
|
||||
avatar = roomItem.avatar,
|
||||
navController = navController,
|
||||
onSuccess = {
|
||||
Toast.makeText(context, enterSuccessText, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
onError = { errorMessage ->
|
||||
Toast.makeText(context, enterFailText, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.JOIN_GROUP_CHAT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
// 调用加入房间接口
|
||||
viewModel.joinRoom(
|
||||
trtcId = roomItem.trtcId.toString(),
|
||||
name = roomItem.title,
|
||||
avatar = roomItem.avatar,
|
||||
navController = navController,
|
||||
onSuccess = {
|
||||
Toast.makeText(context, enterSuccessText, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
onError = { errorMessage ->
|
||||
Toast.makeText(context, enterFailText, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
@@ -615,19 +627,24 @@ fun Explore() {
|
||||
shape = RoundedCornerShape(8.dp)
|
||||
)
|
||||
.clickable {
|
||||
// 调用加入房间接口
|
||||
viewModel.joinRoom(
|
||||
trtcId = bannerItem.trtcId.toString(),
|
||||
name = bannerItem.title,
|
||||
avatar = bannerItem.avatar,
|
||||
navController = navController,
|
||||
onSuccess = {
|
||||
Toast.makeText(context, enterSuccessText, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
onError = { errorMessage ->
|
||||
Toast.makeText(context, enterFailText, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.JOIN_GROUP_CHAT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
// 调用加入房间接口
|
||||
viewModel.joinRoom(
|
||||
trtcId = bannerItem.trtcId.toString(),
|
||||
name = bannerItem.title,
|
||||
avatar = bannerItem.avatar,
|
||||
navController = navController,
|
||||
onSuccess = {
|
||||
Toast.makeText(context, enterSuccessText, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
onError = { errorMessage ->
|
||||
Toast.makeText(context, enterFailText, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
@@ -671,7 +688,12 @@ fun Explore() {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
navController.navigate(NavigationRoute.CreateGroupChat.route)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.JOIN_GROUP_CHAT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
navController.navigate(NavigationRoute.CreateGroupChat.route)
|
||||
}
|
||||
},
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
@@ -706,8 +728,12 @@ fun Explore() {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
navController.navigate(
|
||||
NavigationRoute.AddAgent.route)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CREATE_AGENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
navController.navigate(NavigationRoute.AddAgent.route)
|
||||
}
|
||||
},
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
@@ -737,8 +763,13 @@ fun Explore() {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
NewPostViewModel.asNewPost()
|
||||
navController.navigate("NewPost")
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CREATE_POST)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
NewPostViewModel.asNewPost()
|
||||
navController.navigate("NewPost")
|
||||
}
|
||||
},
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
|
||||
@@ -58,6 +58,12 @@ object MyProfileViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
suspend fun loadUserProfile() {
|
||||
// 游客模式下不获取用户资料
|
||||
if (AppStore.isGuest) {
|
||||
MyProfileViewModel.profile = null
|
||||
return
|
||||
}
|
||||
|
||||
val profile = accountService.getMyAccountProfile()
|
||||
MyProfileViewModel.profile = profile
|
||||
}
|
||||
@@ -71,6 +77,12 @@ object MyProfileViewModel : ViewModel() {
|
||||
firstLoad = false
|
||||
loadUserProfile()
|
||||
refreshing = false
|
||||
|
||||
// 游客模式下不加载个人动态和智能体
|
||||
if (AppStore.isGuest) {
|
||||
return@launch
|
||||
}
|
||||
|
||||
profile?.let {
|
||||
try {
|
||||
momentLoader.loadData(extra = MomentLoaderExtraArgs(authorId = it.id))
|
||||
@@ -85,6 +97,12 @@ object MyProfileViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun loadMoreMoment() {
|
||||
// 游客模式下不加载更多动态
|
||||
if (AppStore.isGuest) {
|
||||
Log.d("MyProfileViewModel", "loadMoreMoment: 游客模式下跳过加载更多动态")
|
||||
return
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
profile?.let { profileData ->
|
||||
try {
|
||||
@@ -100,19 +118,30 @@ object MyProfileViewModel : ViewModel() {
|
||||
|
||||
fun logout(context: Context) {
|
||||
viewModelScope.launch {
|
||||
Messaging.unregisterDevice(context)
|
||||
// 只有非游客用户才需要取消注册推送设备
|
||||
if (!AppStore.isGuest) {
|
||||
Messaging.unregisterDevice(context)
|
||||
}
|
||||
|
||||
AppStore.apply {
|
||||
token = null
|
||||
rememberMe = false
|
||||
isGuest = false // 清除游客状态
|
||||
saveData()
|
||||
}
|
||||
// 删除推送渠道
|
||||
// 删除推送渠道和重置应用状态
|
||||
AppState.ReloadAppState(context)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun updateUserProfileBanner(bannerImageUrl: Uri?, file: File, context: Context) {
|
||||
// 游客模式下不允许更新用户资料
|
||||
if (AppStore.isGuest) {
|
||||
Log.d("MyProfileViewModel", "updateUserProfileBanner: 游客模式下无法更新用户资料")
|
||||
return
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
val newBanner = bannerImageUrl?.let {
|
||||
val cursor = context.contentResolver.query(it, null, null, null, null)
|
||||
@@ -141,6 +170,12 @@ object MyProfileViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun likeMoment(momentLMomentEntity: MomentEntity) {
|
||||
// 游客模式下不允许点赞
|
||||
if (AppStore.isGuest) {
|
||||
Log.d("MyProfileViewModel", "likeMoment: 游客模式下无法点赞")
|
||||
return
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
if (momentLMomentEntity.liked) {
|
||||
momentService.dislikeMoment(momentLMomentEntity.id)
|
||||
|
||||
@@ -61,6 +61,8 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.aiosman.ravenow.AppState
|
||||
import com.aiosman.ravenow.ConstVars
|
||||
import com.aiosman.ravenow.GuestLoginCheckOut
|
||||
import com.aiosman.ravenow.GuestLoginCheckOutScene
|
||||
import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.MainActivity
|
||||
|
||||
@@ -29,8 +29,12 @@ import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.aiosman.ravenow.AppState
|
||||
import com.aiosman.ravenow.GuestLoginCheckOut
|
||||
import com.aiosman.ravenow.GuestLoginCheckOutScene
|
||||
import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.NavigationRoute
|
||||
import com.aiosman.ravenow.entity.AccountProfileEntity
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
|
||||
@@ -41,6 +45,7 @@ fun OtherProfileAction(
|
||||
onChat: (() -> Unit)? = null
|
||||
) {
|
||||
val AppColors = LocalAppTheme.current
|
||||
val navController = LocalNavController.current
|
||||
|
||||
// 定义渐变色
|
||||
val followGradient = Brush.horizontalGradient(
|
||||
@@ -84,7 +89,12 @@ fun OtherProfileAction(
|
||||
}
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
.noRippleClickable {
|
||||
onFollow?.invoke()
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.FOLLOW_USER)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
onFollow?.invoke()
|
||||
}
|
||||
}
|
||||
) {
|
||||
Text(
|
||||
@@ -112,7 +122,12 @@ fun OtherProfileAction(
|
||||
.background(AppColors.nonActive) // 使用主题灰色背景
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
.noRippleClickable {
|
||||
onChat?.invoke()
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CHAT_WITH_AGENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
onChat?.invoke()
|
||||
}
|
||||
}
|
||||
) {
|
||||
Text(
|
||||
|
||||
@@ -35,8 +35,12 @@ import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.aiosman.ravenow.GuestLoginCheckOut
|
||||
import com.aiosman.ravenow.GuestLoginCheckOutScene
|
||||
import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.NavigationRoute
|
||||
import com.aiosman.ravenow.entity.AgentEntity
|
||||
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.ravenow.utils.DebounceUtils
|
||||
@@ -82,6 +86,7 @@ fun UserAgentCard(
|
||||
onAvatarClick: (AgentEntity) -> Unit = {}
|
||||
) {
|
||||
val AppColors = LocalAppTheme.current
|
||||
val navController = LocalNavController.current
|
||||
|
||||
// 防抖状态
|
||||
var lastClickTime by remember { mutableStateOf(0L) }
|
||||
@@ -165,7 +170,12 @@ fun UserAgentCard(
|
||||
)
|
||||
.clickable {
|
||||
if (DebounceUtils.simpleDebounceClick(lastClickTime, 500L) {
|
||||
onAgentClick(agent)
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CHAT_WITH_AGENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
onAgentClick(agent)
|
||||
}
|
||||
}) {
|
||||
lastClickTime = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user