feat: 回复按钮点击跳转回复
This commit is contained in:
parent
0a86dffd8e
commit
11fb0b7e1a
|
|
@ -136,6 +136,7 @@ private fun ThreadList(
|
|||
goodClassifyId: Int?,
|
||||
goodClassifyHoldersProvider: () -> List<ImmutableHolder<Classify>>,
|
||||
onItemClicked: (ThreadInfo) -> Unit,
|
||||
onItemReplyClicked: (ThreadInfo) -> Unit,
|
||||
onAgree: (ThreadInfo) -> Unit,
|
||||
onClassifySelected: (Int) -> Unit
|
||||
) {
|
||||
|
|
@ -219,12 +220,9 @@ private fun ThreadList(
|
|||
}
|
||||
FeedCard(
|
||||
item = holder,
|
||||
onClick = {
|
||||
onItemClicked(item)
|
||||
},
|
||||
onAgree = {
|
||||
onAgree(item)
|
||||
},
|
||||
onClick = onItemClicked,
|
||||
onReplyClick = onItemReplyClicked,
|
||||
onAgree = onAgree,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -338,10 +336,20 @@ fun ForumThreadListPage(
|
|||
navigator.navigate(
|
||||
ThreadPageDestination(
|
||||
it.threadId,
|
||||
forumId = it.forumId,
|
||||
threadInfo = it
|
||||
)
|
||||
)
|
||||
},
|
||||
onItemReplyClicked = {
|
||||
navigator.navigate(
|
||||
ThreadPageDestination(
|
||||
it.threadId,
|
||||
forumId = it.forumId,
|
||||
scrollToReply = true
|
||||
)
|
||||
)
|
||||
},
|
||||
onAgree = {
|
||||
viewModel.send(
|
||||
ForumThreadListUiIntent.Agree(
|
||||
|
|
|
|||
|
|
@ -115,7 +115,8 @@ private class ForumThreadListPartialChangeProducer(val type: ForumThreadListType
|
|||
1,
|
||||
1,
|
||||
sortType.takeIf { type == ForumThreadListType.Latest } ?: -1,
|
||||
goodClassifyId.takeIf { type == ForumThreadListType.Good }
|
||||
goodClassifyId.takeIf { type == ForumThreadListType.Good },
|
||||
forceNew = true
|
||||
)
|
||||
.map<FrsPageResponse, ForumThreadListPartialChange.Refresh> { response ->
|
||||
if (response.data_?.page == null) throw TiebaUnknownException
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import androidx.compose.runtime.getValue
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.huanchengfly.tieba.post.api.hasAgree
|
||||
import com.huanchengfly.tieba.post.arch.BaseComposeActivity
|
||||
import com.huanchengfly.tieba.post.arch.CommonUiEvent.ScrollToTop.bindScrollToTopEvent
|
||||
import com.huanchengfly.tieba.post.arch.collectPartialAsState
|
||||
|
|
@ -102,19 +103,27 @@ fun ConcernPage(
|
|||
onClick = {
|
||||
navigator.navigate(
|
||||
ThreadPageDestination(
|
||||
item.threadList.threadId,
|
||||
item.threadList.forumId,
|
||||
threadInfo = item.threadList
|
||||
it.threadId,
|
||||
it.forumId,
|
||||
threadInfo = it
|
||||
)
|
||||
)
|
||||
},
|
||||
onReplyClick = {
|
||||
navigator.navigate(
|
||||
ThreadPageDestination(
|
||||
it.threadId,
|
||||
it.forumId,
|
||||
scrollToReply = true
|
||||
)
|
||||
)
|
||||
|
||||
},
|
||||
onAgree = {
|
||||
viewModel.send(
|
||||
ConcernUiIntent.Agree(
|
||||
item.threadList.threadId,
|
||||
item.threadList.firstPostId,
|
||||
item.threadList.agree?.hasAgree ?: 0
|
||||
it.threadId,
|
||||
it.firstPostId,
|
||||
it.hasAgree
|
||||
)
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -283,6 +283,14 @@ fun HotPage(
|
|||
)
|
||||
)
|
||||
},
|
||||
onReplyClick = {
|
||||
navigator.navigate(
|
||||
ThreadPageDestination(
|
||||
threadId = it.id,
|
||||
scrollToReply = true
|
||||
)
|
||||
)
|
||||
},
|
||||
onAgree = {
|
||||
viewModel.send(
|
||||
HotUiIntent.Agree(
|
||||
|
|
|
|||
|
|
@ -157,21 +157,30 @@ fun PersonalizedPage(
|
|||
personalizedDataProvider = { threadPersonalizedData },
|
||||
refreshPositionProvider = { refreshPosition },
|
||||
hiddenThreadIdsProvider = { hiddenThreadIds },
|
||||
onItemClick = { threadInfo ->
|
||||
onItemClick = {
|
||||
navigator.navigate(
|
||||
ThreadPageDestination(
|
||||
threadInfo.id,
|
||||
threadInfo.forumId,
|
||||
threadInfo = threadInfo
|
||||
it.id,
|
||||
it.forumId,
|
||||
threadInfo = it
|
||||
)
|
||||
)
|
||||
},
|
||||
onAgree = { item ->
|
||||
onItemReplyClick = {
|
||||
navigator.navigate(
|
||||
ThreadPageDestination(
|
||||
it.id,
|
||||
it.forumId,
|
||||
scrollToReply = true
|
||||
)
|
||||
)
|
||||
},
|
||||
onAgree = {
|
||||
viewModel.send(
|
||||
PersonalizedUiIntent.Agree(
|
||||
item.threadId,
|
||||
item.firstPostId,
|
||||
item.agree?.hasAgree ?: 0
|
||||
it.threadId,
|
||||
it.firstPostId,
|
||||
it.agree?.hasAgree ?: 0
|
||||
)
|
||||
)
|
||||
},
|
||||
|
|
@ -232,6 +241,7 @@ private fun FeedList(
|
|||
refreshPositionProvider: () -> Int,
|
||||
hiddenThreadIdsProvider: () -> List<Long>,
|
||||
onItemClick: (ThreadInfo) -> Unit,
|
||||
onItemReplyClick: (ThreadInfo) -> Unit,
|
||||
onAgree: (ThreadInfo) -> Unit,
|
||||
onDislike: (ThreadInfo, Long, List<ImmutableHolder<DislikeReason>>) -> Unit,
|
||||
onRefresh: () -> Unit,
|
||||
|
|
@ -274,14 +284,11 @@ private fun FeedList(
|
|||
) {
|
||||
FeedCard(
|
||||
item = item,
|
||||
onClick = {
|
||||
onItemClick(item.get())
|
||||
},
|
||||
onAgree = {
|
||||
onAgree(item.get())
|
||||
},
|
||||
onClick = onItemClick,
|
||||
onReplyClick = onItemReplyClick,
|
||||
onAgree = onAgree,
|
||||
onClickForum = {
|
||||
onOpenForum(item.get { forumInfo?.name ?: "" })
|
||||
onOpenForum(it.name)
|
||||
}
|
||||
) {
|
||||
val personalized = threadPersonalizedData.getOrNull(index)
|
||||
|
|
|
|||
|
|
@ -397,6 +397,7 @@ fun ThreadPage(
|
|||
from: String = "",
|
||||
extra: ThreadPageExtra = ThreadPageNoExtra,
|
||||
threadInfo: ThreadInfo? = null,
|
||||
scrollToReply: Boolean = false,
|
||||
viewModel: ThreadViewModel = pageViewModel()
|
||||
) {
|
||||
LazyLoad(loaded = viewModel.initialized) {
|
||||
|
|
@ -528,6 +529,8 @@ fun ThreadPage(
|
|||
val curForumId = remember(forumId, forum) {
|
||||
forumId ?: forum?.get { id }
|
||||
}
|
||||
var waitLoadSuccessAndScrollToFirstReply by remember { mutableStateOf(scrollToReply) }
|
||||
|
||||
val lazyListState = rememberLazyListState()
|
||||
val bottomSheetState = rememberModalBottomSheetState(
|
||||
initialValue = ModalBottomSheetValue.Hidden,
|
||||
|
|
@ -571,6 +574,12 @@ fun ThreadPage(
|
|||
viewModel.onEvent<ThreadUiEvent.ScrollToFirstReply> {
|
||||
lazyListState.animateScrollToItem(3)
|
||||
}
|
||||
viewModel.onEvent<ThreadUiEvent.LoadSuccess> {
|
||||
if (it.page > 1 || waitLoadSuccessAndScrollToFirstReply) {
|
||||
waitLoadSuccessAndScrollToFirstReply = false
|
||||
lazyListState.animateScrollToItem(3)
|
||||
}
|
||||
}
|
||||
viewModel.onEvent<ThreadUiEvent.AddFavoriteSuccess> {
|
||||
scaffoldState.snackbarHostState.showSnackbar(
|
||||
context.getString(R.string.message_add_favorite_success, it.floor)
|
||||
|
|
@ -1050,7 +1059,7 @@ fun ThreadPage(
|
|||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
if (data.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class ThreadViewModel @Inject constructor() :
|
|||
)
|
||||
|
||||
ThreadPartialChange.RemoveFavorite.Success -> ThreadUiEvent.RemoveFavoriteSuccess
|
||||
is ThreadPartialChange.Load.Success -> if (partialChange.currentPage > 1) ThreadUiEvent.ScrollToFirstReply else null
|
||||
is ThreadPartialChange.Load.Success -> ThreadUiEvent.LoadSuccess(partialChange.currentPage)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
@ -895,6 +895,10 @@ data class ThreadUiState(
|
|||
sealed interface ThreadUiEvent : UiEvent {
|
||||
object ScrollToFirstReply : ThreadUiEvent
|
||||
|
||||
data class LoadSuccess(
|
||||
val page: Int
|
||||
) : ThreadUiEvent
|
||||
|
||||
data class AddFavoriteSuccess(val floor: Int) : ThreadUiEvent
|
||||
|
||||
object RemoveFavoriteSuccess : ThreadUiEvent
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ import com.huanchengfly.tieba.post.R
|
|||
import com.huanchengfly.tieba.post.activities.UserActivity
|
||||
import com.huanchengfly.tieba.post.api.abstractText
|
||||
import com.huanchengfly.tieba.post.api.models.protos.Media
|
||||
import com.huanchengfly.tieba.post.api.models.protos.SimpleForum
|
||||
import com.huanchengfly.tieba.post.api.models.protos.ThreadInfo
|
||||
import com.huanchengfly.tieba.post.api.models.protos.User
|
||||
import com.huanchengfly.tieba.post.arch.ImmutableHolder
|
||||
|
|
@ -383,7 +384,7 @@ private fun ThreadMedia(
|
|||
@Composable
|
||||
private fun ThreadForumInfo(
|
||||
item: ImmutableHolder<ThreadInfo>,
|
||||
onClick: () -> Unit
|
||||
onClick: (SimpleForum) -> Unit
|
||||
) {
|
||||
val hasForumInfo = remember(item) { item.isNotNull { forumInfo } }
|
||||
if (hasForumInfo) {
|
||||
|
|
@ -392,7 +393,7 @@ private fun ThreadForumInfo(
|
|||
ForumInfoChip(
|
||||
imageUriProvider = { StringUtil.getAvatarUrl(forumInfo.get { avatar }) },
|
||||
nameProvider = { forumInfo.get { name } },
|
||||
onClick = onClick
|
||||
onClick = { onClick(forumInfo.get()) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -486,7 +487,8 @@ fun FeedCard(
|
|||
item: ImmutableHolder<ThreadInfo>,
|
||||
onClick: (ThreadInfo) -> Unit,
|
||||
onAgree: (ThreadInfo) -> Unit,
|
||||
onClickForum: () -> Unit = {},
|
||||
onReplyClick: (ThreadInfo) -> Unit = {},
|
||||
onClickForum: (SimpleForum) -> Unit = {},
|
||||
dislikeAction: @Composable () -> Unit = {},
|
||||
) {
|
||||
Card(
|
||||
|
|
@ -519,7 +521,7 @@ fun FeedCard(
|
|||
Row(modifier = Modifier.fillMaxWidth()) {
|
||||
ThreadReplyBtn(
|
||||
replyNum = item.get { replyNum },
|
||||
onClick = { onClick(item.get()) },
|
||||
onClick = { onReplyClick(item.get()) },
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue