diff --git a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/AgentChatListScreen.kt b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/AgentChatListScreen.kt index 81667d3..771903e 100644 --- a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/AgentChatListScreen.kt +++ b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/AgentChatListScreen.kt @@ -54,6 +54,7 @@ import com.airbnb.lottie.compose.LottieAnimation import com.airbnb.lottie.compose.LottieCompositionSpec import com.airbnb.lottie.compose.LottieConstants import com.airbnb.lottie.compose.rememberLottieComposition +import com.aiosman.ravenow.ui.index.tabs.profile.composable.ChatEmptyStateView /** * 智能体聊天列表页面 @@ -104,22 +105,7 @@ fun AgentChatListScreen() { val isNetworkAvailable = NetworkUtils.isNetworkAvailable(context) if (isNetworkAvailable) { - Image( - painter = painterResource(id = R.mipmap.invalid_name_3), - contentDescription = "null data", - modifier = Modifier.size(120.dp) - ) - Spacer(modifier = Modifier.height(12.dp)) - Text( - text = stringResource(R.string.no_one_knocked_yet), - color = AppColors.text, - fontSize = 16.sp, - fontWeight = FontWeight.W600, - textAlign = TextAlign.Center, - modifier = Modifier.padding(horizontal = 24.dp), - maxLines = 2, - overflow = TextOverflow.Ellipsis - ) + ChatEmptyStateView() } else { NetworkErrorContentCompact( onReload = { diff --git a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/AllChatListScreen.kt b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/AllChatListScreen.kt index 14129a4..1c6be8f 100644 --- a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/AllChatListScreen.kt +++ b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/AllChatListScreen.kt @@ -46,6 +46,7 @@ import com.aiosman.ravenow.ui.network.NetworkErrorContentCompact import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults import androidx.compose.ui.text.font.FontFamily +import com.aiosman.ravenow.ui.index.tabs.profile.composable.ChatEmptyStateView data class CombinedConversation( val type: String, // "agent", "group", or "friend" @@ -230,22 +231,7 @@ fun AllChatListScreen() { val isNetworkAvailable = NetworkUtils.isNetworkAvailable(context) if (isNetworkAvailable) { - Image( - painter = painterResource(id = R.mipmap.invalid_name_3), - contentDescription = "null data", - modifier = Modifier.size(120.dp) - ) - Spacer(modifier = Modifier.height(12.dp)) - Text( - text = stringResource(R.string.no_one_knocked_yet), - color = AppColors.text, - fontSize = 16.sp, - fontWeight = FontWeight.W600, - textAlign = TextAlign.Center, - modifier = Modifier.padding(horizontal = 24.dp), - maxLines = 2, - overflow = TextOverflow.Ellipsis - ) + ChatEmptyStateView() } else { NetworkErrorContentCompact( onReload = { diff --git a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/FriendChatListScreen.kt b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/FriendChatListScreen.kt index 8219fd4..37161e9 100644 --- a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/FriendChatListScreen.kt +++ b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/FriendChatListScreen.kt @@ -41,6 +41,7 @@ import androidx.compose.ui.graphics.Brush import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults import androidx.compose.foundation.layout.PaddingValues +import com.aiosman.ravenow.ui.index.tabs.profile.composable.ChatEmptyStateView @OptIn(ExperimentalMaterialApi::class) @Composable @@ -85,22 +86,7 @@ fun FriendChatListScreen() { val isNetworkAvailable = NetworkUtils.isNetworkAvailable(context) if (isNetworkAvailable) { - Image( - painter = painterResource(id = R.mipmap.invalid_name_3), - contentDescription = "null data", - modifier = Modifier.size(120.dp) - ) - Spacer(modifier = Modifier.height(12.dp)) - Text( - text = stringResource(R.string.no_one_knocked_yet), - color = AppColors.text, - fontSize = 16.sp, - fontWeight = FontWeight.W600, - textAlign = TextAlign.Center, - modifier = Modifier.padding(horizontal = 24.dp), - maxLines = 2, - overflow = TextOverflow.Ellipsis - ) + ChatEmptyStateView() } else { NetworkErrorContentCompact( onReload = { diff --git a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/GroupChatListScreen.kt b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/GroupChatListScreen.kt index 7f6f24d..a05e2d3 100644 --- a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/GroupChatListScreen.kt +++ b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/message/tab/GroupChatListScreen.kt @@ -36,6 +36,7 @@ import com.aiosman.ravenow.ui.composables.rememberDebouncer import com.aiosman.ravenow.ui.modifiers.noRippleClickable import com.aiosman.ravenow.utils.NetworkUtils import com.aiosman.ravenow.ui.network.NetworkErrorContentCompact +import com.aiosman.ravenow.ui.index.tabs.profile.composable.ChatEmptyStateView @OptIn(ExperimentalMaterialApi::class) @Composable @@ -80,22 +81,7 @@ fun GroupChatListScreen() { val isNetworkAvailable = NetworkUtils.isNetworkAvailable(context) if (isNetworkAvailable) { - Image( - painter = painterResource(id = R.mipmap.invalid_name_3), - contentDescription = "null data", - modifier = Modifier.size(120.dp) - ) - Spacer(modifier = Modifier.height(12.dp)) - Text( - text = stringResource(R.string.no_one_knocked_yet), - color = AppColors.text, - fontSize = 16.sp, - fontWeight = FontWeight.W600, - textAlign = TextAlign.Center, - modifier = Modifier.padding(horizontal = 24.dp), - maxLines = 2, - overflow = TextOverflow.Ellipsis - ) + ChatEmptyStateView() } else { NetworkErrorContentCompact( onReload = { diff --git a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/EmptyStateView.kt b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/EmptyStateView.kt new file mode 100644 index 0000000..94a09cb --- /dev/null +++ b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/EmptyStateView.kt @@ -0,0 +1,102 @@ +package com.aiosman.ravenow.ui.index.tabs.profile.composable + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.ContentScale +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.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.aiosman.ravenow.LocalAppTheme +import com.aiosman.ravenow.R + +/** + * 空状态缺省图组件 + * 用于显示我的-动态、智能体、群聊无内容时的缺省图片和提示文本 + */ +@Composable +fun EmptyStateView( + modifier: Modifier = Modifier, + contentDescription: String = "暂无内容", + text: String = stringResource(R.string.cosmos_awaits), + fontWeight: FontWeight = FontWeight.W600 +) { + val AppColors = LocalAppTheme.current + + Column( + modifier = modifier + .fillMaxWidth(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Image( + painter = painterResource(id = R.mipmap.l_empty_img), + contentDescription = contentDescription, + modifier = Modifier + .size(width = 181.dp, height = 153.dp), + contentScale = ContentScale.Fit + ) + + Spacer(modifier = Modifier.height(9.dp)) + + Text( + text = text, + fontSize = 16.sp, + color = AppColors.text, + fontWeight = fontWeight, + textAlign = TextAlign.Center, + modifier = Modifier.padding(horizontal = 24.dp), + maxLines = 2, + overflow = TextOverflow.Ellipsis + ) + } +} + +/** + * 消息页统一空状态 + */ +@Composable +fun ChatEmptyStateView( + modifier: Modifier = Modifier, + contentDescription: String = "暂无会话", + text: String = stringResource(R.string.no_one_knocked_yet) +) { + val AppColors = LocalAppTheme.current + + Column( + modifier = modifier + .fillMaxWidth(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Image( + painter = painterResource(id = R.mipmap.invalid_name_3), + contentDescription = contentDescription, + modifier = Modifier.size(120.dp) + ) + + Spacer(modifier = Modifier.height(12.dp)) + + Text( + text = text, + color = AppColors.text, + fontSize = 16.sp, + fontWeight = FontWeight.W600, + textAlign = TextAlign.Center, + modifier = Modifier.padding(horizontal = 24.dp), + maxLines = 2, + overflow = TextOverflow.Ellipsis + ) + } +} + diff --git a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/GalleryItem.kt b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/GalleryItem.kt index fa0d3e3..f67f21a 100644 --- a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/GalleryItem.kt +++ b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/GalleryItem.kt @@ -199,24 +199,8 @@ fun GalleryGrid( .padding(vertical = 60.dp), horizontalAlignment = Alignment.CenterHorizontally ) { - Image( - painter = painterResource(id = R.mipmap.l_empty_img), - contentDescription = "暂无图片", - modifier = Modifier - .size(width = 181.dp, height = 153.dp), - ) - - Spacer(modifier = Modifier.height(9.dp)) - - Text( - text = stringResource(R.string.cosmos_awaits), - fontSize = 16.sp, - color = AppColors.text, - fontWeight = FontWeight.W600, - textAlign = TextAlign.Center, - modifier = Modifier.padding(horizontal = 24.dp), - maxLines = 2, - overflow = TextOverflow.Ellipsis + EmptyStateView( + contentDescription = "暂无图片" ) } } else { diff --git a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/GroupChatEmptyContent.kt b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/GroupChatEmptyContent.kt index 8b2be8f..1124eb2 100644 --- a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/GroupChatEmptyContent.kt +++ b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/GroupChatEmptyContent.kt @@ -147,19 +147,7 @@ fun GroupChatEmptyContent( Spacer(modifier = Modifier.height(9.dp)) - // 网络可用时才展示空状态文本 - if (networkAvailable) { - Text( - text = stringResource(R.string.cosmos_awaits), - fontSize = 16.sp, - fontWeight = FontWeight.SemiBold, - color = AppColors.text, - textAlign = TextAlign.Center, - modifier = Modifier.padding(horizontal = 24.dp), - maxLines = 2, - overflow = TextOverflow.Ellipsis - ) - } + } } else { LazyColumn( @@ -527,14 +515,11 @@ private fun EmptyStateIllustration( ) { val AppColors = LocalAppTheme.current if (isNetworkAvailable) { - Image( - painter = painterResource(id = R.mipmap.l_empty_img), + EmptyStateView( contentDescription = "空状态", - modifier = Modifier - .width(181.dp) - .height(153.dp), - contentScale = ContentScale.Fit + fontWeight = FontWeight.SemiBold ) + } else { Image( painter = painterResource(id = R.mipmap.invalid_name_10), diff --git a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/UserAgentsList.kt b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/UserAgentsList.kt index 9e8fb97..457e1df 100644 --- a/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/UserAgentsList.kt +++ b/app/src/main/java/com/aiosman/ravenow/ui/index/tabs/profile/composable/UserAgentsList.kt @@ -281,25 +281,8 @@ fun AgentEmptyContentWithSegments( horizontalAlignment = Alignment.CenterHorizontally ) { if (isNetworkAvailable) { - Image( - painter = painterResource(id = R.mipmap.l_empty_img), - contentDescription = "暂无Agent", - modifier = Modifier - .size(width = 181.dp, height = 153.dp) - .align(Alignment.CenterHorizontally), - ) - - Spacer(modifier = Modifier.height(9.dp)) - - Text( - text = stringResource(R.string.cosmos_awaits), - fontSize = 16.sp, - color = AppColors.text, - fontWeight = FontWeight.W600, - textAlign = TextAlign.Center, - modifier = Modifier.padding(horizontal = 24.dp), - maxLines = 2, - overflow = TextOverflow.Ellipsis + EmptyStateView( + contentDescription = "暂无Agent" ) } else { Image(