fix: 重组时列表异常回顶

This commit is contained in:
HuanCheng65 2023-10-08 11:24:30 +08:00
parent fda886629d
commit a3bb46ba46
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
1 changed files with 74 additions and 71 deletions

View File

@ -35,6 +35,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.util.fastForEach
import com.huanchengfly.tieba.post.R
import com.huanchengfly.tieba.post.api.models.protos.OriginThreadInfo
import com.huanchengfly.tieba.post.api.models.protos.ThreadInfo
@ -59,6 +60,7 @@ import com.huanchengfly.tieba.post.ui.page.forum.getSortType
import com.huanchengfly.tieba.post.ui.widgets.Chip
import com.huanchengfly.tieba.post.ui.widgets.compose.BlockTip
import com.huanchengfly.tieba.post.ui.widgets.compose.BlockableContent
import com.huanchengfly.tieba.post.ui.widgets.compose.Container
import com.huanchengfly.tieba.post.ui.widgets.compose.FeedCard
import com.huanchengfly.tieba.post.ui.widgets.compose.LazyLoad
import com.huanchengfly.tieba.post.ui.widgets.compose.LoadMoreLayout
@ -112,18 +114,17 @@ private enum class ItemType {
@Composable
private fun GoodClassifyTabs(
goodClassifyHoldersProvider: () -> List<ImmutableHolder<Classify>>,
goodClassifyHolders: ImmutableList<ImmutableHolder<Classify>>,
selectedItem: Int?,
onSelected: (Int) -> Unit,
) {
val goodClassifyHolders = goodClassifyHoldersProvider()
Row(
modifier = Modifier
.horizontalScroll(rememberScrollState())
.padding(vertical = 8.dp, horizontal = 16.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
goodClassifyHolders.forEach { holder ->
goodClassifyHolders.fastForEach { holder ->
val (classify) = holder
Chip(
text = classify.class_name,
@ -173,7 +174,7 @@ private fun ThreadList(
items: ImmutableList<ThreadItemData>,
isGood: Boolean,
goodClassifyId: Int?,
goodClassifyHoldersProvider: () -> List<ImmutableHolder<Classify>>,
goodClassifyHolders: ImmutableList<ImmutableHolder<Classify>>,
onItemClicked: (ThreadInfo) -> Unit,
onItemReplyClicked: (ThreadInfo) -> Unit,
onAgree: (ThreadInfo) -> Unit,
@ -188,21 +189,22 @@ private fun ThreadList(
WindowWidthSizeClass.Expanded -> 0.5f
else -> 1f
}
MyLazyColumn(
state = state,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxWidth(),
contentPadding = WindowInsets.navigationBars.asPaddingValues()
) {
Column {
if (isGood) {
item(key = "GoodClassifyHeader") {
Container {
GoodClassifyTabs(
goodClassifyHoldersProvider = goodClassifyHoldersProvider,
goodClassifyHolders = goodClassifyHolders,
selectedItem = goodClassifyId,
onSelected = onClassifySelected
)
}
}
MyLazyColumn(
state = state,
// horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxWidth(),
contentPadding = WindowInsets.navigationBars.asPaddingValues()
) {
if (!forumRuleTitle.isNullOrEmpty()) {
item(key = "ForumRule") {
TopThreadItem(
@ -272,6 +274,7 @@ private fun ThreadList(
}
}
}
}
@OptIn(ExperimentalMaterialApi::class)
@Composable
@ -385,7 +388,7 @@ fun ForumThreadListPage(
items = threadList,
isGood = isGood,
goodClassifyId = goodClassifyId,
goodClassifyHoldersProvider = { goodClassifies },
goodClassifyHolders = goodClassifies,
onItemClicked = {
navigator.navigate(
ThreadPageDestination(