首页UI调整

This commit is contained in:
2025-08-29 18:39:59 +08:00
parent 7c0d35ec8c
commit a79628026c
5 changed files with 106 additions and 47 deletions

View File

@@ -1,5 +1,6 @@
package com.aiosman.ravenow.ui.index.tabs.message.tab package com.aiosman.ravenow.ui.index.tabs.message.tab
import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
@@ -19,6 +20,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
@@ -66,17 +68,24 @@ fun GroupChatListScreen() {
.fillMaxSize() .fillMaxSize()
.padding(16.dp), .padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) { ) {
Spacer(modifier = Modifier.height(80.dp))
Image(
painter = painterResource(id = R.mipmap.icon_friend_chat_empty),
contentDescription = "null data",
modifier = Modifier
.size(140.dp)
)
Spacer(modifier = Modifier.height(24.dp))
Text( Text(
text = "暂无群聊", text = stringResource(R.string.group_chat_empty),
color = AppColors.text, color = AppColors.text,
fontSize = 16.sp, fontSize = 16.sp,
fontWeight = FontWeight.W600 fontWeight = FontWeight.W600
) )
Spacer(modifier = Modifier.height(8.dp)) Spacer(modifier = Modifier.height(8.dp))
Text( Text(
text = "您还没有加入任何群聊", text = stringResource(R.string.group_chat_empty_join),
color = AppColors.secondaryText, color = AppColors.secondaryText,
fontSize = 14.sp fontSize = 14.sp
) )

View File

@@ -141,6 +141,7 @@ fun MomentsList() {
) )
} }
//关注tab
Spacer(modifier = Modifier.width(16.dp)) Spacer(modifier = Modifier.width(16.dp))
Column( Column(
modifier = Modifier modifier = Modifier

View File

@@ -1,14 +1,21 @@
package com.aiosman.ravenow.ui.index.tabs.moment.tabs.timeline package com.aiosman.ravenow.ui.index.tabs.moment.tabs.timeline
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
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.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.pullrefresh.PullRefreshIndicator import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.derivedStateOf
@@ -17,7 +24,13 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.paging.compose.collectAsLazyPagingItems import androidx.paging.compose.collectAsLazyPagingItems
import com.aiosman.ravenow.R
import com.aiosman.ravenow.ui.composables.MomentCard import com.aiosman.ravenow.ui.composables.MomentCard
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -52,54 +65,88 @@ fun TimelineMomentsList() {
model.loadMore() model.loadMore()
} }
} }
Column( if (moments.isEmpty()) {
modifier = Modifier Box(
.fillMaxSize() modifier = Modifier
) { .fillMaxSize()
Box(Modifier.pullRefresh(state)) { .padding(top = 188.dp),
LazyColumn( contentAlignment = Alignment.TopCenter
modifier = Modifier.fillMaxSize(), ) {
state = listState Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxWidth()
) { ) {
items( Image(
moments.size, painter = painterResource(id = R.mipmap.rider_pro_following_empty),
key = { idx -> moments.getOrNull(idx)?.id ?: idx } contentDescription = null,
) { idx -> modifier = Modifier.size(140.dp)
moments.getOrNull(idx)?.let { momentItem -> )
MomentCard( Spacer(modifier = Modifier.size(24.dp))
momentEntity = momentItem, Text(
onAddComment = { text = "You haven't followed anyone yet",
scope.launch { color = androidx.compose.material.MaterialTheme.colors.onBackground,
model.onAddComment(momentItem.id) fontSize = 16.sp,
} fontWeight = FontWeight.W600
}, )
onLikeClick = { Spacer(modifier = Modifier.size(8.dp))
scope.launch { Text(
if (momentItem.liked) { text = "Click start your social journey.",
model.dislikeMoment(momentItem.id) color = androidx.compose.material.MaterialTheme.colors.onBackground,
} else { fontSize = 16.sp,
model.likeMoment(momentItem.id) fontWeight = FontWeight.W400
)
}
}
} else {
Column(
modifier = Modifier
.fillMaxSize()
) {
Box(Modifier.pullRefresh(state)) {
LazyColumn(
modifier = Modifier.fillMaxSize(),
state = listState
) {
items(
moments.size,
key = { idx -> moments.getOrNull(idx)?.id ?: idx }
) { idx ->
moments.getOrNull(idx)?.let { momentItem ->
MomentCard(
momentEntity = momentItem,
onAddComment = {
scope.launch {
model.onAddComment(momentItem.id)
} }
} },
}, onLikeClick = {
onFavoriteClick = { scope.launch {
scope.launch { if (momentItem.liked) {
if (momentItem.isFavorite) { model.dislikeMoment(momentItem.id)
model.unfavoriteMoment(momentItem.id) } else {
} else { model.likeMoment(momentItem.id)
model.favoriteMoment(momentItem.id) }
} }
} },
}, onFavoriteClick = {
onFollowClick = { scope.launch {
model.followAction(momentItem) if (momentItem.isFavorite) {
}, model.unfavoriteMoment(momentItem.id)
showFollowButton = false } else {
) model.favoriteMoment(momentItem.id)
}
}
},
onFollowClick = {
model.followAction(momentItem)
},
showFollowButton = false
)
}
} }
} }
PullRefreshIndicator(model.refreshing, state, Modifier.align(Alignment.TopCenter))
} }
PullRefreshIndicator(model.refreshing, state, Modifier.align(Alignment.TopCenter))
} }
} }
} }

