防抖调整

This commit is contained in:
2025-09-04 18:28:11 +08:00
parent 9b7349a761
commit 9f14b35847
15 changed files with 322 additions and 156 deletions

View File

@@ -23,16 +23,22 @@ 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()
navController.navigate("NewPost")
NewPostViewModel.asNewPost()
debouncer {
navController.navigate("NewPost")
}
}
// AddBtn(icon = R.drawable.rider_pro_location_create, text = "Location Create")
}
@@ -40,9 +46,13 @@ fun AddPage(){
@Composable
fun AddBtn(@DrawableRes icon: Int, text: String,onClick: (() -> Unit)? = {}){
val (isDebouncing, startDebounce, resetDebounce) = rememberDebouncedState()
Row (modifier = Modifier
.fillMaxWidth().padding(24.dp).clickable {
onClick?.invoke()
if (!isDebouncing) {
startDebounce()
onClick?.invoke()
}
},
verticalAlignment = Alignment.CenterVertically){
Image(

View File

@@ -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 = {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CHAT_WITH_AGENT)) {
navController.navigate(NavigationRoute.Login.route)
} else {
model.createSingleChat(agentItem.openId)
model.goToChatAi(agentItem.openId,navController)
chatDebouncer {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CHAT_WITH_AGENT)) {
navController.navigate(NavigationRoute.Login.route)
} else {
model.createSingleChat(agentItem.openId)
model.goToChatAi(agentItem.openId, navController)
}
}
},
onAvatarClick = {
avatarDebouncer {
model.goToProfile(agentItem.openId, navController)
}
}
)
}

View File

