粉丝 关注 评论UI调整
This commit is contained in:
@@ -76,6 +76,7 @@ fun NoticeScreenHeader(
|
|||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
|
//返回tab
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(id = R.drawable.rider_pro_back_icon,),
|
painter = painterResource(id = R.drawable.rider_pro_back_icon,),
|
||||||
contentDescription = title,
|
contentDescription = title,
|
||||||
@@ -88,6 +89,7 @@ fun NoticeScreenHeader(
|
|||||||
colorFilter = ColorFilter.tint(AppColors.text)
|
colorFilter = ColorFilter.tint(AppColors.text)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.size(12.dp))
|
Spacer(modifier = Modifier.size(12.dp))
|
||||||
|
Spacer(modifier = Modifier.width(110.dp))
|
||||||
Text(title, fontWeight = FontWeight.W800, fontSize = 17.sp, color = AppColors.text)
|
Text(title, fontWeight = FontWeight.W800, fontSize = 17.sp, color = AppColors.text)
|
||||||
if (moreIcon) {
|
if (moreIcon) {
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ 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.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
@@ -75,73 +77,105 @@ fun CommentNoticeScreen() {
|
|||||||
) {
|
) {
|
||||||
NoticeScreenHeader(stringResource(R.string.comment), moreIcon = false)
|
NoticeScreenHeader(stringResource(R.string.comment), moreIcon = false)
|
||||||
}
|
}
|
||||||
|
if (comments.itemCount == 0 && comments.loadState.refresh is LoadState.NotLoading) {
|
||||||
LazyColumn(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize().padding(horizontal = 16.dp)
|
.fillMaxSize()
|
||||||
) {
|
.padding(top = 188.dp),
|
||||||
items(comments.itemCount) { index ->
|
contentAlignment = Alignment.TopCenter
|
||||||
comments[index]?.let { comment ->
|
) {
|
||||||
CommentNoticeItem(comment) {
|
Column(
|
||||||
viewModel.updateReadStatus(comment.id)
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
viewModel.viewModelScope.launch {
|
modifier = Modifier.fillMaxWidth()
|
||||||
var highlightCommentId = comment.id
|
) {
|
||||||
comment.parentCommentId?.let {
|
androidx.compose.foundation.Image(
|
||||||
highlightCommentId = it
|
painter = painterResource(id = R.mipmap.rider_pro_followers_empty),
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(140.dp)
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.size(24.dp))
|
||||||
|
Text(
|
||||||
|
text = "Wait for the first traveler to appear~",
|
||||||
|
color = AppColors.text,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
fontWeight = FontWeight.W600
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.size(8.dp))
|
||||||
|
Text(
|
||||||
|
text = "Post to connect.",
|
||||||
|
color = AppColors.text,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
fontWeight = FontWeight.W400
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LazyColumn(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize().padding(horizontal = 16.dp)
|
||||||
|
) {
|
||||||
|
items(comments.itemCount) { index ->
|
||||||
|
comments[index]?.let { comment ->
|
||||||
|
CommentNoticeItem(comment) {
|
||||||
|
viewModel.updateReadStatus(comment.id)
|
||||||
|
viewModel.viewModelScope.launch {
|
||||||
|
var highlightCommentId = comment.id
|
||||||
|
comment.parentCommentId?.let {
|
||||||
|
highlightCommentId = it
|
||||||
|
}
|
||||||
|
navController.navigateToPost(
|
||||||
|
id = comment.post!!.id,
|
||||||
|
highlightCommentId = highlightCommentId,
|
||||||
|
initImagePagerIndex = 0
|
||||||
|
)
|
||||||
}
|
}
|
||||||
navController.navigateToPost(
|
|
||||||
id = comment.post!!.id,
|
|
||||||
highlightCommentId = highlightCommentId,
|
|
||||||
initImagePagerIndex = 0
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// handle load error
|
||||||
// handle load error
|
when {
|
||||||
when {
|
comments.loadState.append is LoadState.Loading -> {
|
||||||
comments.loadState.append is LoadState.Loading -> {
|
item {
|
||||||
item {
|
Box(
|
||||||
Box(
|
modifier = Modifier
|
||||||
modifier = Modifier
|
.fillMaxWidth()
|
||||||
.fillMaxWidth()
|
.height(64.dp)
|
||||||
.height(64.dp)
|
.padding(16.dp),
|
||||||
.padding(16.dp),
|
contentAlignment = Alignment.Center
|
||||||
contentAlignment = Alignment.Center
|
) {
|
||||||
) {
|
LinearProgressIndicator(
|
||||||
LinearProgressIndicator(
|
modifier = Modifier.width(160.dp),
|
||||||
modifier = Modifier.width(160.dp),
|
color = AppColors.main
|
||||||
color = AppColors.main
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
comments.loadState.append is LoadState.Error -> {
|
comments.loadState.append is LoadState.Error -> {
|
||||||
item {
|
item {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(64.dp)
|
.height(64.dp)
|
||||||
.noRippleClickable {
|
.noRippleClickable {
|
||||||
comments.retry()
|
comments.retry()
|
||||||
},
|
},
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "Load comment error, click to retry",
|
text = "Load comment error, click to retry",
|
||||||
color = AppColors.text
|
color = AppColors.text
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
item {
|
||||||
item {
|
Spacer(modifier = Modifier.height(72.dp))
|
||||||
Spacer(modifier = Modifier.height(72.dp))
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package com.aiosman.ravenow.ui.follower
|
package com.aiosman.ravenow.ui.follower
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
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.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
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.material.ExperimentalMaterialApi
|
import androidx.compose.material.ExperimentalMaterialApi
|
||||||
import androidx.compose.material.pullrefresh.PullRefreshIndicator
|
import androidx.compose.material.pullrefresh.PullRefreshIndicator
|
||||||
@@ -15,8 +19,11 @@ import androidx.compose.runtime.LaunchedEffect
|
|||||||
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.res.stringResource
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.paging.compose.collectAsLazyPagingItems
|
import androidx.paging.compose.collectAsLazyPagingItems
|
||||||
import com.aiosman.ravenow.AppState
|
import com.aiosman.ravenow.AppState
|
||||||
@@ -55,39 +62,73 @@ fun FollowerListScreen(userId: Int) {
|
|||||||
) {
|
) {
|
||||||
NoticeScreenHeader(stringResource(R.string.followers_upper), moreIcon = false)
|
NoticeScreenHeader(stringResource(R.string.followers_upper), moreIcon = false)
|
||||||
}
|
}
|
||||||
Box(
|
if (users.itemCount == 0) {
|
||||||
modifier = Modifier
|
Box(
|
||||||
.fillMaxWidth()
|
modifier = Modifier
|
||||||
.weight(1f)
|
.fillMaxSize()
|
||||||
.pullRefresh(refreshState)
|
.padding(top = 188.dp),
|
||||||
) {
|
contentAlignment = Alignment.TopCenter
|
||||||
LazyColumn(
|
|
||||||
modifier = Modifier.fillMaxSize()
|
|
||||||
) {
|
) {
|
||||||
items(users.itemCount) { index ->
|
Column(
|
||||||
users[index]?.let { user ->
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
FollowItem(
|
modifier = Modifier.fillMaxWidth()
|
||||||
avatar = user.avatar,
|
) {
|
||||||
nickname = user.nickName,
|
Image(
|
||||||
userId = user.id,
|
painter = painterResource(id = R.mipmap.rider_pro_followers_empty),
|
||||||
isFollowing = user.isFollowing
|
contentDescription = null,
|
||||||
) {
|
modifier = Modifier.size(140.dp)
|
||||||
scope.launch {
|
)
|
||||||
if (user.isFollowing) {
|
Spacer(modifier = Modifier.size(24.dp))
|
||||||
model.unFollowUser(user.id)
|
androidx.compose.material.Text(
|
||||||
} else {
|
text = "No one's paying attention to you yet",
|
||||||
model.followUser(user.id)
|
color = appColors.text,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
fontWeight = FontWeight.W600
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.size(8.dp))
|
||||||
|
androidx.compose.material.Text(
|
||||||
|
text = "Your vibe attracts your tribe.",
|
||||||
|
color = appColors.text,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
fontWeight = FontWeight.W400
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.weight(1f)
|
||||||
|
.pullRefresh(refreshState)
|
||||||
|
) {
|
||||||
|
LazyColumn(
|
||||||
|
modifier = Modifier.fillMaxSize()
|
||||||
|
) {
|
||||||
|
items(users.itemCount) { index ->
|
||||||
|
users[index]?.let { user ->
|
||||||
|
FollowItem(
|
||||||
|
avatar = user.avatar,
|
||||||
|
nickname = user.nickName,
|
||||||
|
userId = user.id,
|
||||||
|
isFollowing = user.isFollowing
|
||||||
|
) {
|
||||||
|
scope.launch {
|
||||||
|
if (user.isFollowing) {
|
||||||
|
model.unFollowUser(user.id)
|
||||||
|
} else {
|
||||||
|
model.followUser(user.id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PullRefreshIndicator(
|
||||||
|
refreshing = model.isLoading,
|
||||||
|
state = refreshState,
|
||||||
|
modifier = Modifier.align(Alignment.TopCenter)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
PullRefreshIndicator(
|
|
||||||
refreshing = model.isLoading,
|
|
||||||
state = refreshState,
|
|
||||||
modifier = Modifier.align(Alignment.TopCenter)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.foundation.layout.Spacer
|
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.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
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.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
@@ -61,12 +62,14 @@ fun FollowingListScreen(userId: Int) {
|
|||||||
.padding(vertical = 16.dp)
|
.padding(vertical = 16.dp)
|
||||||
) {
|
) {
|
||||||
NoticeScreenHeader(stringResource(R.string.following_upper), moreIcon = false)
|
NoticeScreenHeader(stringResource(R.string.following_upper), moreIcon = false)
|
||||||
|
|
||||||
}
|
}
|
||||||
if(users.itemCount == 0) {
|
if(users.itemCount == 0) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize(),
|
.fillMaxSize()
|
||||||
contentAlignment = Alignment.Center
|
.padding(top=188.dp),
|
||||||
|
contentAlignment = Alignment.TopCenter
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
@@ -77,14 +80,14 @@ fun FollowingListScreen(userId: Int) {
|
|||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier.size(140.dp)
|
modifier = Modifier.size(140.dp)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.size(32.dp))
|
Spacer(modifier = Modifier.size(24.dp))
|
||||||
androidx.compose.material.Text(
|
androidx.compose.material.Text(
|
||||||
text = "You haven't followed anyone yet",
|
text = "You haven't followed anyone yet",
|
||||||
color = appColors.text,
|
color = appColors.text,
|
||||||
fontSize = 16.sp,
|
fontSize = 16.sp,
|
||||||
fontWeight = FontWeight.W600
|
fontWeight = FontWeight.W600
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.size(16.dp))
|
Spacer(modifier = Modifier.size(8.dp))
|
||||||
androidx.compose.material.Text(
|
androidx.compose.material.Text(
|
||||||
text = "Click start your social journey.",
|
text = "Click start your social journey.",
|
||||||
color = appColors.text,
|
color = appColors.text,
|
||||||
@@ -129,6 +132,5 @@ fun FollowingListScreen(userId: Int) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,6 +48,7 @@ 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.layout.ContentScale
|
||||||
import androidx.compose.ui.draw.blur
|
import androidx.compose.ui.draw.blur
|
||||||
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
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
|
||||||
@@ -146,95 +147,95 @@ fun Explore() {
|
|||||||
fun AgentCard2(agentItem: AgentItem) {
|
fun AgentCard2(agentItem: AgentItem) {
|
||||||
val AppColors = LocalAppTheme.current
|
val AppColors = LocalAppTheme.current
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(vertical = 12.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically
|
|
||||||
) {
|
|
||||||
// 左侧头像
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(48.dp)
|
.fillMaxWidth()
|
||||||
.background(Color(0xFFF5F5F5), RoundedCornerShape(24.dp)),
|
.padding(vertical = 12.dp),
|
||||||
contentAlignment = Alignment.Center
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
if (agentItem.avatar.isNotEmpty()) {
|
// 左侧头像
|
||||||
CustomAsyncImage(
|
Box(
|
||||||
imageUrl = agentItem.avatar,
|
modifier = Modifier
|
||||||
contentDescription = "Agent头像",
|
.size(48.dp)
|
||||||
modifier = Modifier
|
.background(Color(0xFFF5F5F5), RoundedCornerShape(24.dp)),
|
||||||
.size(48.dp)
|
contentAlignment = Alignment.Center
|
||||||
.clip(RoundedCornerShape(24.dp)),
|
) {
|
||||||
contentScale = androidx.compose.ui.layout.ContentScale.Crop
|
if (agentItem.avatar.isNotEmpty()) {
|
||||||
|
CustomAsyncImage(
|
||||||
|
imageUrl = agentItem.avatar,
|
||||||
|
contentDescription = "Agent头像",
|
||||||
|
modifier = Modifier
|
||||||
|
.size(48.dp)
|
||||||
|
.clip(RoundedCornerShape(24.dp)),
|
||||||
|
contentScale = androidx.compose.ui.layout.ContentScale.Crop
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Image(
|
||||||
|
painter = painterResource(R.mipmap.rider_pro_agent),
|
||||||
|
contentDescription = "默认头像",
|
||||||
|
modifier = Modifier.size(24.dp),
|
||||||
|
colorFilter = ColorFilter.tint(AppColors.secondaryText)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.width(12.dp))
|
||||||
|
|
||||||
|
// 中间文字内容
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
.padding(end = 8.dp)
|
||||||
|
) {
|
||||||
|
// 标题
|
||||||
|
Text(
|
||||||
|
text = agentItem.title,
|
||||||
|
fontSize = 14.sp,
|
||||||
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W600,
|
||||||
|
color = AppColors.text,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
Image(
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
painter = painterResource(R.mipmap.rider_pro_agent),
|
|
||||||
contentDescription = "默认头像",
|
// 描述
|
||||||
modifier = Modifier.size(24.dp),
|
Text(
|
||||||
colorFilter = ColorFilter.tint(AppColors.secondaryText)
|
text = agentItem.desc,
|
||||||
|
fontSize = 12.sp,
|
||||||
|
color = AppColors.secondaryText,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 右侧聊天按钮
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(width = 60.dp, height = 32.dp)
|
||||||
|
.background(
|
||||||
|
color = Color(0X147c7480),
|
||||||
|
shape = RoundedCornerShape(8.dp)
|
||||||
|
)
|
||||||
|
.clickable {
|
||||||
|
// 聊天逻辑
|
||||||
|
},
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "聊天",
|
||||||
|
fontSize = 12.sp,
|
||||||
|
color = AppColors.text,
|
||||||
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.width(12.dp))
|
|
||||||
|
|
||||||
// 中间文字内容
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.weight(1f)
|
|
||||||
.padding(end = 8.dp)
|
|
||||||
) {
|
|
||||||
// 标题
|
|
||||||
Text(
|
|
||||||
text = agentItem.title,
|
|
||||||
fontSize = 14.sp,
|
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W600,
|
|
||||||
color = AppColors.text,
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
|
||||||
|
|
||||||
// 描述
|
|
||||||
Text(
|
|
||||||
text = agentItem.desc,
|
|
||||||
fontSize = 12.sp,
|
|
||||||
color = AppColors.secondaryText,
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 右侧聊天按钮
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.size(width = 60.dp, height = 32.dp)
|
|
||||||
.background(
|
|
||||||
color = Color(0X147c7480),
|
|
||||||
shape = RoundedCornerShape(8.dp)
|
|
||||||
)
|
|
||||||
.clickable {
|
|
||||||
// 聊天逻辑
|
|
||||||
},
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = "聊天",
|
|
||||||
fontSize = 12.sp,
|
|
||||||
color = AppColors.text,
|
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AgentPage(agentItems: List<AgentItem>, page: Int) {
|
fun AgentPage(agentItems: List<AgentItem>, page: Int, modifier: Modifier = Modifier) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(horizontal = 0.dp)
|
.padding(horizontal = 0.dp)
|
||||||
) {
|
) {
|
||||||
@@ -268,20 +269,27 @@ fun Explore() {
|
|||||||
) {
|
) {
|
||||||
HorizontalPager(
|
HorizontalPager(
|
||||||
state = pagerState,
|
state = pagerState,
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
contentPadding = androidx.compose.foundation.layout.PaddingValues(horizontal = 4.dp),
|
||||||
|
pageSpacing = 0.dp
|
||||||
) { page ->
|
) { page ->
|
||||||
// 计算当前页面的偏移量
|
// 计算当前页面的偏移量
|
||||||
val pageOffset = (
|
val pageOffset = (
|
||||||
(pagerState.currentPage - page) + pagerState
|
(pagerState.currentPage - page) + pagerState
|
||||||
.currentPageOffsetFraction
|
.currentPageOffsetFraction
|
||||||
).coerceIn(-1f, 1f)
|
).coerceIn(-1f, 1f)
|
||||||
|
|
||||||
// 根据偏移量计算缩放比例
|
// 根据偏移量计算缩放比例
|
||||||
val scale = 1f - (0.1f * kotlin.math.abs(pageOffset))
|
val scale = 1f - (0.1f * kotlin.math.abs(pageOffset))
|
||||||
|
|
||||||
AgentPage(
|
AgentPage(
|
||||||
agentItems = agentItems.drop(page * itemsPerPage).take(itemsPerPage),
|
agentItems = agentItems.drop(page * itemsPerPage).take(itemsPerPage),
|
||||||
page = page
|
page = page,
|
||||||
|
modifier = Modifier
|
||||||
|
.graphicsLayer {
|
||||||
|
scaleX = scale
|
||||||
|
scaleY = scale
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,12 +427,12 @@ fun Explore() {
|
|||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BannerCard(bannerItem: BannerItem) {
|
fun BannerCard(bannerItem: BannerItem, modifier: Modifier = Modifier) {
|
||||||
val AppColors = LocalAppTheme.current
|
val AppColors = LocalAppTheme.current
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(horizontal = 0.dp),
|
.padding(horizontal = 0.dp),
|
||||||
shape = RoundedCornerShape(20.dp),
|
shape = RoundedCornerShape(20.dp),
|
||||||
@@ -465,22 +473,22 @@ fun Explore() {
|
|||||||
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),
|
||||||
colorFilter = ColorFilter.tint(Color.White)
|
colorFilter = ColorFilter.tint(Color.White)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(4.dp))
|
Spacer(modifier = Modifier.width(4.dp))
|
||||||
Text(
|
Text(
|
||||||
text = "${bannerItem.userCount}人在聊",
|
text = "${bannerItem.userCount}人在聊",
|
||||||
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
|
||||||
)*/
|
)*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// 底部:标题和描述
|
// 底部:标题和描述
|
||||||
@@ -492,7 +500,7 @@ fun Explore() {
|
|||||||
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis,
|
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis,
|
||||||
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)
|
modifier = Modifier.padding(start = 16.dp)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
Text(
|
Text(
|
||||||
@@ -508,81 +516,81 @@ fun Explore() {
|
|||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
.background(brush = androidx.compose.ui.graphics.Brush.verticalGradient(
|
.background(brush = androidx.compose.ui.graphics.Brush.verticalGradient(
|
||||||
colors = listOf(
|
colors = listOf(
|
||||||
Color(0x00000000), // 底部颜色(透明)
|
Color(0x00000000), // 底部颜色(透明)
|
||||||
Color(0x33000000), // 顶部颜色
|
Color(0x33000000), // 顶部颜色
|
||||||
|
|
||||||
)
|
)
|
||||||
)),
|
)),
|
||||||
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.SpaceBetween,
|
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.SpaceBetween,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Row( modifier = Modifier
|
Row( modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(16.dp),
|
.padding(16.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically){
|
verticalAlignment = Alignment.CenterVertically){
|
||||||
// 左侧头像
|
// 左侧头像
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(24.dp)
|
.size(24.dp)
|
||||||
.background(
|
.background(
|
||||||
Color.White.copy(alpha = 0.2f),
|
Color.White.copy(alpha = 0.2f),
|
||||||
RoundedCornerShape(16.dp)
|
RoundedCornerShape(16.dp)
|
||||||
)
|
|
||||||
|
|
||||||
) {
|
|
||||||
CustomAsyncImage(
|
|
||||||
context = context,
|
|
||||||
imageUrl = bannerItem.imageUrl,
|
|
||||||
contentDescription = "agent Image",
|
|
||||||
contentScale = ContentScale.Crop,
|
|
||||||
modifier = Modifier.fillMaxSize()
|
|
||||||
.clip(RoundedCornerShape(24.dp)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 中间信息区域(占比1)
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.weight(1f)
|
|
||||||
.padding(horizontal = 8.dp)
|
|
||||||
) {
|
|
||||||
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,
|
|
||||||
maxLines = 1,
|
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W400,
|
|
||||||
modifier = Modifier.padding(top = 2.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 右侧进入按钮
|
) {
|
||||||
Box(
|
CustomAsyncImage(
|
||||||
modifier = Modifier
|
context = context,
|
||||||
.width(69.dp)
|
imageUrl = bannerItem.imageUrl,
|
||||||
.height(29.dp)
|
contentDescription = "agent Image",
|
||||||
.background(
|
contentScale = ContentScale.Crop,
|
||||||
color = Color(0x7dffffff),
|
modifier = Modifier.fillMaxSize()
|
||||||
shape = RoundedCornerShape(8.dp)
|
.clip(RoundedCornerShape(24.dp)))
|
||||||
)
|
}
|
||||||
.clickable {
|
|
||||||
// 进入房间逻辑
|
// 中间信息区域(占比1)
|
||||||
},
|
Column(
|
||||||
contentAlignment = Alignment.Center
|
modifier = Modifier
|
||||||
) {
|
.weight(1f)
|
||||||
Text(
|
.padding(horizontal = 8.dp)
|
||||||
text = "进入",
|
) {
|
||||||
fontSize = 14.sp,
|
Text(
|
||||||
color = Color.White,
|
text = bannerItem.agentName,
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W600
|
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,
|
||||||
|
maxLines = 1,
|
||||||
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W400,
|
||||||
|
modifier = Modifier.padding(top = 2.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 右侧进入按钮
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.width(69.dp)
|
||||||
|
.height(29.dp)
|
||||||
|
.background(
|
||||||
|
color = Color(0x7dffffff),
|
||||||
|
shape = RoundedCornerShape(8.dp)
|
||||||
)
|
)
|
||||||
}
|
.clickable {
|
||||||
|
// 进入房间逻辑
|
||||||
|
},
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "进入",
|
||||||
|
fontSize = 14.sp,
|
||||||
|
color = Color.White,
|
||||||
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W600
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,15 +612,15 @@ fun Explore() {
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
// 可以添加更多不同高度的内容项
|
// 第一块区域
|
||||||
item {
|
item {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(vertical = 6.dp),
|
.padding(vertical = 6.dp),
|
||||||
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.SpaceEvenly
|
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.SpaceBetween
|
||||||
) {
|
) {
|
||||||
// 第一个
|
// 第一个 - 靠左显示
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable {
|
.clickable {
|
||||||
@@ -642,81 +650,75 @@ fun Explore() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 第二个
|
// 中间两个 - 平均分布
|
||||||
Column(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier.weight(1f),
|
||||||
.clickable {
|
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.SpaceEvenly
|
||||||
navController.navigate(
|
|
||||||
NavigationRoute.AddAgent.route)
|
|
||||||
},
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
) {
|
) {
|
||||||
Box(
|
// 第二个
|
||||||
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(64.dp)
|
.clickable {
|
||||||
.background(Color(0xFF94f9f2), RoundedCornerShape(24.dp)),
|
navController.navigate(
|
||||||
contentAlignment = Alignment.Center
|
NavigationRoute.AddAgent.route)
|
||||||
|
},
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Image(
|
Box(
|
||||||
painter = painterResource(R.mipmap.rider_pro_agent),
|
modifier = Modifier
|
||||||
contentDescription = "创建智能体",
|
.size(64.dp)
|
||||||
modifier = Modifier.size(24.dp),
|
.background(Color(0xFF94f9f2), RoundedCornerShape(24.dp)),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
painter = painterResource(R.mipmap.rider_pro_agent),
|
||||||
|
contentDescription = "创建智能体",
|
||||||
|
modifier = Modifier.size(24.dp),
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
)
|
|
||||||
=======
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.size(8.dp))
|
Spacer(modifier = Modifier.size(8.dp))
|
||||||
|
Text(
|
||||||
|
text = "创建Agent",
|
||||||
|
fontSize = 12.sp,
|
||||||
|
color = AppColors.text,
|
||||||
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 第三个
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.clickable {
|
||||||
|
NewPostViewModel.asNewPost()
|
||||||
|
navController.navigate("NewPost")
|
||||||
|
},
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(64.dp)
|
||||||
|
.background(Color(0xFFfafd5d), RoundedCornerShape(24.dp)),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
painter = painterResource(R.mipmap.rider_pro_release),
|
||||||
|
contentDescription = "发布动态",
|
||||||
|
modifier = Modifier.size(24.dp),
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Spacer(modifier = Modifier.size(8.dp))
|
||||||
Text(
|
Text(
|
||||||
text = "发布动态",
|
text = "发布动态",
|
||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
color = AppColors.text,
|
color = AppColors.text,
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
||||||
)
|
)
|
||||||
>>>>>>> upstream/main
|
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.size(8.dp))
|
|
||||||
Text(
|
|
||||||
text = "创建Agent",
|
|
||||||
fontSize = 12.sp,
|
|
||||||
color = AppColors.text,
|
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 第三个
|
// 第四个 - 靠右显示
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.clickable {
|
|
||||||
NewPostViewModel.asNewPost()
|
|
||||||
navController.navigate("NewPost")
|
|
||||||
},
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.size(64.dp)
|
|
||||||
.background(Color(0xFFfafd5d), RoundedCornerShape(24.dp)),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Image(
|
|
||||||
painter = painterResource(R.mipmap.rider_pro_release),
|
|
||||||
contentDescription = "发布动态",
|
|
||||||
modifier = Modifier.size(24.dp),
|
|
||||||
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Spacer(modifier = Modifier.size(8.dp))
|
|
||||||
Text(
|
|
||||||
text = "发布动态",
|
|
||||||
fontSize = 12.sp,
|
|
||||||
color = AppColors.text,
|
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W500
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 第四个
|
|
||||||
Column(
|
Column(
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
@@ -731,7 +733,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(
|
||||||
@@ -744,103 +746,96 @@ fun Explore() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun BannerSection(bannerItems: List<BannerItem>) {
|
fun BannerSection(bannerItems: List<BannerItem>) {
|
||||||
val AppColors = LocalAppTheme.current
|
val AppColors = LocalAppTheme.current
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
val pagerState = rememberPagerState(pageCount = { bannerItems.size })
|
val pagerState = rememberPagerState(pageCount = { bannerItems.size })
|
||||||
|
|
||||||
// 预加载banner图片
|
// 预加载banner图片
|
||||||
LaunchedEffect(bannerItems) {
|
LaunchedEffect(bannerItems) {
|
||||||
bannerItems.forEach { bannerItem ->
|
bannerItems.forEach { bannerItem ->
|
||||||
if (bannerItem.backgroundImageUrl.isNotEmpty()) {
|
if (bannerItem.backgroundImageUrl.isNotEmpty()) {
|
||||||
// 预加载背景图片
|
// 预加载背景图片
|
||||||
com.aiosman.ravenow.utils.Utils.getImageLoader(context).enqueue(
|
com.aiosman.ravenow.utils.Utils.getImageLoader(context).enqueue(
|
||||||
coil.request.ImageRequest.Builder(context)
|
coil.request.ImageRequest.Builder(context)
|
||||||
.data(bannerItem.backgroundImageUrl)
|
.data(bannerItem.backgroundImageUrl)
|
||||||
.memoryCachePolicy(coil.request.CachePolicy.ENABLED)
|
.memoryCachePolicy(coil.request.CachePolicy.ENABLED)
|
||||||
.diskCachePolicy(coil.request.CachePolicy.ENABLED)
|
.diskCachePolicy(coil.request.CachePolicy.ENABLED)
|
||||||
.build()
|
.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 {
|
|
||||||
// Banner内容
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(362.dp)
|
|
||||||
) {
|
|
||||||
HorizontalPager(
|
|
||||||
state = pagerState,
|
|
||||||
<<<<<<< HEAD
|
|
||||||
modifier = Modifier.fillMaxSize()
|
|
||||||
) { page ->
|
|
||||||
val bannerItem = bannerItems[page]
|
|
||||||
BannerCard(bannerItem = bannerItem)
|
|
||||||
=======
|
|
||||||
modifier = Modifier.fillMaxSize(),
|
|
||||||
contentPadding = androidx.compose.foundation.layout.PaddingValues(horizontal = 4.dp),
|
|
||||||
) { page ->
|
|
||||||
val bannerItem = bannerItems[page]
|
|
||||||
|
|
||||||
// 计算当前页面的偏移量
|
|
||||||
val pageOffset = (
|
|
||||||
(pagerState.currentPage - page) + pagerState
|
|
||||||
.currentPageOffsetFraction
|
|
||||||
).coerceIn(-1f, 1f)
|
|
||||||
|
|
||||||
// 根据偏移量计算缩放比例
|
|
||||||
val scale = 1f - (0.1f * kotlin.math.abs(pageOffset))
|
|
||||||
|
|
||||||
BannerCard(
|
|
||||||
bannerItem = bannerItem,
|
|
||||||
modifier = Modifier
|
|
||||||
.graphicsLayer {
|
|
||||||
scaleX = scale
|
|
||||||
scaleY = scale
|
|
||||||
}
|
|
||||||
)
|
|
||||||
>>>>>>> upstream/main
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 指示器
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(top = 12.dp),
|
|
||||||
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.Center
|
|
||||||
) {
|
|
||||||
bannerItems.forEachIndexed { index, _ ->
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(horizontal = 4.dp)
|
|
||||||
.size(3.dp)
|
|
||||||
.background(
|
|
||||||
color = if (pagerState.currentPage == index) AppColors.main else AppColors.secondaryText.copy(alpha = 0.3f),
|
|
||||||
shape = androidx.compose.foundation.shape.CircleShape
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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 {
|
||||||
|
// Banner内容
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(362.dp)
|
||||||
|
) {
|
||||||
|
HorizontalPager(
|
||||||
|
state = pagerState,
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
contentPadding = androidx.compose.foundation.layout.PaddingValues(horizontal = 4.dp),
|
||||||
|
) { page ->
|
||||||
|
val bannerItem = bannerItems[page]
|
||||||
|
|
||||||
|
// 计算当前页面的偏移量
|
||||||
|
val pageOffset = (
|
||||||
|
(pagerState.currentPage - page) + pagerState
|
||||||
|
.currentPageOffsetFraction
|
||||||
|
).coerceIn(-1f, 1f)
|
||||||
|
|
||||||
|
// 根据偏移量计算缩放比例
|
||||||
|
val scale = 1f - (0.1f * kotlin.math.abs(pageOffset))
|
||||||
|
|
||||||
|
BannerCard(
|
||||||
|
bannerItem = bannerItem,
|
||||||
|
modifier = Modifier
|
||||||
|
.graphicsLayer {
|
||||||
|
scaleX = scale
|
||||||
|
scaleY = scale
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 指示器
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(top = 12.dp),
|
||||||
|
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.Center
|
||||||
|
) {
|
||||||
|
bannerItems.forEachIndexed { index, _ ->
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 4.dp)
|
||||||
|
.size(3.dp)
|
||||||
|
.background(
|
||||||
|
color = if (pagerState.currentPage == index) AppColors.main else AppColors.secondaryText.copy(alpha = 0.3f),
|
||||||
|
shape = androidx.compose.foundation.shape.CircleShape
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 第二块区域:Banner
|
// 第二块区域:Banner
|
||||||
@@ -853,7 +848,7 @@ fun Explore() {
|
|||||||
// 标题
|
// 标题
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = Modifier.padding(bottom = 30.dp)
|
modifier = Modifier.padding(bottom = 12.dp)
|
||||||
) {
|
) {
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(R.mipmap.rider_pro_fire2),
|
painter = painterResource(R.mipmap.rider_pro_fire2),
|
||||||
@@ -891,12 +886,12 @@ fun Explore() {
|
|||||||
contentDescription = "agent",
|
contentDescription = "agent",
|
||||||
modifier = Modifier.size(28.dp),
|
modifier = Modifier.size(28.dp),
|
||||||
|
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(4.dp))
|
Spacer(modifier = Modifier.width(4.dp))
|
||||||
Text(
|
Text(
|
||||||
text = "推荐给你的Agent",
|
text = "推荐给你的智能体",
|
||||||
fontSize = 20.sp,
|
fontSize = 16.sp,
|
||||||
fontWeight = androidx.compose.ui.text.font.FontWeight.W900,
|
fontWeight = androidx.compose.ui.text.font.FontWeight.W600,
|
||||||
color = AppColors.text
|
color = AppColors.text
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -921,7 +916,7 @@ fun Explore() {
|
|||||||
Image(
|
Image(
|
||||||
painter = painterResource(R.mipmap.rider_pro_hot_room),
|
painter = painterResource(R.mipmap.rider_pro_hot_room),
|
||||||
contentDescription = "chat room",
|
contentDescription = "chat room",
|
||||||
modifier = Modifier.size(28.dp),
|
modifier = Modifier.size(24.dp),
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(4.dp))
|
Spacer(modifier = Modifier.width(4.dp))
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
Reference in New Issue
Block a user