Skip to content

Commit 555af2d

Browse files
authored
feat: Add shuffle for liked songs, offline songs end recently played songs (#758)
1 parent 9f7e8f8 commit 555af2d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/screens/user_songs_page.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class _UserSongsPageState extends State<UserSongsPage> {
189189
runSpacing: 8,
190190
children: [
191191
if (songsLength > 0) _buildPlayButton(primaryColor, title),
192+
if (songsLength > 0) _buildShufflePlayButton(primaryColor),
192193
if (isRecentlyPlayed && songsLength > 0)
193194
_buildClearRecentsButton(primaryColor),
194195
],
@@ -276,6 +277,29 @@ class _UserSongsPageState extends State<UserSongsPage> {
276277
);
277278
}
278279

280+
Widget _buildShufflePlayButton(Color primaryColor) {
281+
return IconButton.filledTonal(
282+
icon: Icon(FluentIcons.arrow_shuffle_24_filled, color: primaryColor),
283+
iconSize: 24,
284+
tooltip: 'Shuffle play',
285+
onPressed: () async {
286+
final songsList = getSongsList(widget.page);
287+
if (songsList.isEmpty) return;
288+
289+
final shuffledSongs = List<Map>.from(songsList.whereType<Map>());
290+
if (shuffledSongs.isEmpty) return;
291+
292+
shuffledSongs.shuffle();
293+
294+
await audioHandler.addPlaylistToQueue(
295+
shuffledSongs,
296+
replace: true,
297+
startIndex: 0,
298+
);
299+
},
300+
);
301+
}
302+
279303
Widget _buildClearRecentsButton(Color primaryColor) {
280304
return IconButton.filledTonal(
281305
icon: Icon(FluentIcons.delete_24_regular, color: primaryColor),

0 commit comments

Comments
 (0)