Skip to content

Commit

Permalink
chore: shuffling all items will put current item at first #88
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Dec 29, 2023
1 parent 17d917d commit 40fa467
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/controller/miniplayer_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,18 @@ class MiniPlayerController {
bool bounceUp = false;
bool bounceDown = false;

void animateQueueToCurrentTrack({bool jump = false}) {
void animateQueueToCurrentTrack({bool jump = false, bool minZero = false}) {
if (queueScrollController.hasClients) {
final trackTileItemScrollOffsetInQueue = Dimensions.inst.trackTileItemExtent * Player.inst.currentIndex - screenSize.height * 0.3;
if (queueScrollController.positions.lastOrNull?.pixels == trackTileItemScrollOffsetInQueue) {
return;
}
final finalOffset = minZero ? trackTileItemScrollOffsetInQueue.withMinimum(0) : trackTileItemScrollOffsetInQueue;
if (jump) {
queueScrollController.jumpTo(trackTileItemScrollOffsetInQueue);
queueScrollController.jumpTo(finalOffset);
} else {
queueScrollController.animateToEff(
trackTileItemScrollOffsetInQueue,
finalOffset,
duration: const Duration(milliseconds: 600),
curve: Curves.fastEaseInToSlowEaseOut,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/controller/player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class Player {
} else {
_audioHandler.shuffleAllItems((element) => (element as YoutubeID).id);
}
MiniPlayerController.inst.animateQueueToCurrentTrack(jump: true);
MiniPlayerController.inst.animateQueueToCurrentTrack(jump: true, minZero: true);
} else {
await _audioHandler.shuffleNextItems();
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dependencies:
basic_audio_handler:
git:
url: https://github.com/namidaco/basic_audio_handler
ref: 5192bd8c8510ab6e1f656c7f06fc0b76725e027e
ref: 6cbc29797efc9eb68fec639028cf0fdb615e4243
on_audio_query:
git:
url: https://github.com/MSOB7YY/on_audio_query
Expand Down

0 comments on commit 40fa467

Please sign in to comment.