mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 00:37:03 +05:30
fix(comments): preserve scroll state
This commit is contained in:
parent
d9b1d082f9
commit
f00853dcc4
1 changed files with 3 additions and 1 deletions
|
@ -28,6 +28,7 @@ import androidx.compose.foundation.layout.systemBars
|
||||||
import androidx.compose.foundation.layout.windowInsetsBottomHeight
|
import androidx.compose.foundation.layout.windowInsetsBottomHeight
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
|
@ -77,6 +78,7 @@ internal fun CommentsPageInternal(
|
||||||
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val commentNodes by commentsHandler.listItems.collectAsStateWithLifecycle()
|
val commentNodes by commentsHandler.listItems.collectAsStateWithLifecycle()
|
||||||
|
val commentListState = rememberLazyListState()
|
||||||
|
|
||||||
LaunchedEffect(key1 = details, key2 = commentState) {
|
LaunchedEffect(key1 = details, key2 = commentState) {
|
||||||
if (details.comments.isNotEmpty() && !commentState?.commentIds.isNullOrEmpty()) {
|
if (details.comments.isNotEmpty() && !commentState?.commentIds.isNullOrEmpty()) {
|
||||||
|
@ -94,7 +96,7 @@ internal fun CommentsPageInternal(
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface(color = MaterialTheme.colorScheme.surfaceVariant) {
|
Surface(color = MaterialTheme.colorScheme.surfaceVariant) {
|
||||||
LazyColumn(modifier = modifier, contentPadding = contentPadding) {
|
LazyColumn(modifier = modifier, contentPadding = contentPadding, state = commentListState) {
|
||||||
item {
|
item {
|
||||||
CommentsHeader(
|
CommentsHeader(
|
||||||
post = details,
|
post = details,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue