首页UI调整
This commit is contained in:
@@ -7,8 +7,8 @@ import com.aiosman.ravenow.entity.ProfileEntity
|
|||||||
import com.google.gson.annotations.SerializedName
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
data class Agent(
|
data class Agent(
|
||||||
@SerializedName("author")
|
/*@SerializedName("author")
|
||||||
val author: String,
|
val author: String,*/
|
||||||
@SerializedName("avatar")
|
@SerializedName("avatar")
|
||||||
val avatar: String,
|
val avatar: String,
|
||||||
@SerializedName("breakMode")
|
@SerializedName("breakMode")
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.Row
|
|||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.wrapContentWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
@@ -19,6 +20,8 @@ import androidx.compose.foundation.pager.HorizontalPager
|
|||||||
import androidx.compose.foundation.pager.rememberPagerState
|
import androidx.compose.foundation.pager.rememberPagerState
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
|
import androidx.compose.foundation.layout.wrapContentSize
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.material.ExperimentalMaterialApi
|
import androidx.compose.material.ExperimentalMaterialApi
|
||||||
@@ -41,16 +44,21 @@ import androidx.compose.ui.res.painterResource
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.layout.ContentScale
|
||||||
|
import androidx.compose.ui.draw.blur
|
||||||
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.aiosman.ravenow.AppStore
|
import com.aiosman.ravenow.AppStore
|
||||||
import com.aiosman.ravenow.LocalAppTheme
|
import com.aiosman.ravenow.LocalAppTheme
|
||||||
|
import com.aiosman.ravenow.LocalNavController
|
||||||
import com.aiosman.ravenow.R
|
import com.aiosman.ravenow.R
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import com.aiosman.ravenow.data.Room
|
import com.aiosman.ravenow.data.Room
|
||||||
import com.aiosman.ravenow.data.Agent
|
import com.aiosman.ravenow.data.Agent
|
||||||
import com.aiosman.ravenow.data.api.ApiClient
|
import com.aiosman.ravenow.data.api.ApiClient
|
||||||
|
import com.aiosman.ravenow.ui.NavigationRoute
|
||||||
import com.aiosman.ravenow.ui.composables.AgentCard
|
import com.aiosman.ravenow.ui.composables.AgentCard
|
||||||
|
import com.aiosman.ravenow.ui.post.NewPostViewModel
|
||||||
|
|
||||||
// Banner数据类
|
// Banner数据类
|
||||||
data class BannerItem(
|
data class BannerItem(
|
||||||
@@ -60,7 +68,7 @@ data class BannerItem(
|
|||||||
val imageUrl: String,
|
val imageUrl: String,
|
||||||
val backgroundImageUrl: String,
|
val backgroundImageUrl: String,
|
||||||
val userCount: Int,
|
val userCount: Int,
|
||||||
val agentName: String
|
val agentName: String,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
fun fromRoom(room: Room): BannerItem {
|
fun fromRoom(room: Room): BannerItem {
|
||||||
@@ -68,7 +76,7 @@ data class BannerItem(
|
|||||||
id = room.id,
|
id = room.id,
|
||||||
title = room.name ?: "聊天室",
|
title = room.name ?: "聊天室",
|
||||||
subtitle = room.description ?: "欢迎加入我们的聊天室",
|
subtitle = room.description ?: "欢迎加入我们的聊天室",
|
||||||
imageUrl = room.avatar ?: "",
|
imageUrl = "${ApiClient.BASE_API_URL+"/outside"}${room.creator.profile.avatar}"+"?token="+"${AppStore.token}" ?: "",
|
||||||
backgroundImageUrl = "${ApiClient.BASE_API_URL+"/outside"}${room.recommendBanner}"+"?token="+"${AppStore.token}" ?: "",
|
backgroundImageUrl = "${ApiClient.BASE_API_URL+"/outside"}${room.recommendBanner}"+"?token="+"${AppStore.token}" ?: "",
|
||||||
userCount = room.userCount,
|
userCount = room.userCount,
|
||||||
agentName = room.creator.profile.nickname
|
agentName = room.creator.profile.nickname
|
||||||
@@ -84,7 +92,7 @@ data class AgentItem(
|
|||||||
val desc: String,
|
val desc: String,
|
||||||
val avatar: String,
|
val avatar: String,
|
||||||
val useCount: Int,
|
val useCount: Int,
|
||||||
val author: String
|
//val author: String
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
fun fromAgent(agent: Agent): AgentItem {
|
fun fromAgent(agent: Agent): AgentItem {
|
||||||
@@ -94,7 +102,7 @@ data class AgentItem(
|
|||||||
desc = agent.desc,
|
desc = agent.desc,
|
||||||
avatar = "${ApiClient.BASE_API_URL+"/outside"}${agent.avatar}"+"?token="+"${AppStore.token}",
|
avatar = "${ApiClient.BASE_API_URL+"/outside"}${agent.avatar}"+"?token="+"${AppStore.token}",
|
||||||
useCount = agent.useCount,
|
useCount = agent.useCount,
|
||||||
author = agent.author
|
//author = agent.author
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,6 +114,7 @@ data class AgentItem(
|
|||||||
@OptIn(ExperimentalMaterialApi::class)
|
@OptIn(ExperimentalMaterialApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun Explore() {
|
fun Explore() {
|
||||||
|
val navController = LocalNavController.current
|
||||||
val AppColors = LocalAppTheme.current
|
val AppColors = LocalAppTheme.current
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val viewModel: ExploreViewModel = viewModel()
|
val viewModel: ExploreViewModel = viewModel()
|
||||||
@@ -118,27 +127,13 @@ fun Explore() {
|
|||||||
isRefreshing = viewModel.isRefreshing
|
isRefreshing = viewModel.isRefreshing
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理刷新
|
|
||||||
LaunchedEffect(isRefreshing) {
|
|
||||||
if (isRefreshing) {
|
|
||||||
viewModel.refreshBannerData()
|
|
||||||
viewModel.refreshAgentData()
|
|
||||||
// 模拟网络请求延迟
|
|
||||||
kotlinx.coroutines.delay(2000)
|
|
||||||
isRefreshing = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val pullRefreshState = rememberPullRefreshState(
|
val pullRefreshState = rememberPullRefreshState(
|
||||||
refreshing = isRefreshing,
|
refreshing = isRefreshing,
|
||||||
onRefresh = {
|
onRefresh = {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
isRefreshing = true
|
// 重新请求数据
|
||||||
viewModel.refreshBannerData()
|
viewModel.refreshBannerData()
|
||||||
viewModel.refreshAgentData()
|
viewModel.refreshAgentData()
|
||||||
// 模拟网络请求延迟
|
|
||||||
kotlinx.coroutines.delay(2000)
|
|
||||||
isRefreshing = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -150,7 +145,7 @@ fun Explore() {
|
|||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(12.dp),
|
.padding(vertical = 12.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
// 左侧头像
|
// 左侧头像
|
||||||
@@ -210,20 +205,22 @@ fun Explore() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 右侧聊天按钮
|
// 右侧聊天按钮
|
||||||
androidx.compose.material3.Button(
|
Box(
|
||||||
onClick = {
|
modifier = Modifier
|
||||||
// 聊天逻辑
|
.size(width = 60.dp, height = 32.dp)
|
||||||
},
|
.background(
|
||||||
colors = androidx.compose.material3.ButtonDefaults.buttonColors(
|
color = Color(0X147c7480),
|
||||||
containerColor = AppColors.main,
|
shape = RoundedCornerShape(8.dp)
|
||||||
contentColor = Color.White
|
)
|
||||||
),
|
.clickable {
|
||||||
shape = RoundedCornerShape(20.dp),
|
// 聊天逻辑
|
||||||
modifier = Modifier.size(width = 60.dp, height = 32.dp)
|
},
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "聊天",
|
text = "聊天",
|
||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
|
color = AppColors.text,
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -300,77 +297,111 @@ fun Explore() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HotChatRoomCard(roomItem: BannerItem) {
|
fun HotChatRoomGridItem(roomItem: BannerItem) {
|
||||||
val AppColors = LocalAppTheme.current
|
val AppColors = LocalAppTheme.current
|
||||||
|
|
||||||
Card(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(160.dp)
|
.padding(horizontal = 2.dp, vertical = 4.dp)
|
||||||
.height(80.dp),
|
.background( when (roomItem.id % 6) {
|
||||||
shape = RoundedCornerShape(12.dp),
|
0 -> Color(0x285856d6)
|
||||||
elevation = androidx.compose.material3.CardDefaults.cardElevation(defaultElevation = 4.dp)
|
1 -> Color(0x2832ade6)
|
||||||
|
2 -> Color(0x28ff9500)
|
||||||
|
3 -> Color(0x28ff3b30)
|
||||||
|
4 -> Color(0x28af52de)
|
||||||
|
else -> Color(0x28ffcc00)
|
||||||
|
},
|
||||||
|
shape = RoundedCornerShape(12.dp)),
|
||||||
|
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Row(
|
// 左侧图标
|
||||||
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.size(24.dp)
|
||||||
.padding(12.dp),
|
.padding(start = 16.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
// 左侧图标
|
Image(
|
||||||
Box(
|
painter = painterResource(R.drawable.rider_pro_group_chat),
|
||||||
modifier = Modifier
|
contentDescription = "chat",
|
||||||
.size(32.dp)
|
modifier = Modifier.size(12.dp),
|
||||||
.background(
|
|
||||||
color = when (roomItem.id % 5) {
|
|
||||||
0 -> Color(0xFFE3F2FD) // 浅蓝色
|
|
||||||
1 -> Color(0xFFF3E5F5) // 浅紫色
|
|
||||||
2 -> Color(0xFFFFF3E0) // 浅橙色
|
|
||||||
3 -> Color(0xFFFCE4EC) // 浅粉色
|
|
||||||
else -> Color(0xFFFFF8E1) // 浅黄色
|
|
||||||
},
|
|
||||||
shape = RoundedCornerShape(8.dp)
|
|
||||||
),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Image(
|
|
||||||
painter = painterResource(R.drawable.rider_pro_group_chat),
|
|
||||||
contentDescription = "chat",
|
|
||||||
modifier = Modifier.size(16.dp),
|
|
||||||
colorFilter = ColorFilter.tint(Color.White)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
|
||||||
|
|
||||||
// 右侧文字
|
|
||||||
Text(
|
|
||||||
text = roomItem.title,
|
|
||||||
fontSize = 12.sp,
|
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W500,
|
|
||||||
color = AppColors.text,
|
|
||||||
maxLines = 2,
|
|
||||||
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis,
|
|
||||||
modifier = Modifier.weight(1f)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.width(6.dp))
|
||||||
|
|
||||||
|
// 右侧文字
|
||||||
|
Text(
|
||||||
|
text = roomItem.title,
|
||||||
|
fontSize = 14.sp,
|
||||||
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W500,
|
||||||
|
color = AppColors.text,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis,
|
||||||
|
modifier = Modifier.padding(end = 16.dp, top = 8.dp, bottom = 8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HotChatRoomSection(roomItems: List<BannerItem>) {
|
fun HotChatRoomGrid(roomItems: List<BannerItem>) {
|
||||||
LazyRow(
|
val AppColors = LocalAppTheme.current
|
||||||
|
|
||||||
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.wrapContentWidth()
|
||||||
.padding(horizontal = 16.dp),
|
.padding(vertical = 2.dp)
|
||||||
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.spacedBy(12.dp)
|
|
||||||
) {
|
) {
|
||||||
items(roomItems.size) { index ->
|
repeat(3) { rowIndex ->
|
||||||
HotChatRoomCard(roomItem = roomItems[index])
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.wrapContentWidth()
|
||||||
|
.padding(vertical = 2.dp),
|
||||||
|
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.spacedBy(8.dp)
|
||||||
|
) {
|
||||||
|
repeat(3) { columnIndex ->
|
||||||
|
val itemIndex = rowIndex * 3 + columnIndex
|
||||||
|
if (itemIndex < roomItems.size) {
|
||||||
|
val roomItem = roomItems[itemIndex]
|
||||||
|
HotChatRoomGridItem(roomItem = roomItem)
|
||||||
|
} else {
|
||||||
|
// 填充空白占位
|
||||||
|
Spacer(modifier = Modifier.width(80.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun HotChatRoomGridSection(roomItems: List<BannerItem>) {
|
||||||
|
val AppColors = LocalAppTheme.current
|
||||||
|
|
||||||
|
// 每行显示3个数据,总共3行
|
||||||
|
val itemsPerRow = 3
|
||||||
|
val totalRows = 3
|
||||||
|
val totalItems = itemsPerRow * totalRows
|
||||||
|
|
||||||
|
// 计算需要多少个完整的3x3网格
|
||||||
|
val gridCount = (roomItems.size + totalItems - 1) / totalItems
|
||||||
|
|
||||||
|
LazyRow(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
contentPadding = androidx.compose.foundation.layout.PaddingValues(horizontal = 0.dp),
|
||||||
|
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.spacedBy(6.dp)
|
||||||
|
) {
|
||||||
|
repeat(gridCount) { gridIndex ->
|
||||||
|
item {
|
||||||
|
HotChatRoomGrid(roomItems = roomItems.drop(gridIndex * totalItems).take(totalItems))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BannerCard(bannerItem: BannerItem) {
|
fun BannerCard(bannerItem: BannerItem) {
|
||||||
@@ -390,6 +421,7 @@ fun Explore() {
|
|||||||
// 背景图片
|
// 背景图片
|
||||||
if (bannerItem.backgroundImageUrl.isNotEmpty()) {
|
if (bannerItem.backgroundImageUrl.isNotEmpty()) {
|
||||||
CustomAsyncImage(
|
CustomAsyncImage(
|
||||||
|
context = context,
|
||||||
imageUrl = bannerItem.backgroundImageUrl,
|
imageUrl = bannerItem.backgroundImageUrl,
|
||||||
contentDescription = "背景图片",
|
contentDescription = "背景图片",
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
@@ -414,15 +446,14 @@ fun Explore() {
|
|||||||
// 内容
|
// 内容
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize(),
|
||||||
.padding(20.dp),
|
|
||||||
verticalArrangement = androidx.compose.foundation.layout.Arrangement.SpaceBetween
|
verticalArrangement = androidx.compose.foundation.layout.Arrangement.SpaceBetween
|
||||||
) {
|
) {
|
||||||
// 顶部:用户数量
|
// 顶部:用户数量
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Image(
|
/* Image(
|
||||||
painter = painterResource(R.drawable.rider_pro_nav_profile),
|
painter = painterResource(R.drawable.rider_pro_nav_profile),
|
||||||
contentDescription = "chat",
|
contentDescription = "chat",
|
||||||
modifier = Modifier.size(16.dp),
|
modifier = Modifier.size(16.dp),
|
||||||
@@ -434,7 +465,7 @@ fun Explore() {
|
|||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
color = Color.White,
|
color = Color.White,
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
||||||
)
|
)*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// 底部:标题和描述
|
// 底部:标题和描述
|
||||||
@@ -443,7 +474,8 @@ fun Explore() {
|
|||||||
text = bannerItem.title,
|
text = bannerItem.title,
|
||||||
fontSize = 24.sp,
|
fontSize = 24.sp,
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.Bold,
|
fontWeight = androidx.compose.ui.text.font.FontWeight.Bold,
|
||||||
color = Color.White
|
color = Color.White,
|
||||||
|
modifier = Modifier.padding(start = 16.dp)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
Text(
|
Text(
|
||||||
@@ -451,57 +483,96 @@ fun Explore() {
|
|||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
color = Color.White.copy(alpha = 0.9f),
|
color = Color.White.copy(alpha = 0.9f),
|
||||||
maxLines = 2,
|
maxLines = 2,
|
||||||
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis
|
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis,
|
||||||
|
modifier = Modifier.padding(start = 16.dp)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth().background(brush = androidx.compose.ui.graphics.Brush.verticalGradient(
|
||||||
|
colors = listOf(
|
||||||
|
Color(0x00000000), // 底部颜色(透明)
|
||||||
|
Color(0x33000000), // 顶部颜色
|
||||||
|
|
||||||
|
)
|
||||||
|
)),
|
||||||
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.SpaceBetween,
|
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.SpaceBetween,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
// Agent信息
|
// Agent信息
|
||||||
Row(
|
Box(
|
||||||
verticalAlignment = Alignment.CenterVertically
|
modifier = Modifier
|
||||||
|
.wrapContentWidth()
|
||||||
|
.padding(8.dp),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier.padding(horizontal = 12.dp, vertical = 8.dp)
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(24.dp)
|
||||||
|
.background(
|
||||||
|
Color.White.copy(alpha = 0.2f),
|
||||||
|
RoundedCornerShape(16.dp)
|
||||||
|
).blur(6.dp),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
CustomAsyncImage(
|
||||||
|
context = context,
|
||||||
|
imageUrl = bannerItem.imageUrl,
|
||||||
|
contentDescription = "agent Image",
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
|
Column {
|
||||||
|
Text(
|
||||||
|
text = bannerItem.agentName,
|
||||||
|
fontSize = 10.sp,
|
||||||
|
color = Color(0xfff5f5f5).copy(alpha = 0.6f),
|
||||||
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
||||||
|
)
|
||||||
|
// 新增的文字行
|
||||||
|
Text(
|
||||||
|
text = bannerItem.subtitle,
|
||||||
|
fontSize = 12.sp,
|
||||||
|
color = Color.White,
|
||||||
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W400,
|
||||||
|
modifier = Modifier.padding(top = 2.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Column (
|
||||||
|
modifier = Modifier
|
||||||
|
.wrapContentWidth()
|
||||||
|
.padding(end = 16.dp)
|
||||||
|
){
|
||||||
|
// 进入按钮
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(32.dp)
|
.width(69.dp)
|
||||||
.background(Color.White.copy(alpha = 0.2f), RoundedCornerShape(16.dp)),
|
.height(29.dp)
|
||||||
|
.background(
|
||||||
|
color = Color(0x7dffffff),
|
||||||
|
shape = RoundedCornerShape(8.dp)
|
||||||
|
)
|
||||||
|
.clickable {
|
||||||
|
// 进入房间逻辑
|
||||||
|
},
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = bannerItem.agentName.firstOrNull().toString(),
|
text = "进入",
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
color = Color.White,
|
color = Color.White,
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.Bold
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W600
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
|
||||||
Text(
|
|
||||||
text = bannerItem.agentName,
|
|
||||||
fontSize = 14.sp,
|
|
||||||
color = Color.White,
|
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 进入按钮
|
|
||||||
androidx.compose.material3.Button(
|
|
||||||
onClick = {
|
|
||||||
// 进入房间逻辑
|
|
||||||
},
|
|
||||||
colors = androidx.compose.material3.ButtonDefaults.buttonColors(
|
|
||||||
containerColor = Color.White.copy(alpha = 0.9f),
|
|
||||||
contentColor = Color(0xFF4CAF50)
|
|
||||||
),
|
|
||||||
shape = RoundedCornerShape(20.dp)
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = "进入",
|
|
||||||
fontSize = 14.sp,
|
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W600
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -522,7 +593,6 @@ fun Explore() {
|
|||||||
|
|
||||||
|
|
||||||
// 可以添加更多不同高度的内容项
|
// 可以添加更多不同高度的内容项
|
||||||
// 四个圆角布局
|
|
||||||
item {
|
item {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -532,6 +602,10 @@ fun Explore() {
|
|||||||
) {
|
) {
|
||||||
// 第一个
|
// 第一个
|
||||||
Column(
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.clickable {
|
||||||
|
navController.navigate(NavigationRoute.CreateGroupChat.route)
|
||||||
|
},
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
@@ -545,7 +619,7 @@ fun Explore() {
|
|||||||
contentDescription = "创建群聊",
|
contentDescription = "创建群聊",
|
||||||
modifier = Modifier.size(24.dp),
|
modifier = Modifier.size(24.dp),
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.size(8.dp))
|
Spacer(modifier = Modifier.size(8.dp))
|
||||||
Text(
|
Text(
|
||||||
@@ -558,6 +632,11 @@ fun Explore() {
|
|||||||
|
|
||||||
// 第二个
|
// 第二个
|
||||||
Column(
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.clickable {
|
||||||
|
navController.navigate(
|
||||||
|
NavigationRoute.AddAgent.route)
|
||||||
|
},
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
@@ -568,10 +647,10 @@ fun Explore() {
|
|||||||
) {
|
) {
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(R.mipmap.rider_pro_agent),
|
painter = painterResource(R.mipmap.rider_pro_agent),
|
||||||
contentDescription = "创建Agent",
|
contentDescription = "创建智能体",
|
||||||
modifier = Modifier.size(24.dp),
|
modifier = Modifier.size(24.dp),
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.size(8.dp))
|
Spacer(modifier = Modifier.size(8.dp))
|
||||||
Text(
|
Text(
|
||||||
@@ -584,6 +663,11 @@ fun Explore() {
|
|||||||
|
|
||||||
// 第三个
|
// 第三个
|
||||||
Column(
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.clickable {
|
||||||
|
NewPostViewModel.asNewPost()
|
||||||
|
navController.navigate("NewPost")
|
||||||
|
},
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
@@ -620,7 +704,7 @@ fun Explore() {
|
|||||||
) {
|
) {
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(R.mipmap.rider_pro_fire),
|
painter = painterResource(R.mipmap.rider_pro_fire),
|
||||||
contentDescription = "热门Agents",
|
contentDescription = "热门智能体",
|
||||||
modifier = Modifier.size(24.dp),
|
modifier = Modifier.size(24.dp),
|
||||||
|
|
||||||
)
|
)
|
||||||
@@ -644,6 +728,32 @@ fun BannerSection(bannerItems: List<BannerItem>) {
|
|||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
val pagerState = rememberPagerState(pageCount = { bannerItems.size })
|
val pagerState = rememberPagerState(pageCount = { bannerItems.size })
|
||||||
|
|
||||||
|
// 预加载banner图片
|
||||||
|
LaunchedEffect(bannerItems) {
|
||||||
|
bannerItems.forEach { bannerItem ->
|
||||||
|
if (bannerItem.backgroundImageUrl.isNotEmpty()) {
|
||||||
|
// 预加载背景图片
|
||||||
|
com.aiosman.ravenow.utils.Utils.getImageLoader(context).enqueue(
|
||||||
|
coil.request.ImageRequest.Builder(context)
|
||||||
|
.data(bannerItem.backgroundImageUrl)
|
||||||
|
.memoryCachePolicy(coil.request.CachePolicy.ENABLED)
|
||||||
|
.diskCachePolicy(coil.request.CachePolicy.ENABLED)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (bannerItem.imageUrl.isNotEmpty()) {
|
||||||
|
// 预加载头像图片
|
||||||
|
com.aiosman.ravenow.utils.Utils.getImageLoader(context).enqueue(
|
||||||
|
coil.request.ImageRequest.Builder(context)
|
||||||
|
.data(bannerItem.imageUrl)
|
||||||
|
.memoryCachePolicy(coil.request.CachePolicy.ENABLED)
|
||||||
|
.diskCachePolicy(coil.request.CachePolicy.ENABLED)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
// Banner内容
|
// Banner内容
|
||||||
@@ -705,7 +815,7 @@ fun BannerSection(bannerItems: List<BannerItem>) {
|
|||||||
Spacer(modifier = Modifier.width(4.dp))
|
Spacer(modifier = Modifier.width(4.dp))
|
||||||
Text(
|
Text(
|
||||||
text = "正在高能对话中",
|
text = "正在高能对话中",
|
||||||
fontSize = 16.sp,
|
fontSize = 20.sp,
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W600,
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W600,
|
||||||
color = AppColors.text
|
color = AppColors.text
|
||||||
)
|
)
|
||||||
@@ -736,7 +846,7 @@ fun BannerSection(bannerItems: List<BannerItem>) {
|
|||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(4.dp))
|
Spacer(modifier = Modifier.width(4.dp))
|
||||||
Text(
|
Text(
|
||||||
text = "推荐Agent",
|
text = "推荐给你的智能体",
|
||||||
fontSize = 16.sp,
|
fontSize = 16.sp,
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W600,
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W600,
|
||||||
color = AppColors.text
|
color = AppColors.text
|
||||||
@@ -761,9 +871,9 @@ fun BannerSection(bannerItems: List<BannerItem>) {
|
|||||||
modifier = Modifier.padding(bottom = 12.dp)
|
modifier = Modifier.padding(bottom = 12.dp)
|
||||||
) {
|
) {
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(R.mipmap.rider_pro_group),
|
painter = painterResource(R.mipmap.rider_pro_hot_room),
|
||||||
contentDescription = "chat room",
|
contentDescription = "chat room",
|
||||||
modifier = Modifier.size(16.dp),
|
modifier = Modifier.size(24.dp),
|
||||||
colorFilter = ColorFilter.tint(Color(0xFFFFA500))
|
colorFilter = ColorFilter.tint(Color(0xFFFFA500))
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(4.dp))
|
Spacer(modifier = Modifier.width(4.dp))
|
||||||
@@ -776,7 +886,7 @@ fun BannerSection(bannerItems: List<BannerItem>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 热门聊天室列表
|
// 热门聊天室列表
|
||||||
//HotChatRoomSection(roomItems = viewModel.bannerItems)
|
HotChatRoomGridSection(roomItems = viewModel.bannerItems)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
app/src/main/res/mipmap-xhdpi/rider_pro_hot_room.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/rider_pro_hot_room.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 655 B |
Reference in New Issue
Block a user