Skip to content

Commit

Permalink
fix: Prevent multiple Tap when importing Playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
khaled-0 committed Dec 2, 2024
1 parent 00f609a commit 368679e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/app/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class _HomeTabState extends State<HomeTab> {
showDialog(
context: context,
useRootNavigator: true,
barrierDismissible: false,
builder: (_) => ChangeNotifierProvider.value(
value: context.read<LibraryProvider>(),
child: ImportPlaylistDialog(url: url),
Expand Down
21 changes: 14 additions & 7 deletions lib/app/library/import_playlist_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class _ImportPlaylistDialogState extends State<ImportPlaylistDialog> {
String? error;

Future<void> tryImportPlaylist() async {
if (loading) return;
try {
error = null;
setState(() => loading = true);
Expand Down Expand Up @@ -95,8 +96,9 @@ class _ImportPlaylistDialogState extends State<ImportPlaylistDialog> {
error!,
maxLines: 3,
overflow: TextOverflow.ellipsis,
style:
TextStyle(color: Theme.of(context).colorScheme.error),
style: TextStyle(
color: Theme.of(context).colorScheme.error,
),
),
),
),
Expand All @@ -105,11 +107,16 @@ class _ImportPlaylistDialogState extends State<ImportPlaylistDialog> {
),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text("Cancel"),
),
FilledButton(onPressed: tryImportPlaylist, child: const Text("Import"))
if (!loading)
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text("Cancel"),
),
if (!loading)
FilledButton(
onPressed: tryImportPlaylist,
child: const Text("Import"),
),
],
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/app/library/library_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class LibraryTab extends StatelessWidget {
void onPressed() => showDialog(
context: context,
useRootNavigator: true,
barrierDismissible: false,
builder: (_) => ChangeNotifierProvider.value(
value: context.read<LibraryProvider>(),
child: const ImportPlaylistDialog(),
Expand Down

0 comments on commit 368679e

Please sign in to comment.