-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add confirmation dialog before deleting downloaded album
- Loading branch information
Showing
2 changed files
with
52 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
lib/components/AlbumScreen/DownloadedAlbumDeleteDialog.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:get_it/get_it.dart'; | ||
|
||
import '../../models/JellyfinModels.dart'; | ||
import '../../services/DownloadsHelper.dart'; | ||
import '../errorSnackbar.dart'; | ||
|
||
class DownloadedAlbumDeleteDialog extends StatelessWidget { | ||
const DownloadedAlbumDeleteDialog({ | ||
Key? key, | ||
required this.items, | ||
required this.parent, | ||
}) : super(key: key); | ||
|
||
final List<BaseItemDto> items; | ||
final BaseItemDto parent; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final _downloadsHelper = GetIt.instance<DownloadsHelper>(); | ||
return AlertDialog( | ||
title: const Text("Are you sure?"), | ||
actions: [ | ||
TextButton( | ||
child: const Text("CANCEL"), | ||
onPressed: () => Navigator.of(context).pop(), | ||
), | ||
TextButton( | ||
child: const Text("DELETE"), | ||
onPressed: () { | ||
_downloadsHelper.deleteDownloads( | ||
jellyfinItemIds: items.map((e) => e.id).toList(), | ||
deletedFor: parent.id | ||
).onError((error, stackTrace) => errorSnackbar(error, context)); | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
const SnackBar(content: Text("Downloads deleted."))); | ||
Navigator.of(context).pop(); | ||
}, | ||
), | ||
], | ||
); | ||
} | ||
} |