防抖调整
This commit is contained in:
@@ -23,26 +23,36 @@ import androidx.compose.ui.unit.sp
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.ui.post.NewPostViewModel
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncedNavigation
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncedState
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
|
||||
@Composable
|
||||
fun AddPage(){
|
||||
val navController = LocalNavController.current
|
||||
val debouncer = rememberDebouncedNavigation()
|
||||
Column(modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(Color.Black)) {
|
||||
AddBtn(icon = R.drawable.rider_pro_icon_rider_share, text = "Rave NowShare") {
|
||||
NewPostViewModel.asNewPost()
|
||||
debouncer {
|
||||
navController.navigate("NewPost")
|
||||
}
|
||||
}
|
||||
// AddBtn(icon = R.drawable.rider_pro_location_create, text = "Location Create")
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun AddBtn(@DrawableRes icon: Int, text: String,onClick: (() -> Unit)? = {}){
|
||||
val (isDebouncing, startDebounce, resetDebounce) = rememberDebouncedState()
|
||||
Row (modifier = Modifier
|
||||
.fillMaxWidth().padding(24.dp).clickable {
|
||||
if (!isDebouncing) {
|
||||
startDebounce()
|
||||
onClick?.invoke()
|
||||
}
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically){
|
||||
Image(
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.NavigationRoute
|
||||
import com.aiosman.ravenow.ui.composables.AgentCard
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
@@ -117,20 +118,26 @@ fun HotAgent() {
|
||||
key = { idx -> idx }
|
||||
) { idx ->
|
||||
val agentItem = agentList[idx]
|
||||
val chatDebouncer = rememberDebouncer()
|
||||
val avatarDebouncer = rememberDebouncer()
|
||||
AgentCard(
|
||||
agentEntity = agentItem,
|
||||
onClick = {
|
||||
chatDebouncer {
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CHAT_WITH_AGENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
model.createSingleChat(agentItem.openId)
|
||||
model.goToChatAi(agentItem.openId,navController)
|
||||
model.goToChatAi(agentItem.openId, navController)
|
||||
}
|
||||
}
|
||||
},
|
||||
onAvatarClick = {
|
||||
avatarDebouncer {
|
||||
model.goToProfile(agentItem.openId, navController)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.NavigationRoute
|
||||
import com.aiosman.ravenow.ui.composables.AgentCard
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
import com.aiosman.ravenow.ui.index.tabs.message.tab.GroupChatItem
|
||||
import com.aiosman.ravenow.ui.index.tabs.message.tab.GroupChatListViewModel
|
||||
import java.util.UUID
|
||||
@@ -108,9 +109,13 @@ fun MineAgent() {
|
||||
|
||||
items(count = agentList.itemCount, key = { index -> agentList[index]?.id ?: index }) { index ->
|
||||
agentList[index]?.let { agent ->
|
||||
val chatDebouncer = rememberDebouncer()
|
||||
val avatarDebouncer = rememberDebouncer()
|
||||
|
||||
AgentCard(
|
||||
agentEntity = agent,
|
||||
onClick = {
|
||||
chatDebouncer {
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CHAT_WITH_AGENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
@@ -118,14 +123,18 @@ fun MineAgent() {
|
||||
model.createSingleChat(agent.openId)
|
||||
model.goToChatAi(agent.openId,navController)
|
||||
}
|
||||
}
|
||||
},
|
||||
onAvatarClick = {
|
||||
avatarDebouncer {
|
||||
model.goToProfile(agent.openId, navController)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 加载更多指示器
|
||||
if (agentList.loadState.append is LoadState.Loading) {
|
||||
item {
|
||||
|
||||
@@ -65,6 +65,8 @@ import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.ravenow.ui.composables.StatusBarSpacer
|
||||
import com.aiosman.ravenow.ui.composables.TabItem
|
||||
import com.aiosman.ravenow.ui.composables.TabSpacer
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncedNavigation
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
import com.aiosman.ravenow.ui.follower.FollowerNoticeViewModel
|
||||
import com.aiosman.ravenow.ui.index.tabs.message.tab.AgentChatListScreen
|
||||
import com.aiosman.ravenow.ui.index.tabs.message.tab.AgentChatListViewModel
|
||||
@@ -84,6 +86,7 @@ import kotlinx.coroutines.launch
|
||||
@OptIn(ExperimentalMaterialApi::class, ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun NotificationsScreen() {
|
||||
val debouncer = rememberDebouncer()
|
||||
// 计算总未读消息数
|
||||
val totalUnreadCount = AgentChatListViewModel.totalUnreadCount +
|
||||
GroupChatListViewModel.totalUnreadCount +
|
||||
@@ -167,12 +170,15 @@ fun NotificationsScreen() {
|
||||
modifier = Modifier
|
||||
.size(24.dp)
|
||||
.noRippleClickable {
|
||||
debouncer {
|
||||
navController.navigate(NavigationRoute.CreateGroupChat.route)
|
||||
}
|
||||
},
|
||||
colorFilter = ColorFilter.tint(AppColors.text)
|
||||
)
|
||||
|
||||
|
||||
|
||||
}
|
||||
// 搜索栏//
|
||||
Box(
|
||||
@@ -219,12 +225,17 @@ fun NotificationsScreen() {
|
||||
.padding(horizontal = 16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
) {
|
||||
val likeDebouncer = rememberDebouncer()
|
||||
val followDebouncer = rememberDebouncer()
|
||||
val commentDebouncer = rememberDebouncer()
|
||||
|
||||
NotificationIndicator(
|
||||
MessageListViewModel.likeNoticeCount,
|
||||
R.mipmap.rider_pro_like,
|
||||
stringResource(R.string.like_upper),
|
||||
Color(0xFFFAFD5D)
|
||||
) {
|
||||
likeDebouncer {
|
||||
if (MessageListViewModel.likeNoticeCount > 0) {
|
||||
// 刷新点赞消息列表
|
||||
LikeNoticeViewModel.isFirstLoad = true
|
||||
@@ -233,12 +244,14 @@ fun NotificationsScreen() {
|
||||
}
|
||||
navController.navigate(NavigationRoute.Likes.route)
|
||||
}
|
||||
}
|
||||
NotificationIndicator(
|
||||
MessageListViewModel.followNoticeCount,
|
||||
R.mipmap.rider_pro_followers,
|
||||
stringResource(R.string.followers_upper),
|
||||
Color(0xFFF470FE)
|
||||
) {
|
||||
followDebouncer {
|
||||
if (MessageListViewModel.followNoticeCount > 0) {
|
||||
// 刷新关注消息列表
|
||||
FollowerNoticeViewModel.isFirstLoad = true
|
||||
@@ -246,15 +259,18 @@ fun NotificationsScreen() {
|
||||
}
|
||||
navController.navigate(NavigationRoute.Followers.route)
|
||||
}
|
||||
}
|
||||
NotificationIndicator(
|
||||
MessageListViewModel.commentNoticeCount,
|
||||
R.mipmap.rider_pro_comment,
|
||||
stringResource(R.string.comment).uppercase(),
|
||||
Color(0xFF6246FF)
|
||||
) {
|
||||
commentDebouncer {
|
||||
navController.navigate(NavigationRoute.CommentNoticeScreen.route)
|
||||
}
|
||||
}
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
@@ -264,15 +280,19 @@ fun NotificationsScreen() {
|
||||
horizontalArrangement = Arrangement.Start,
|
||||
verticalAlignment = Alignment.Bottom
|
||||
) {
|
||||
val tabDebouncer = rememberDebouncer()
|
||||
|
||||
Box {
|
||||
TabItem(
|
||||
text = stringResource(R.string.chat_ai),
|
||||
isSelected = pagerState.currentPage == 0,
|
||||
onClick = {
|
||||
tabDebouncer {
|
||||
scope.launch {
|
||||
pagerState.animateScrollToPage(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// 智能体未读消息红点
|
||||
@@ -295,10 +315,12 @@ fun NotificationsScreen() {
|
||||
text = stringResource(R.string.chat_group),
|
||||
isSelected = pagerState.currentPage == 1,
|
||||
onClick = {
|
||||
tabDebouncer {
|
||||
scope.launch {
|
||||
pagerState.animateScrollToPage(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// 群聊未读消息红点
|
||||
@@ -321,10 +343,12 @@ fun NotificationsScreen() {
|
||||
text = stringResource(R.string.chat_friend),
|
||||
isSelected = pagerState.currentPage == 2,
|
||||
onClick = {
|
||||
tabDebouncer {
|
||||
scope.launch {
|
||||
pagerState.animateScrollToPage(2)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// 朋友未读消息红点
|
||||
@@ -378,6 +402,7 @@ fun NotificationIndicator(
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
val AppColors = LocalAppTheme.current
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
) {
|
||||
@@ -435,3 +460,5 @@ fun NotificationIndicator(
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.NavigationRoute
|
||||
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
import com.aiosman.ravenow.utils.NetworkUtils
|
||||
|
||||
@@ -190,13 +191,16 @@ fun AgentChatItem(
|
||||
onChatClick: (AgentConversation) -> Unit = {}
|
||||
) {
|
||||
val AppColors = LocalAppTheme.current
|
||||
|
||||
val chatDebouncer = rememberDebouncer()
|
||||
val avatarDebouncer = rememberDebouncer()
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
.noRippleClickable {
|
||||
chatDebouncer {
|
||||
onChatClick(conversation)
|
||||
}
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
@@ -209,8 +213,10 @@ fun AgentChatItem(
|
||||
.size(48.dp)
|
||||
.clip(RoundedCornerShape(48.dp))
|
||||
.noRippleClickable {
|
||||
avatarDebouncer {
|
||||
onUserAvatarClick(conversation)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
import com.aiosman.ravenow.utils.NetworkUtils
|
||||
|
||||
@@ -169,13 +170,17 @@ fun FriendChatItem(
|
||||
onChatClick: (FriendConversation) -> Unit = {}
|
||||
) {
|
||||
val AppColors = LocalAppTheme.current
|
||||
val chatDebouncer = rememberDebouncer()
|
||||
val avatarDebouncer = rememberDebouncer()
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
.noRippleClickable {
|
||||
chatDebouncer {
|
||||
onChatClick(conversation)
|
||||
}
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
@@ -188,8 +193,10 @@ fun FriendChatItem(
|
||||
.size(48.dp)
|
||||
.clip(RoundedCornerShape(48.dp))
|
||||
.noRippleClickable {
|
||||
avatarDebouncer {
|
||||
onUserAvatarClick(conversation)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -259,3 +266,4 @@ fun FriendChatItem(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
import com.aiosman.ravenow.utils.NetworkUtils
|
||||
|
||||
@@ -172,14 +173,18 @@ fun GroupChatItem(
|
||||
onChatClick: (GroupConversation) -> Unit = {}
|
||||
) {
|
||||
val AppColors = LocalAppTheme.current
|
||||
val chatDebouncer = rememberDebouncer()
|
||||
val avatarDebouncer = rememberDebouncer()
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 24.dp, vertical = 12.dp)
|
||||
.noRippleClickable {
|
||||
chatDebouncer {
|
||||
onChatClick(conversation)
|
||||
}
|
||||
}
|
||||
) {
|
||||
Box {
|
||||
CustomAsyncImage(
|
||||
@@ -190,8 +195,10 @@ fun GroupChatItem(
|
||||
.size(48.dp)
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.noRippleClickable {
|
||||
avatarDebouncer {
|
||||
onGroupAvatarClick(conversation)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -261,3 +268,4 @@ fun GroupChatItem(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.aiosman.ravenow.GuestLoginCheckOutScene
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.ui.NavigationRoute
|
||||
import com.aiosman.ravenow.ui.composables.MomentCard
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
@@ -101,8 +102,16 @@ fun Dynamic() {
|
||||
//处理下标越界
|
||||
if (idx < 0 || idx >= moments.size) return@items
|
||||
val momentItem = moments[idx] ?: return@items
|
||||
MomentCard(momentEntity = momentItem,
|
||||
|
||||
val commentDebouncer = rememberDebouncer()
|
||||
val likeDebouncer = rememberDebouncer()
|
||||
val favoriteDebouncer = rememberDebouncer()
|
||||
val followDebouncer = rememberDebouncer()
|
||||
|
||||
MomentCard(
|
||||
momentEntity = momentItem,
|
||||
onAddComment = {
|
||||
commentDebouncer {
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.COMMENT_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
@@ -111,8 +120,10 @@ fun Dynamic() {
|
||||
model.onAddComment(momentItem.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onLikeClick = {
|
||||
likeDebouncer {
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
@@ -125,8 +136,10 @@ fun Dynamic() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onFavoriteClick = {
|
||||
favoriteDebouncer {
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
@@ -139,20 +152,22 @@ fun Dynamic() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onFollowClick = {
|
||||
followDebouncer {
|
||||
// 检查游客模式,如果是游客则跳转登录
|
||||
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.FOLLOW_USER)) {
|
||||
navController.navigate(NavigationRoute.Login.route)
|
||||
} else {
|
||||
model.followAction(momentItem)
|
||||
}
|
||||
}
|
||||
},
|
||||
showFollowButton = true
|
||||
)
|
||||
}
|
||||
}
|
||||
PullRefreshIndicator(model.refreshing, state, Modifier.align(Alignment.TopCenter))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.NavigationRoute
|
||||
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.ravenow.ui.composables.StatusBarSpacer
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
import com.aiosman.ravenow.ui.index.tabs.search.SearchViewModel
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
import com.aiosman.ravenow.ui.navigateToPost
|
||||
@@ -130,18 +131,21 @@ fun DiscoverView() {
|
||||
// contentPadding = PaddingValues(8.dp)
|
||||
) {
|
||||
items(moments) { momentItem ->
|
||||
val debouncer = rememberDebouncer()
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(1f)
|
||||
.padding(2.dp)
|
||||
.noRippleClickable {
|
||||
debouncer {
|
||||
navController.navigateToPost(
|
||||
id = momentItem.id,
|
||||
highlightCommentId = 0,
|
||||
initImagePagerIndex = 0
|
||||
)
|
||||
}
|
||||
}
|
||||
) {
|
||||
CustomAsyncImage(
|
||||
imageUrl = momentItem.images[0].thumbnail,
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.aiosman.ravenow.AppState
|
||||
import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.composables.MomentCard
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
@@ -86,6 +87,7 @@ fun TimelineMomentsList() {
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
val exploreDebouncer = rememberDebouncer()
|
||||
Image(
|
||||
painter = painterResource(
|
||||
id = if(AppState.darkMode) R.mipmap.qst_gz_qs_as_img
|
||||
@@ -109,7 +111,10 @@ fun TimelineMomentsList() {
|
||||
)
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
ExploreButton(
|
||||
onClick = { /* TODO: 添加点击事件处理 */ }
|
||||
onClick = {
|
||||
exploreDebouncer {
|
||||
/* TODO: 添加点击事件处理 */
|
||||
} }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -128,14 +133,22 @@ fun TimelineMomentsList() {
|
||||
key = { idx -> moments.getOrNull(idx)?.id ?: idx }
|
||||
) { idx ->
|
||||
moments.getOrNull(idx)?.let { momentItem ->
|
||||
val commentDebouncer = rememberDebouncer()
|
||||
val likeDebouncer = rememberDebouncer()
|
||||
val favoriteDebouncer = rememberDebouncer()
|
||||
val followDebouncer = rememberDebouncer()
|
||||
|
||||
MomentCard(
|
||||
momentEntity = momentItem,
|
||||
onAddComment = {
|
||||
commentDebouncer {
|
||||
scope.launch {
|
||||
model.onAddComment(momentItem.id)
|
||||
}
|
||||
}
|
||||
},
|
||||
onLikeClick = {
|
||||
likeDebouncer {
|
||||
scope.launch {
|
||||
if (momentItem.liked) {
|
||||
model.dislikeMoment(momentItem.id)
|
||||
@@ -143,8 +156,10 @@ fun TimelineMomentsList() {
|
||||
model.likeMoment(momentItem.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onFavoriteClick = {
|
||||
favoriteDebouncer {
|
||||
scope.launch {
|
||||
if (momentItem.isFavorite) {
|
||||
model.unfavoriteMoment(momentItem.id)
|
||||
@@ -152,14 +167,18 @@ fun TimelineMomentsList() {
|
||||
model.favoriteMoment(momentItem.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onFollowClick = {
|
||||
followDebouncer {
|
||||
model.followAction(momentItem)
|
||||
}
|
||||
},
|
||||
showFollowButton = false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
PullRefreshIndicator(model.refreshing, state, Modifier.align(Alignment.TopCenter))
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import androidx.compose.foundation.lazy.grid.rememberLazyGridState
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import com.aiosman.ravenow.AppState
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
|
||||
@Composable
|
||||
fun GalleryItem(
|
||||
@@ -46,6 +47,7 @@ fun GalleryItem(
|
||||
) {
|
||||
val navController = LocalNavController.current
|
||||
val AppColors = LocalAppTheme.current
|
||||
val debouncer = rememberDebouncer()
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
@@ -65,10 +67,12 @@ fun GalleryItem(
|
||||
}
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.noRippleClickable {
|
||||
debouncer {
|
||||
navController.navigateToPost(
|
||||
moment.id
|
||||
)
|
||||
}
|
||||
}
|
||||
) {
|
||||
// 检查图片列表是否为空
|
||||
if (moment.images.isEmpty()) {
|
||||
@@ -116,6 +120,7 @@ fun GalleryItem(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
fun GalleryGrid(
|
||||
moments: List<MomentEntity>
|
||||
@@ -123,6 +128,7 @@ fun GalleryGrid(
|
||||
val navController = LocalNavController.current
|
||||
val AppColors = LocalAppTheme.current
|
||||
val gridState = rememberLazyGridState()
|
||||
val debouncer = rememberDebouncer()
|
||||
|
||||
if (moments.isEmpty()) {
|
||||
Column(
|
||||
@@ -166,18 +172,21 @@ fun GalleryGrid(
|
||||
) {
|
||||
itemsIndexed(moments) { idx, moment ->
|
||||
if (moment != null) {
|
||||
val itemDebouncer = rememberDebouncer()
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(1f)
|
||||
.padding(2.dp)
|
||||
.noRippleClickable {
|
||||
itemDebouncer {
|
||||
navController.navigateToPost(
|
||||
id = moment.id,
|
||||
highlightCommentId = 0,
|
||||
initImagePagerIndex = 0
|
||||
)
|
||||
}
|
||||
}
|
||||
) {
|
||||
CustomAsyncImage(
|
||||
imageUrl = moment.images[0].thumbnail,
|
||||
@@ -208,3 +217,4 @@ fun GalleryGrid(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
|
||||
@Composable
|
||||
@@ -31,6 +32,8 @@ fun SelfProfileAction(
|
||||
onPremiumClick: (() -> Unit)? = null
|
||||
) {
|
||||
val AppColors = LocalAppTheme.current
|
||||
val editProfileDebouncer = rememberDebouncer()
|
||||
val premiumClickDebouncer = rememberDebouncer()
|
||||
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
@@ -47,8 +50,10 @@ fun SelfProfileAction(
|
||||
.background(AppColors.nonActive)
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
.noRippleClickable {
|
||||
editProfileDebouncer {
|
||||
onEditProfile()
|
||||
}
|
||||
}
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.edit_profile),
|
||||
@@ -68,8 +73,10 @@ fun SelfProfileAction(
|
||||
.background(AppColors.premiumBackground)
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
.noRippleClickable {
|
||||
premiumClickDebouncer {
|
||||
onPremiumClick?.invoke()
|
||||
}
|
||||
}
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.ic_member),
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.entity.AgentEntity
|
||||
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
|
||||
@Composable
|
||||
@@ -164,6 +165,9 @@ private fun AgentItem(
|
||||
onLongClick: () -> Unit = {}
|
||||
) {
|
||||
val AppColors = LocalAppTheme.current
|
||||
val clickDebouncer = rememberDebouncer()
|
||||
val avatarClickDebouncer = rememberDebouncer()
|
||||
val longClickDebouncer = rememberDebouncer()
|
||||
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
@@ -173,12 +177,16 @@ private fun AgentItem(
|
||||
indication = null,
|
||||
onClick = {
|
||||
Log.d("AgentItem", "onClick triggered for agent: ${agent.title}")
|
||||
clickDebouncer {
|
||||
onClick()
|
||||
}
|
||||
},
|
||||
onLongClick = {
|
||||
Log.d("AgentItem", "onLongClick triggered for agent: ${agent.title}")
|
||||
longClickDebouncer {
|
||||
onLongClick()
|
||||
}
|
||||
}
|
||||
)
|
||||
) {
|
||||
// 头像
|
||||
@@ -191,12 +199,16 @@ private fun AgentItem(
|
||||
indication = null,
|
||||
onClick = {
|
||||
Log.d("AgentItem", "Avatar clicked for agent: ${agent.title}")
|
||||
avatarClickDebouncer {
|
||||
onAvatarClick()
|
||||
}
|
||||
},
|
||||
onLongClick = {
|
||||
Log.d("AgentItem", "Avatar long clicked for agent: ${agent.title}")
|
||||
longClickDebouncer {
|
||||
onLongClick()
|
||||
}
|
||||
}
|
||||
)
|
||||
) {
|
||||
CustomAsyncImage(
|
||||
@@ -205,7 +217,7 @@ private fun AgentItem(
|
||||
contentDescription = agent.title,
|
||||
modifier = Modifier.size(48.dp),
|
||||
contentScale = ContentScale.Crop,
|
||||
defaultRes = com.aiosman.ravenow.R.mipmap.rider_pro_agent
|
||||
defaultRes = R.mipmap.rider_pro_agent
|
||||
)
|
||||
}
|
||||
|
||||
@@ -225,16 +237,22 @@ private fun AgentItem(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
private fun MoreAgentItem(
|
||||
modifier: Modifier = Modifier,
|
||||
onClick: () -> Unit = {}
|
||||
) {
|
||||
val AppColors = LocalAppTheme.current
|
||||
val debouncer = rememberDebouncer()
|
||||
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = modifier.noRippleClickable { onClick() }
|
||||
modifier = modifier.noRippleClickable {
|
||||
debouncer {
|
||||
onClick()
|
||||
}
|
||||
}
|
||||
) {
|
||||
// 圆形右箭头按钮
|
||||
Box(
|
||||
@@ -267,3 +285,4 @@ private fun MoreAgentItem(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.entity.AccountProfileEntity
|
||||
import com.aiosman.ravenow.ui.NavigationRoute
|
||||
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
|
||||
@Composable
|
||||
@@ -36,6 +37,8 @@ fun UserItem(
|
||||
) {
|
||||
val navController = LocalNavController.current
|
||||
val AppColors = LocalAppTheme.current
|
||||
val followerDebouncer = rememberDebouncer()
|
||||
val followingDebouncer = rememberDebouncer()
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -84,6 +87,7 @@ fun UserItem(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.noRippleClickable {
|
||||
followerDebouncer {
|
||||
navController.navigate(
|
||||
NavigationRoute.FollowerList.route.replace(
|
||||
"{id}",
|
||||
@@ -91,6 +95,7 @@ fun UserItem(
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
) {
|
||||
Text(
|
||||
text = accountProfileEntity.followerCount.toString(),
|
||||
@@ -111,6 +116,7 @@ fun UserItem(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.noRippleClickable {
|
||||
followingDebouncer {
|
||||
navController.navigate(
|
||||
NavigationRoute.FollowingList.route.replace(
|
||||
"{id}",
|
||||
@@ -118,6 +124,7 @@ fun UserItem(
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
) {
|
||||
Text(
|
||||
text = accountProfileEntity.followingCount.toString(),
|
||||
|
||||
@@ -80,6 +80,7 @@ import com.aiosman.ravenow.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.ravenow.ui.composables.DraggableGrid
|
||||
import com.aiosman.ravenow.ui.composables.RelPostCard
|
||||
import com.aiosman.ravenow.ui.composables.StatusBarMaskLayout
|
||||
import com.aiosman.ravenow.ui.composables.rememberDebouncer
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -486,6 +487,9 @@ fun AddImageGrid() {
|
||||
}
|
||||
}
|
||||
|
||||
val addImageDebouncer = rememberDebouncer()
|
||||
val takePhotoDebouncer = rememberDebouncer()
|
||||
|
||||
val stroke = Stroke(
|
||||
width = 2f,
|
||||
pathEffect = PathEffect.dashPathEffect(floatArrayOf(10f, 10f), 0f)
|
||||
@@ -551,10 +555,16 @@ fun AddImageGrid() {
|
||||
.clip(RoundedCornerShape(16.dp)) // 设置圆角
|
||||
.background(AppColors.basicMain) // 设置背景色
|
||||
.noRippleClickable {
|
||||
addImageDebouncer {
|
||||
if (model.imageList.size < 9) {
|
||||
pickImagesLauncher.launch("image/*")
|
||||
} else {
|
||||
Toast.makeText(context, "最多只能选择9张图片", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(
|
||||
context,
|
||||
"最多只能选择9张图片",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
},
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user