View File

@@ -158,10 +158,10 @@
<string name="agent_chat_load_failed">加载失败</string> <string name="agent_chat_load_failed">加载失败</string>
<string name="agent_chat_load_more_failed">加载更多失败</string> <string name="agent_chat_load_more_failed">加载更多失败</string>
<string name="agent_chat_user_info_failed">获取用户信息失败: %s</string> <string name="agent_chat_user_info_failed">获取用户信息失败: %s</string>
<string name="group_chat_empty">暂无群聊</string>
<string name="group_chat_empty_title">没有群聊消息的宇宙太安静了</string> <string name="group_chat_empty_title">没有群聊消息的宇宙太安静了</string>
<string name="group_chat_empty_subtitle">在首页探索感兴趣的主题房间</string> <string name="group_chat_empty_subtitle">在首页探索感兴趣的主题房间</string>
<string name="group_chat_empty_join">您还没有加入任何群聊</string>
<string name="friend_chat_empty_title">暂无朋友聊天</string> <string name="friend_chat_empty_title">暂无朋友聊天</string>
<string name="friend_chat_empty_subtitle">开始与朋友对话吧</string> <string name="friend_chat_empty_subtitle">开始与朋友对话吧</string>
<string name="friend_chat_me_prefix">我: </string> <string name="friend_chat_me_prefix">我: </string>

View File

@@ -155,6 +155,8 @@
<string name="agent_chat_load_failed">加载失败</string> <string name="agent_chat_load_failed">加载失败</string>
<string name="agent_chat_load_more_failed">加载更多失败</string> <string name="agent_chat_load_more_failed">加载更多失败</string>
<string name="agent_chat_user_info_failed">获取用户信息失败: %s</string> <string name="agent_chat_user_info_failed">获取用户信息失败: %s</string>
<string name="group_chat_empty">No group chats</string>
<string name="group_chat_empty_join">You have not joined any group chats yet</string>
<string name="group_chat_empty_title">没有群聊消息的宇宙太安静了</string> <string name="group_chat_empty_title">没有群聊消息的宇宙太安静了</string>
<string name="group_chat_empty_subtitle">在首页探索感兴趣的主题房间</string> <string name="group_chat_empty_subtitle">在首页探索感兴趣的主题房间</string>
<string name="friend_chat_empty_title">暂无朋友聊天</string> <string name="friend_chat_empty_title">暂无朋友聊天</string>