@@ -74,6 +74,54 @@ class _ArtistScreenState extends State<ArtistScreen> {
7474 }
7575 }
7676
77+ Future <void > _addArtistToQueue () async {
78+ if (_albums.isEmpty) return ;
79+
80+ final playerProvider = Provider .of <PlayerProvider >(context, listen: false );
81+ final libraryProvider = Provider .of <LibraryProvider >(context, listen: false );
82+ final subsonicService = libraryProvider.subsonicService;
83+
84+ final messenger = ScaffoldMessenger .of (context);
85+ final loc = AppLocalizations .of (context);
86+
87+ try {
88+ final songsToQueue = < Song > [];
89+ for (final album in _albums) {
90+ final albumSongs = libraryProvider.isLocalOnlyMode
91+ ? libraryProvider.cachedAllSongs
92+ .where ((s) => s.albumId == album.id)
93+ .toList ()
94+ : await subsonicService.getAlbumSongs (album.id);
95+
96+ songsToQueue.addAll (albumSongs);
97+ }
98+
99+ if (songsToQueue.isNotEmpty) {
100+ playerProvider.addAllToQueue (songsToQueue);
101+ }
102+
103+ if (! mounted) return ;
104+
105+ final addedToQueueMessage = loc? .addedArtistToQueue ?? 'Added artist to Queue' ;
106+ messenger.showSnackBar (
107+ SnackBar (
108+ content: Text (addedToQueueMessage),
109+ duration: const Duration (seconds: 2 ),
110+ ),
111+ );
112+ } catch (e) {
113+ if (! mounted) return ;
114+
115+ final addedToQueueErrorMessage = loc? .addedArtistToQueueError ?? 'Failed adding artist to Queue' ;
116+ messenger.showSnackBar (
117+ SnackBar (
118+ content: Text (addedToQueueErrorMessage),
119+ duration: const Duration (seconds: 2 ),
120+ ),
121+ );
122+ }
123+ }
124+
77125 void _playTopSongs ({bool shuffle = false }) {
78126 if (_topSongs.isEmpty) return ;
79127
@@ -144,6 +192,11 @@ class _ArtistScreenState extends State<ArtistScreen> {
144192 ),
145193 ),
146194 actions: [
195+ IconButton (
196+ icon: const Icon (Icons .queue_music_rounded),
197+ tooltip: AppLocalizations .of (context)! .addToQueue,
198+ onPressed: _albums.isEmpty ? null : () => _addArtistToQueue (),
199+ ),
147200 IconButton (
148201 icon: const Icon (CupertinoIcons .play_circle_fill),
149202 onPressed: () => _playTopSongs (),
0 commit comments