fix: 重组时列表异常回顶
This commit is contained in:
parent
fda886629d
commit
a3bb46ba46
|
|
@ -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(
|
||||
|
|
@ -271,6 +273,7 @@ private fun ThreadList(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
|
|
@ -385,7 +388,7 @@ fun ForumThreadListPage(
|
|||
items = threadList,
|
||||
isGood = isGood,
|
||||
goodClassifyId = goodClassifyId,
|
||||
goodClassifyHoldersProvider = { goodClassifies },
|
||||
goodClassifyHolders = goodClassifies,
|
||||
onItemClicked = {
|
||||
navigator.navigate(
|
||||
ThreadPageDestination(
|
||||
|
|
|
|||
Loading…
Reference in New Issue