@@ -511,75 +511,84 @@ class _PlaylistPageState extends State<PlaylistPage> {
511511 return const SizedBox .shrink ();
512512 }
513513
514- return ValueListenableBuilder <List <dynamic >>(
515- valueListenable: offlinePlaylistService.offlinePlaylists,
516- builder: (context, offlinePlaylists, _) {
517- playlistOfflineStatus = offlinePlaylistService.isPlaylistDownloaded (
518- playlistId,
519- );
520-
521- if (playlistOfflineStatus) {
522- return IconButton .filled (
523- icon: Icon (
524- FluentIcons .arrow_download_off_24_filled,
525- color: Theme .of (context).colorScheme.onPrimary,
526- ),
527- iconSize: 24 ,
528- onPressed: () => _showRemoveOfflineDialog (playlistId),
529- tooltip: context.l10n! .removeOffline,
530- );
531- }
532-
533- return ValueListenableBuilder <DownloadProgress >(
534- valueListenable: offlinePlaylistService.getProgressNotifier (
535- playlistId,
536- ),
537- builder: (context, progress, _) {
538- final isDownloading = offlinePlaylistService.isPlaylistDownloading (
539- playlistId,
540- );
541-
542- if (isDownloading) {
543- return SizedBox (
544- width: 48 ,
545- height: 48 ,
546- child: Stack (
547- alignment: Alignment .center,
548- children: [
549- SizedBox (
550- width: 40 ,
551- height: 40 ,
552- child: CircularProgressIndicator (
553- value: progress.progress,
554- strokeWidth: 3 ,
555- backgroundColor: Theme .of (
556- context,
557- ).colorScheme.primaryContainer,
558- ),
559- ),
560- IconButton (
561- icon: const Icon (FluentIcons .dismiss_24_filled, size: 16 ),
562- onPressed: () => offlinePlaylistService.cancelDownload (
563- context,
564- playlistId,
565- ),
566- tooltip: context.l10n! .cancel,
567- ),
568- ],
514+ return ValueListenableBuilder <int >(
515+ valueListenable: currentOfflineSongsLength,
516+ builder: (context, _, __) {
517+ return ValueListenableBuilder <List <dynamic >>(
518+ valueListenable: offlinePlaylistService.offlinePlaylists,
519+ builder: (context, offlinePlaylists, _) {
520+ final playlistSongs = _playlist? ['list' ] as List ? ?? [];
521+ playlistOfflineStatus = isPlaylistFullyOffline (playlistSongs);
522+
523+ if (playlistOfflineStatus) {
524+ return IconButton .filled (
525+ icon: Icon (
526+ FluentIcons .arrow_download_off_24_filled,
527+ color: Theme .of (context).colorScheme.onPrimary,
569528 ),
529+ iconSize: 24 ,
530+ onPressed: () => _showRemoveOfflineDialog (playlistId),
531+ tooltip: context.l10n! .removeOffline,
570532 );
571533 }
572534
573- if (offlineMode.value) {
574- return const SizedBox .shrink ();
575- }
576-
577- return IconButton .filledTonal (
578- icon: const Icon (FluentIcons .arrow_download_24_filled),
579- iconSize: 24 ,
580- onPressed: () =>
581- offlinePlaylistService.downloadPlaylist (context, _playlist),
582- tooltip: context.l10n! .downloadPlaylist,
535+ return ValueListenableBuilder <DownloadProgress >(
536+ valueListenable: offlinePlaylistService.getProgressNotifier (
537+ playlistId,
538+ ),
539+ builder: (context, progress, _) {
540+ final isDownloading =
541+ offlinePlaylistService.isPlaylistDownloading (playlistId);
542+
543+ if (isDownloading) {
544+ return SizedBox (
545+ width: 48 ,
546+ height: 48 ,
547+ child: Stack (
548+ alignment: Alignment .center,
549+ children: [
550+ SizedBox (
551+ width: 40 ,
552+ height: 40 ,
553+ child: CircularProgressIndicator (
554+ value: progress.progress,
555+ strokeWidth: 3 ,
556+ backgroundColor: Theme .of (
557+ context,
558+ ).colorScheme.primaryContainer,
559+ ),
560+ ),
561+ IconButton (
562+ icon: const Icon (
563+ FluentIcons .dismiss_24_filled,
564+ size: 16 ,
565+ ),
566+ onPressed: () =>
567+ offlinePlaylistService.cancelDownload (
568+ context,
569+ playlistId,
570+ ),
571+ tooltip: context.l10n! .cancel,
572+ ),
573+ ],
574+ ),
575+ );
576+ }
577+
578+ if (offlineMode.value) {
579+ return const SizedBox .shrink ();
580+ }
581+
582+ return IconButton .filledTonal (
583+ icon: const Icon (FluentIcons .arrow_download_24_filled),
584+ iconSize: 24 ,
585+ onPressed: () => offlinePlaylistService.downloadPlaylist (
586+ context,
587+ _playlist,
588+ ),
589+ tooltip: context.l10n! .downloadPlaylist,
590+ );
591+ },
583592 );
584593 },
585594 );
0 commit comments