@@ -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,24 +109,32 @@ 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 = {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CHAT_WITH_AGENT)) {
navController.navigate(NavigationRoute.Login.route)
} else {
model.createSingleChat(agent.openId)
model.goToChatAi(agent.openId,navController)
chatDebouncer {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.CHAT_WITH_AGENT)) {
navController.navigate(NavigationRoute.Login.route)
} else {
model.createSingleChat(agent.openId)
model.goToChatAi(agent.openId,navController)
}
}
},
onAvatarClick = {
model.goToProfile(agent.openId, navController)
avatarDebouncer {
model.goToProfile(agent.openId, navController)
}
}
)
}
}
// 加载更多指示器
if (agentList.loadState.append is LoadState.Loading) {
item {

View File

@@ -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 {
navController.navigate(NavigationRoute.CreateGroupChat.route)
debouncer {
navController.navigate(NavigationRoute.CreateGroupChat.route)
}
},
colorFilter = ColorFilter.tint(AppColors.text)
)
}
// 搜索栏//
Box(
@@ -219,19 +225,25 @@ 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)
) {
if (MessageListViewModel.likeNoticeCount > 0) {
// 刷新点赞消息列表
LikeNoticeViewModel.isFirstLoad = true
// 清除点赞消息数量
MessageListViewModel.clearLikeNoticeCount()
likeDebouncer {
if (MessageListViewModel.likeNoticeCount > 0) {
// 刷新点赞消息列表
LikeNoticeViewModel.isFirstLoad = true
// 清除点赞消息数量
MessageListViewModel.clearLikeNoticeCount()
}
navController.navigate(NavigationRoute.Likes.route)
}
navController.navigate(NavigationRoute.Likes.route)
}
NotificationIndicator(
MessageListViewModel.followNoticeCount,
@@ -239,12 +251,14 @@ fun NotificationsScreen() {
stringResource(R.string.followers_upper),
Color(0xFFF470FE)
) {
if (MessageListViewModel.followNoticeCount > 0) {
// 刷新关注消息列表
FollowerNoticeViewModel.isFirstLoad = true
MessageListViewModel.clearFollowNoticeCount()
followDebouncer {
if (MessageListViewModel.followNoticeCount > 0) {
// 刷新关注消息列表
FollowerNoticeViewModel.isFirstLoad = true
MessageListViewModel.clearFollowNoticeCount()
}
navController.navigate(NavigationRoute.Followers.route)
}
navController.navigate(NavigationRoute.Followers.route)
}
NotificationIndicator(
MessageListViewModel.commentNoticeCount,
@@ -252,7 +266,9 @@ fun NotificationsScreen() {
stringResource(R.string.comment).uppercase(),
Color(0xFF6246FF)
) {
navController.navigate(NavigationRoute.CommentNoticeScreen.route)
commentDebouncer {
navController.navigate(NavigationRoute.CommentNoticeScreen.route)
}
}
}
Row(
@@ -264,13 +280,17 @@ fun NotificationsScreen() {
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.Bottom
) {
val tabDebouncer = rememberDebouncer()
Box {
TabItem(
text = stringResource(R.string.chat_ai),
isSelected = pagerState.currentPage == 0,
onClick = {
scope.launch {
pagerState.animateScrollToPage(0)
tabDebouncer {
scope.launch {
pagerState.animateScrollToPage(0)
}
}
}
)
@@ -295,8 +315,10 @@ fun NotificationsScreen() {
text = stringResource(R.string.chat_group),
isSelected = pagerState.currentPage == 1,
onClick = {
scope.launch {
pagerState.animateScrollToPage(1)
tabDebouncer {
scope.launch {
pagerState.animateScrollToPage(1)
}
}
}
)
@@ -321,8 +343,10 @@ fun NotificationsScreen() {
text = stringResource(R.string.chat_friend),
isSelected = pagerState.currentPage == 2,
onClick = {
scope.launch {
pagerState.animateScrollToPage(2)
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(
}

View File

@@ -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 {
onChatClick(conversation)
chatDebouncer {
onChatClick(conversation)
}
},
verticalAlignment = Alignment.CenterVertically
) {
@@ -209,7 +213,9 @@ fun AgentChatItem(
.size(48.dp)
.clip(RoundedCornerShape(48.dp))
.noRippleClickable {
onUserAvatarClick(conversation)
avatarDebouncer {
onUserAvatarClick(conversation)
}
}
)
}

View File

@@ -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 {
onChatClick(conversation)
chatDebouncer {
onChatClick(conversation)
}
},
verticalAlignment = Alignment.CenterVertically
) {
@@ -188,7 +193,9 @@ fun FriendChatItem(
.size(48.dp)
.clip(RoundedCornerShape(48.dp))
.noRippleClickable {
onUserAvatarClick(conversation)
avatarDebouncer {
onUserAvatarClick(conversation)
}
}
)
}
@@ -259,3 +266,4 @@ fun FriendChatItem(
}
}
}

View File

@@ -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,13 +173,17 @@ 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 {
onChatClick(conversation)
chatDebouncer {
onChatClick(conversation)
}
}
) {
Box {
@@ -190,7 +195,9 @@ fun GroupChatItem(
.size(48.dp)
.clip(RoundedCornerShape(12.dp))
.noRippleClickable {
onGroupAvatarClick(conversation)
avatarDebouncer {
onGroupAvatarClick(conversation)
}
}
)
}
@@ -261,3 +268,4 @@ fun GroupChatItem(
}
}
}

View File

@@ -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,58 +102,72 @@ 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 = {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.COMMENT_MOMENT)) {
navController.navigate(NavigationRoute.Login.route)
} else {
scope.launch {
model.onAddComment(momentItem.id)
commentDebouncer {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.COMMENT_MOMENT)) {
navController.navigate(NavigationRoute.Login.route)
} else {
scope.launch {
model.onAddComment(momentItem.id)
}
}
}
},
onLikeClick = {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
navController.navigate(NavigationRoute.Login.route)
} else {
scope.launch {
if (momentItem.liked) {
model.dislikeMoment(momentItem.id)
} else {
model.likeMoment(momentItem.id)
likeDebouncer {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
navController.navigate(NavigationRoute.Login.route)
} else {
scope.launch {
if (momentItem.liked) {
model.dislikeMoment(momentItem.id)
} else {
model.likeMoment(momentItem.id)
}
}
}
}
},
onFavoriteClick = {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
navController.navigate(NavigationRoute.Login.route)
} else {
scope.launch {
if (momentItem.isFavorite) {
model.unfavoriteMoment(momentItem.id)
} else {
model.favoriteMoment(momentItem.id)
favoriteDebouncer {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.LIKE_MOMENT)) {
navController.navigate(NavigationRoute.Login.route)
} else {
scope.launch {
if (momentItem.isFavorite) {
model.unfavoriteMoment(momentItem.id)
} else {
model.favoriteMoment(momentItem.id)
}
}
}
}
},
onFollowClick = {
// 检查游客模式,如果是游客则跳转登录
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.FOLLOW_USER)) {
navController.navigate(NavigationRoute.Login.route)
} else {
model.followAction(momentItem)
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))
}
}
}

View File

