新增网络工具,修改bug
This commit is contained in:
@@ -363,7 +363,7 @@ fun IndexScreen() {
|
||||
@Composable
|
||||
fun Home() {
|
||||
val systemUiController = rememberSystemUiController()
|
||||
LaunchedEffect(Unit) {
|
||||
LaunchedEffect(AppState.darkMode) {
|
||||
systemUiController.setStatusBarColor(Color.Transparent, darkIcons = !AppState.darkMode)
|
||||
}
|
||||
Column(
|
||||
@@ -380,7 +380,7 @@ fun Home() {
|
||||
@Composable
|
||||
fun Street() {
|
||||
val systemUiController = rememberSystemUiController()
|
||||
LaunchedEffect(Unit) {
|
||||
LaunchedEffect(AppState.darkMode) {
|
||||
systemUiController.setStatusBarColor(Color.Transparent, darkIcons = !AppState.darkMode)
|
||||
}
|
||||
Column(
|
||||
@@ -396,7 +396,7 @@ fun Street() {
|
||||
@Composable
|
||||
fun Add() {
|
||||
val systemUiController = rememberSystemUiController()
|
||||
LaunchedEffect(Unit) {
|
||||
LaunchedEffect(AppState.darkMode) {
|
||||
systemUiController.setStatusBarColor(Color.Black, darkIcons = !AppState.darkMode)
|
||||
}
|
||||
Column(
|
||||
@@ -413,7 +413,7 @@ fun Add() {
|
||||
@Composable
|
||||
fun Video() {
|
||||
val systemUiController = rememberSystemUiController()
|
||||
LaunchedEffect(Unit) {
|
||||
LaunchedEffect(AppState.darkMode) {
|
||||
systemUiController.setStatusBarColor(Color.Black, darkIcons = false)
|
||||
}
|
||||
Column(
|
||||
@@ -430,7 +430,7 @@ fun Video() {
|
||||
@Composable
|
||||
fun Profile() {
|
||||
val systemUiController = rememberSystemUiController()
|
||||
LaunchedEffect(Unit) {
|
||||
LaunchedEffect(AppState.darkMode) {
|
||||
systemUiController.setStatusBarColor(Color.Transparent, !AppState.darkMode)
|
||||
}
|
||||
Column(
|
||||
@@ -446,7 +446,7 @@ fun Profile() {
|
||||
@Composable
|
||||
fun Notifications() {
|
||||
val systemUiController = rememberSystemUiController()
|
||||
LaunchedEffect(Unit) {
|
||||
LaunchedEffect(AppState.darkMode) {
|
||||
systemUiController.setStatusBarColor(Color.Transparent, !AppState.darkMode)
|
||||
}
|
||||
Column(
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.NavigationRoute
|
||||
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
import com.aiosman.ravenow.utils.NetworkUtils
|
||||
|
||||
/**
|
||||
* 智能体聊天列表页面
|
||||
@@ -123,8 +124,12 @@ fun AgentChatListScreen() {
|
||||
AgentChatListViewModel.goToUserDetail(conv, navController)
|
||||
},
|
||||
onChatClick = { conv ->
|
||||
model.createSingleChat(conv.trtcUserId)
|
||||
model.goToChatAi(conv.trtcUserId,navController)
|
||||
if (NetworkUtils.isNetworkAvailable(context)) {
|
||||
model.createSingleChat(conv.trtcUserId)
|
||||
model.goToChatAi(conv.trtcUserId,navController)
|
||||
} else {
|
||||
android.widget.Toast.makeText(context, "网络连接异常,请检查网络设置", android.widget.Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
import com.aiosman.ravenow.utils.NetworkUtils
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
@@ -106,7 +107,11 @@ fun FriendChatListScreen() {
|
||||
FriendChatListViewModel.goToUserDetail(conv, navController)
|
||||
},
|
||||
onChatClick = { conv ->
|
||||
FriendChatListViewModel.goToChat(conv, navController)
|
||||
if (NetworkUtils.isNetworkAvailable(context)) {
|
||||
FriendChatListViewModel.goToChat(conv, navController)
|
||||
} else {
|
||||
android.widget.Toast.makeText(context, "网络连接异常,请检查网络设置", android.widget.Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.aiosman.ravenow.ui.index.tabs.message.tab
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
@@ -16,14 +14,11 @@ import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
@@ -34,6 +29,7 @@ import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
import com.aiosman.ravenow.utils.NetworkUtils
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
@@ -51,15 +47,6 @@ fun GroupChatListScreen() {
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
GroupChatListViewModel.refreshPager(context = context)
|
||||
// 初始化消息监听器
|
||||
GroupChatListViewModel.initMessageListener(context)
|
||||
}
|
||||
|
||||
// 在组件销毁时清理监听器
|
||||
DisposableEffect(Unit) {
|
||||
onDispose {
|
||||
GroupChatListViewModel.removeMessageListener()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,31 +66,18 @@ fun GroupChatListScreen() {
|
||||
.fillMaxSize()
|
||||
.padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
|
||||
Spacer(modifier = Modifier.height(80.dp))
|
||||
Image(
|
||||
painter = painterResource(id = if (isSystemInDarkTheme()) {
|
||||
R.mipmap.icon_group_chat_empty // 深色模式图片
|
||||
} else {
|
||||
R.mipmap.icon_group_chat_empty // 浅色模式图片
|
||||
}),
|
||||
contentDescription = "null data",
|
||||
modifier = Modifier
|
||||
.size(140.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.group_chat_empty_title),
|
||||
text = "暂无群聊",
|
||||
color = AppColors.text,
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.W600
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.group_chat_empty_subtitle),
|
||||
color = AppColors.text,
|
||||
text = "您还没有加入任何群聊",
|
||||
color = AppColors.secondaryText,
|
||||
fontSize = 14.sp
|
||||
)
|
||||
}
|
||||
@@ -121,10 +95,20 @@ fun GroupChatListScreen() {
|
||||
GroupChatListViewModel.goToGroupDetail(conv, navController)
|
||||
},
|
||||
onChatClick = { conv ->
|
||||
GroupChatListViewModel.goToChat(conv, navController)
|
||||
if (NetworkUtils.isNetworkAvailable(context)) {
|
||||
GroupChatListViewModel.goToChat(conv, navController)
|
||||
} else {
|
||||
android.widget.Toast.makeText(context, "网络连接异常,请检查网络设置", android.widget.Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (index < GroupChatListViewModel.groupChatList.size - 1) {
|
||||
HorizontalDivider(
|
||||
modifier = Modifier.padding(horizontal = 24.dp),
|
||||
color = AppColors.divider
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (GroupChatListViewModel.isLoading && GroupChatListViewModel.groupChatList.isNotEmpty()) {
|
||||
@@ -180,11 +164,10 @@ fun GroupChatItem(
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
.padding(horizontal = 24.dp, vertical = 12.dp)
|
||||
.noRippleClickable {
|
||||
onChatClick(conversation)
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
}
|
||||
) {
|
||||
Box {
|
||||
CustomAsyncImage(
|
||||
@@ -202,9 +185,9 @@ fun GroupChatItem(
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
|
||||
.weight(1f)
|
||||
.padding(start = 12.dp, top = 2.dp),
|
||||
verticalArrangement = Arrangement.Center
|
||||
.padding(start = 12.dp)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
@@ -212,22 +195,22 @@ fun GroupChatItem(
|
||||
) {
|
||||
Text(
|
||||
text = conversation.groupName,
|
||||
fontSize = 14.sp,
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = AppColors.text,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.width(6.dp))
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
|
||||
Text(
|
||||
text = conversation.lastMessageTime,
|
||||
fontSize = 11.sp,
|
||||
fontSize = 12.sp,
|
||||
color = AppColors.secondaryText
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
@@ -235,29 +218,30 @@ fun GroupChatItem(
|
||||
) {
|
||||
Text(
|
||||
text = "${if (conversation.isSelf) stringResource(R.string.friend_chat_me_prefix) else ""}${conversation.displayText}",
|
||||
fontSize = 12.sp,
|
||||
fontSize = 14.sp,
|
||||
color = AppColors.secondaryText,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.width(10.dp))
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
|
||||
if (conversation.unreadCount > 0) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(if (conversation.unreadCount > 99) 24.dp else 20.dp)
|
||||
.background(
|
||||
color = Color(0xFFFF3B30),
|
||||
color = AppColors.main,
|
||||
shape = CircleShape
|
||||
),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = if (conversation.unreadCount > 99) "99+" else conversation.unreadCount.toString(),
|
||||
color = Color.White,
|
||||
fontSize = if (conversation.unreadCount > 99) 11.sp else 12.sp,
|
||||
color = AppColors.mainText,
|
||||
fontSize = if (conversation.unreadCount > 99) 9.sp else 10.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
@@ -140,6 +141,7 @@ fun ProfileV3(
|
||||
val AppColors = appTheme
|
||||
val systemUiController = rememberSystemUiController()
|
||||
val listState = rememberLazyListState()
|
||||
val gridState = rememberLazyGridState()
|
||||
|
||||
// observe list scrolling
|
||||
val reachedListBottom by remember {
|
||||
@@ -149,13 +151,28 @@ fun ProfileV3(
|
||||
}
|
||||
}
|
||||
|
||||
// load more if scrolled to bottom
|
||||
// observe grid scrolling for load more
|
||||
val reachedGridBottom by remember {
|
||||
derivedStateOf {
|
||||
val lastVisibleItem = gridState.layoutInfo.visibleItemsInfo.lastOrNull()
|
||||
lastVisibleItem?.index != 0 && lastVisibleItem?.index == gridState.layoutInfo.totalItemsCount - 2
|
||||
}
|
||||
}
|
||||
|
||||
// load more if scrolled to bottom of list
|
||||
LaunchedEffect(reachedListBottom) {
|
||||
if (reachedListBottom) {
|
||||
onLoadMore()
|
||||
}
|
||||
}
|
||||
|
||||
// load more if scrolled to bottom of grid
|
||||
LaunchedEffect(reachedGridBottom) {
|
||||
if (reachedGridBottom) {
|
||||
onLoadMore()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun switchTheme() {
|
||||
@@ -451,15 +468,16 @@ fun ProfileV3(
|
||||
pagerState = pagerState,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
HorizontalPager(
|
||||
state = pagerState,
|
||||
) { idx ->
|
||||
when (idx) {
|
||||
0 ->
|
||||
LazyVerticalGrid(
|
||||
columns = GridCells.Fixed(3),
|
||||
modifier = Modifier.fillMaxSize().padding(bottom = 8.dp),
|
||||
) {
|
||||
HorizontalPager(
|
||||
state = pagerState,
|
||||
) { idx ->
|
||||
when (idx) {
|
||||
0 ->
|
||||
LazyVerticalGrid(
|
||||
columns = GridCells.Fixed(3),
|
||||
state = gridState,
|
||||
modifier = Modifier.fillMaxSize().padding(bottom = 8.dp),
|
||||
) {
|
||||
|
||||
items(moments.size) { idx ->
|
||||
val moment = moments[idx] ?: return@items
|
||||
|
||||
Reference in New Issue
Block a user