mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05: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,
|
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 bool isLocal;
|
||||||
final void Function(bool?)? onCheckChange;
|
final void Function(bool?)? onCheckChange;
|
||||||
|
|
||||||
|
final List<Widget>? actions;
|
||||||
|
|
||||||
TrackTile(
|
TrackTile(
|
||||||
this.playlist, {
|
this.playlist, {
|
||||||
required this.track,
|
required this.track,
|
||||||
@ -54,6 +56,7 @@ class TrackTile extends HookConsumerWidget {
|
|||||||
this.showCheck = false,
|
this.showCheck = false,
|
||||||
this.isLocal = false,
|
this.isLocal = false,
|
||||||
this.onCheckChange,
|
this.onCheckChange,
|
||||||
|
this.actions,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(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/components/shared/page_window_title_bar.dart';
|
||||||
import 'package:spotube/collections/spotify_markets.dart';
|
import 'package:spotube/collections/spotify_markets.dart';
|
||||||
import 'package:spotube/provider/authentication_provider.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:spotube/provider/user_preferences_provider.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
|
||||||
@ -23,6 +24,8 @@ class SettingsPage extends HookConsumerWidget {
|
|||||||
Widget build(BuildContext context, ref) {
|
Widget build(BuildContext context, ref) {
|
||||||
final UserPreferences preferences = ref.watch(userPreferencesProvider);
|
final UserPreferences preferences = ref.watch(userPreferencesProvider);
|
||||||
final auth = ref.watch(AuthenticationNotifier.provider);
|
final auth = ref.watch(AuthenticationNotifier.provider);
|
||||||
|
final isDownloading =
|
||||||
|
ref.watch(downloaderProvider.select((s) => s.currentlyRunning > 0));
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
final pickColorScheme = useCallback(() {
|
final pickColorScheme = useCallback(() {
|
||||||
@ -297,15 +300,21 @@ class SettingsPage extends HookConsumerWidget {
|
|||||||
style: theme.textTheme.headlineSmall
|
style: theme.textTheme.headlineSmall
|
||||||
?.copyWith(fontWeight: FontWeight.bold),
|
?.copyWith(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
ListTile(
|
Tooltip(
|
||||||
|
message: isDownloading
|
||||||
|
? "Please wait for the current download to finish"
|
||||||
|
: null,
|
||||||
|
child: ListTile(
|
||||||
leading: const Icon(SpotubeIcons.download),
|
leading: const Icon(SpotubeIcons.download),
|
||||||
title: const Text("Download Location"),
|
title: const Text("Download Location"),
|
||||||
subtitle: Text(preferences.downloadLocation),
|
subtitle: Text(preferences.downloadLocation),
|
||||||
trailing: FilledButton(
|
trailing: FilledButton(
|
||||||
onPressed: pickDownloadLocation,
|
onPressed:
|
||||||
|
isDownloading ? null : pickDownloadLocation,
|
||||||
child: const Icon(SpotubeIcons.folder),
|
child: const Icon(SpotubeIcons.folder),
|
||||||
),
|
),
|
||||||
onTap: pickDownloadLocation,
|
onTap: isDownloading ? null : pickDownloadLocation,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
secondary: const Icon(SpotubeIcons.lyrics),
|
secondary: const Icon(SpotubeIcons.lyrics),
|
||||||
|
@ -50,7 +50,6 @@ class Downloader with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
// Using android Audio Focus to keep the app run in background
|
// Using android Audio Focus to keep the app run in background
|
||||||
// _playback.mobileAudioService?.session?.setActive(true);
|
|
||||||
grabberQueue.add(() async {
|
grabberQueue.add(() async {
|
||||||
final track = await SpotubeTrack.fetchFromTrack(
|
final track = await SpotubeTrack.fetchFromTrack(
|
||||||
baseTrack,
|
baseTrack,
|
||||||
@ -139,9 +138,6 @@ class Downloader with ChangeNotifier {
|
|||||||
} finally {
|
} finally {
|
||||||
currentlyRunning--;
|
currentlyRunning--;
|
||||||
inQueue.removeWhere((t) => t.id == track.id);
|
inQueue.removeWhere((t) => t.id == track.id);
|
||||||
// if (currentlyRunning == 0 && !PlaylistProvider.isPlaying) {
|
|
||||||
// _playback.mobileAudioService?.session?.setActive(false);
|
|
||||||
// }
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user