mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 15:29:15 +01:00
request the initial queue scroll and settle it before loading
This commit is contained in:
@@ -35,6 +35,7 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.runtime.snapshotFlow
|
import androidx.compose.runtime.snapshotFlow
|
||||||
|
import androidx.compose.runtime.withFrameNanos
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
@@ -291,14 +292,14 @@ fun QueueScreen(
|
|||||||
var centered by remember { mutableStateOf(false) }
|
var centered by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
LaunchedEffect(ready, rows.size, currentPosition) {
|
LaunchedEffect(ready, rows.size, currentPosition) {
|
||||||
if (centered || !ready || rows.isEmpty()) return@LaunchedEffect
|
if (centered || !ready) return@LaunchedEffect
|
||||||
val position = currentPosition ?: return@LaunchedEffect
|
val position = currentPosition ?: return@LaunchedEffect
|
||||||
val index = rows.indexOfFirst { it.position == position }
|
val index = rows.indexOfFirst { it.position == position }
|
||||||
if (index < 0) return@LaunchedEffect
|
if (index >= 0) {
|
||||||
snapshotFlow { listState.layoutInfo.totalItemsCount }.first { it > 0 }
|
listState.requestScrollToItem(index)
|
||||||
listState.scrollToItem(index)
|
|
||||||
centered = true
|
centered = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val reorderState =
|
val reorderState =
|
||||||
rememberReorderableLazyListState(listState) { from, to ->
|
rememberReorderableLazyListState(listState) { from, to ->
|
||||||
@@ -311,6 +312,7 @@ fun QueueScreen(
|
|||||||
|
|
||||||
LaunchedEffect(listState, centered) {
|
LaunchedEffect(listState, centered) {
|
||||||
if (!centered) return@LaunchedEffect
|
if (!centered) return@LaunchedEffect
|
||||||
|
withFrameNanos { }
|
||||||
snapshotFlow {
|
snapshotFlow {
|
||||||
val info = listState.layoutInfo
|
val info = listState.layoutInfo
|
||||||
val firstVisible = info.visibleItemsInfo.firstOrNull()?.index ?: -1
|
val firstVisible = info.visibleItemsInfo.firstOrNull()?.index ?: -1
|
||||||
|
|||||||
Reference in New Issue
Block a user