Scroll to top when shuffling the queue (#283)

This commit is contained in:
vfsfitvnm 2022-09-06 13:28:50 +02:00
parent 9f6b6c9a9c
commit 4014675766
2 changed files with 9 additions and 2 deletions

View file

@ -59,6 +59,7 @@ import it.vfsfitvnm.vimusic.utils.rememberMediaItemIndex
import it.vfsfitvnm.vimusic.utils.rememberShouldBePlaying import it.vfsfitvnm.vimusic.utils.rememberShouldBePlaying
import it.vfsfitvnm.vimusic.utils.rememberWindows import it.vfsfitvnm.vimusic.utils.rememberWindows
import it.vfsfitvnm.vimusic.utils.shuffleQueue import it.vfsfitvnm.vimusic.utils.shuffleQueue
import kotlinx.coroutines.launch
@ExperimentalFoundationApi @ExperimentalFoundationApi
@ExperimentalAnimationApi @ExperimentalAnimationApi
@ -251,7 +252,13 @@ fun CurrentPlaylistView(
colorFilter = ColorFilter.tint(colorPalette.text), colorFilter = ColorFilter.tint(colorPalette.text),
modifier = Modifier modifier = Modifier
.padding(end = 2.dp) .padding(end = 2.dp)
.clickable(onClick = binder.player::shuffleQueue) .clickable {
reorderingState.coroutineScope.launch {
reorderingState.lazyListState.animateScrollToItem(0)
}.invokeOnCompletion {
binder.player.shuffleQueue()
}
}
.align(Alignment.CenterEnd) .align(Alignment.CenterEnd)
.padding(all = 8.dp) .padding(all = 8.dp)
.size(20.dp) .size(20.dp)

View file

@ -28,7 +28,7 @@ import kotlinx.coroutines.withContext
@Stable @Stable
class ReorderingState( class ReorderingState(
val lazyListState: LazyListState, val lazyListState: LazyListState,
internal val coroutineScope: CoroutineScope, val coroutineScope: CoroutineScope,
private val lastIndex: Int, private val lastIndex: Int,
internal val onDragStart: () -> Unit, internal val onDragStart: () -> Unit,
internal val onDragEnd: (Int, Int) -> Unit, internal val onDragEnd: (Int, Int) -> Unit,