mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
feat(local_tracks): delete local track (#484)
This commit is contained in:
parent
fd1846eecf
commit
52835b2ce2
@ -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"),
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -41,6 +41,8 @@ class TrackTile extends HookConsumerWidget {
|
||||
final bool isLocal;
|
||||
final void Function(bool?)? onCheckChange;
|
||||
|
||||
final List<Widget>? 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,
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -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(
|
||||
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: pickDownloadLocation,
|
||||
onPressed:
|
||||
isDownloading ? null : pickDownloadLocation,
|
||||
child: const Icon(SpotubeIcons.folder),
|
||||
),
|
||||
onTap: pickDownloadLocation,
|
||||
onTap: isDownloading ? null : pickDownloadLocation,
|
||||
),
|
||||
),
|
||||
SwitchListTile(
|
||||
secondary: const Icon(SpotubeIcons.lyrics),
|
||||
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user