@@ -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,17 +131,20 @@ fun DiscoverView() {
// contentPadding = PaddingValues(8.dp)
) {
items(moments) { momentItem ->
val debouncer = rememberDebouncer()
Box(
modifier = Modifier
.fillMaxWidth()
.aspectRatio(1f)
.padding(2.dp)
.noRippleClickable {
navController.navigateToPost(
id = momentItem.id,
highlightCommentId = 0,
initImagePagerIndex = 0
)
debouncer {
navController.navigateToPost(
id = momentItem.id,
highlightCommentId = 0,
initImagePagerIndex = 0
)
}
}
) {
CustomAsyncImage(

View File

@@ -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,38 +133,52 @@ 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 = {
scope.launch {
model.onAddComment(momentItem.id)
commentDebouncer {
scope.launch {
model.onAddComment(momentItem.id)
}
}
},
onLikeClick = {
scope.launch {
if (momentItem.liked) {
model.dislikeMoment(momentItem.id)
} else {
model.likeMoment(momentItem.id)
likeDebouncer {
scope.launch {
if (momentItem.liked) {
model.dislikeMoment(momentItem.id)
} else {
model.likeMoment(momentItem.id)
}
}
}
},
onFavoriteClick = {
scope.launch {
if (momentItem.isFavorite) {
model.unfavoriteMoment(momentItem.id)
} else {
model.favoriteMoment(momentItem.id)
favoriteDebouncer {
scope.launch {
if (momentItem.isFavorite) {
model.unfavoriteMoment(momentItem.id)
} else {
model.favoriteMoment(momentItem.id)
}
}
}
},
onFollowClick = {
model.followAction(momentItem)
followDebouncer {
model.followAction(momentItem)
}
},
showFollowButton = false
)
}
}
}
PullRefreshIndicator(model.refreshing, state, Modifier.align(Alignment.TopCenter))
}

View File

@@ -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,9 +67,11 @@ fun GalleryItem(
}
.clip(RoundedCornerShape(8.dp))
.noRippleClickable {
navController.navigateToPost(
moment.id
)
debouncer {
navController.navigateToPost(
moment.id
)
}
}
) {
// 检查图片列表是否为空
@@ -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,17 +172,20 @@ fun GalleryGrid(
) {
itemsIndexed(moments) { idx, moment ->
if (moment != null) {
val itemDebouncer = rememberDebouncer()
Box(
modifier = Modifier
.fillMaxWidth()
.aspectRatio(1f)
.padding(2.dp)
.noRippleClickable {
navController.navigateToPost(
id = moment.id,
highlightCommentId = 0,
initImagePagerIndex = 0
)
itemDebouncer {
navController.navigateToPost(
id = moment.id,
highlightCommentId = 0,
initImagePagerIndex = 0
)
}
}
) {
CustomAsyncImage(
@@ -208,3 +217,4 @@ fun GalleryGrid(
}
}

View File

@@ -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,7 +50,9 @@ fun SelfProfileAction(
.background(AppColors.nonActive)
.padding(horizontal = 16.dp, vertical = 12.dp)
.noRippleClickable {
onEditProfile()
editProfileDebouncer {
onEditProfile()
}
}
) {
Text(
@@ -68,7 +73,9 @@ fun SelfProfileAction(
.background(AppColors.premiumBackground)
.padding(horizontal = 16.dp, vertical = 12.dp)
.noRippleClickable {
onPremiumClick?.invoke()
premiumClickDebouncer {
onPremiumClick?.invoke()
}
}
) {
Image(

View File

@@ -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,11 +177,15 @@ private fun AgentItem(
indication = null,
onClick = {
Log.d("AgentItem", "onClick triggered for agent: ${agent.title}")
onClick()
clickDebouncer {
onClick()
}
},
onLongClick = {
Log.d("AgentItem", "onLongClick triggered for agent: ${agent.title}")
onLongClick()
longClickDebouncer {
onLongClick()
}
}
)
) {
@@ -191,11 +199,15 @@ private fun AgentItem(
indication = null,
onClick = {
Log.d("AgentItem", "Avatar clicked for agent: ${agent.title}")
onAvatarClick()
avatarClickDebouncer {
onAvatarClick()
}
},
onLongClick = {
Log.d("AgentItem", "Avatar long clicked for agent: ${agent.title}")
onLongClick()
longClickDebouncer {
onLongClick()
}
}
)
) {
@@ -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(
)
}
}

View File

@@ -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,12 +87,14 @@ fun UserItem(
modifier = Modifier
.weight(1f)
.noRippleClickable {
navController.navigate(
NavigationRoute.FollowerList.route.replace(
"{id}",
accountProfileEntity.id.toString()
followerDebouncer {
navController.navigate(
NavigationRoute.FollowerList.route.replace(
"{id}",
accountProfileEntity.id.toString()
)
)
)
}
}
) {
Text(
@@ -111,12 +116,14 @@ fun UserItem(
modifier = Modifier
.weight(1f)
.noRippleClickable {
navController.navigate(
NavigationRoute.FollowingList.route.replace(
"{id}",
accountProfileEntity.id.toString()
followingDebouncer {
navController.navigate(
NavigationRoute.FollowingList.route.replace(
"{id}",
accountProfileEntity.id.toString()
)
)
)
}
}
) {
Text(

View File

@@ -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 {
if (model.imageList.size < 9) {
pickImagesLauncher.launch("image/*")
} else {
Toast.makeText(context, "最多只能选择9张图片", Toast.LENGTH_SHORT).show()
addImageDebouncer {
if (model.imageList.size < 9) {
pickImagesLauncher.launch("image/*")
} else {
Toast.makeText(
context,
"最多只能选择9张图片",
Toast.LENGTH_SHORT
).show()
}
}
},
) {