diff --git a/lib/components/library/user_local_tracks.dart b/lib/components/library/user_local_tracks.dart index 28fa97c1..0df439b2 100644 --- a/lib/components/library/user_local_tracks.dart +++ b/lib/components/library/user_local_tracks.dart @@ -282,6 +282,27 @@ class UserLocalTracks extends HookConsumerWidget { currentTrack: track, ); }, + actions: [ + PopupMenuButton( + icon: const Icon(SpotubeIcons.moreHorizontal), + itemBuilder: (context) { + return [ + PopupMenuItem( + value: "delete", + onTap: () async { + await File(track.path).delete(); + ref.refresh(localTracksProvider); + }, + padding: EdgeInsets.zero, + child: const ListTile( + leading: Icon(SpotubeIcons.trash), + title: Text("Delete"), + ), + ), + ]; + }, + ), + ], ); }, ), diff --git a/lib/components/shared/track_table/track_tile.dart b/lib/components/shared/track_table/track_tile.dart index 1e963c47..2fda59c7 100644 --- a/lib/components/shared/track_table/track_tile.dart +++ b/lib/components/shared/track_table/track_tile.dart @@ -41,6 +41,8 @@ class TrackTile extends HookConsumerWidget { final bool isLocal; final void Function(bool?)? onCheckChange; + final List? actions; + TrackTile( this.playlist, { required this.track, @@ -54,6 +56,7 @@ class TrackTile extends HookConsumerWidget { this.showCheck = false, this.isLocal = false, this.onCheckChange, + this.actions, Key? key, }) : super(key: key); @@ -396,6 +399,7 @@ class TrackTile extends HookConsumerWidget { ) ], ), + ...?actions, ], ), ), diff --git a/lib/pages/settings/settings.dart b/lib/pages/settings/settings.dart index 2e28204e..ffacd212 100644 --- a/lib/pages/settings/settings.dart +++ b/lib/pages/settings/settings.dart @@ -13,6 +13,7 @@ import 'package:spotube/components/shared/adaptive/adaptive_list_tile.dart'; import 'package:spotube/components/shared/page_window_title_bar.dart'; import 'package:spotube/collections/spotify_markets.dart'; import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/downloader_provider.dart'; import 'package:spotube/provider/user_preferences_provider.dart'; import 'package:url_launcher/url_launcher_string.dart'; @@ -23,6 +24,8 @@ class SettingsPage extends HookConsumerWidget { Widget build(BuildContext context, ref) { final UserPreferences preferences = ref.watch(userPreferencesProvider); final auth = ref.watch(AuthenticationNotifier.provider); + final isDownloading = + ref.watch(downloaderProvider.select((s) => s.currentlyRunning > 0)); final theme = Theme.of(context); final pickColorScheme = useCallback(() { @@ -297,15 +300,21 @@ class SettingsPage extends HookConsumerWidget { style: theme.textTheme.headlineSmall ?.copyWith(fontWeight: FontWeight.bold), ), - ListTile( - leading: const Icon(SpotubeIcons.download), - title: const Text("Download Location"), - subtitle: Text(preferences.downloadLocation), - trailing: FilledButton( - onPressed: pickDownloadLocation, - child: const Icon(SpotubeIcons.folder), + Tooltip( + message: isDownloading + ? "Please wait for the current download to finish" + : null, + child: ListTile( + leading: const Icon(SpotubeIcons.download), + title: const Text("Download Location"), + subtitle: Text(preferences.downloadLocation), + trailing: FilledButton( + onPressed: + isDownloading ? null : pickDownloadLocation, + child: const Icon(SpotubeIcons.folder), + ), + onTap: isDownloading ? null : pickDownloadLocation, ), - onTap: pickDownloadLocation, ), SwitchListTile( secondary: const Icon(SpotubeIcons.lyrics), diff --git a/lib/provider/downloader_provider.dart b/lib/provider/downloader_provider.dart index c12ec644..3f0de0b8 100644 --- a/lib/provider/downloader_provider.dart +++ b/lib/provider/downloader_provider.dart @@ -50,7 +50,6 @@ class Downloader with ChangeNotifier { notifyListeners(); // Using android Audio Focus to keep the app run in background - // _playback.mobileAudioService?.session?.setActive(true); grabberQueue.add(() async { final track = await SpotubeTrack.fetchFromTrack( baseTrack, @@ -139,9 +138,6 @@ class Downloader with ChangeNotifier { } finally { currentlyRunning--; inQueue.removeWhere((t) => t.id == track.id); - // if (currentlyRunning == 0 && !PlaylistProvider.isPlaying) { - // _playback.mobileAudioService?.session?.setActive(false); - // } notifyListeners(); } });