@@ -74,6 +74,48 @@ 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+ final messenger = ScaffoldMessenger .of (context);
84+
85+ try {
86+ final songsToQueue = < Song > [];
87+ for (final album in _albums) {
88+ final albumSongs = libraryProvider.isLocalOnlyMode
89+ ? libraryProvider.cachedAllSongs
90+ .where ((s) => s.albumId == album.id)
91+ .toList ()
92+ : await subsonicService.getAlbumSongs (album.id);
93+
94+ songsToQueue.addAll (albumSongs);
95+ }
96+
97+ if (songsToQueue.isNotEmpty) {
98+ playerProvider.addAllToQueue (songsToQueue);
99+ }
100+ // Show snackbar on success?
101+
102+ // messenger.showSnackBar(
103+ // SnackBar(
104+ // content: Text(AppLocalizations.of(context)!.addToQueue),
105+ // duration: const Duration(seconds: 2),
106+ // ),
107+ // );
108+ } catch (e) {
109+ if (! mounted) return ;
110+ messenger.showSnackBar (
111+ SnackBar (
112+ content: Text ('Error adding to queue: $e ' ), //Add localization for this error msg?
113+ duration: const Duration (seconds: 2 ),
114+ ),
115+ );
116+ }
117+ }
118+
77119 void _playTopSongs ({bool shuffle = false }) {
78120 if (_topSongs.isEmpty) return ;
79121
@@ -144,6 +186,11 @@ class _ArtistScreenState extends State<ArtistScreen> {
144186 ),
145187 ),
146188 actions: [
189+ IconButton (
190+ icon: const Icon (Icons .queue_music_rounded),
191+ tooltip: AppLocalizations .of (context)! .addToQueue,
192+ onPressed: _albums.isEmpty ? null : () => _addArtistToQueue (),
193+ ),
147194 IconButton (
148195 icon: const Icon (CupertinoIcons .play_circle_fill),
149196 onPressed: () => _playTopSongs (),
0 commit comments