新增空状态组件文件
GalleryItem.kt、GroupChatEmptyContent.kt 、UserAgentsList.kt 3个文件都使用统一的 EmptyStateView 组件来显示空状态 消息页统一使用ChatEmptyStateView组件来显示空状态
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user