Skip to content

Commit

Permalink
Scroll to top when shuffling the queue (vfsfitvnm#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
vfsfitvnm committed Sep 6, 2022
1 parent 9f6b6c9 commit 4014675
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import it.vfsfitvnm.vimusic.utils.rememberMediaItemIndex
import it.vfsfitvnm.vimusic.utils.rememberShouldBePlaying
import it.vfsfitvnm.vimusic.utils.rememberWindows
import it.vfsfitvnm.vimusic.utils.shuffleQueue
import kotlinx.coroutines.launch

@ExperimentalFoundationApi
@ExperimentalAnimationApi
Expand Down Expand Up @@ -251,7 +252,13 @@ fun CurrentPlaylistView(
colorFilter = ColorFilter.tint(colorPalette.text),
modifier = Modifier
.padding(end = 2.dp)
.clickable(onClick = binder.player::shuffleQueue)
.clickable {
reorderingState.coroutineScope.launch {
reorderingState.lazyListState.animateScrollToItem(0)
}.invokeOnCompletion {
binder.player.shuffleQueue()
}
}
.align(Alignment.CenterEnd)
.padding(all = 8.dp)
.size(20.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import kotlinx.coroutines.withContext
@Stable
class ReorderingState(
val lazyListState: LazyListState,
internal val coroutineScope: CoroutineScope,
val coroutineScope: CoroutineScope,
private val lastIndex: Int,
internal val onDragStart: () -> Unit,
internal val onDragEnd: (Int, Int) -> Unit,
Expand Down

0 comments on commit 4014675

Please sign in to comment.