Skip to content

Commit

Permalink
Disable and grey out clear queue button when the queue is empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
amugofjava committed Oct 30, 2023
1 parent 076289e commit a0a2bc3
Showing 1 changed file with 50 additions and 40 deletions.
90 changes: 50 additions & 40 deletions lib/ui/podcast/up_next_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,48 +67,58 @@ class UpNextView extends StatelessWidget {
Padding(
padding: const EdgeInsets.fromLTRB(16.0, 0.0, 24.0, 8.0),
child: TextButton(
onPressed: () {
showPlatformDialog<void>(
context: context,
useRootNavigator: false,
builder: (_) => BasicDialogAlert(
title: Text(
L.of(context)!.queue_clear_label_title,
),
content: Text(L.of(context)!.queue_clear_label),
actions: <Widget>[
BasicDialogAction(
title: ActionText(
L.of(context)!.cancel_button_label,
),
onPressed: () {
Navigator.pop(context);
},
),
BasicDialogAction(
title: ActionText(
Theme.of(context).platform == TargetPlatform.iOS
? L.of(context)!.queue_clear_button_label.toUpperCase()
: L.of(context)!.queue_clear_button_label,
onPressed: snapshot.hasData && snapshot.data!.queue.isEmpty
? null
: () {
showPlatformDialog<void>(
context: context,
useRootNavigator: false,
builder: (_) => BasicDialogAlert(
title: Text(
L.of(context)!.queue_clear_label_title,
),
content: Text(L.of(context)!.queue_clear_label),
actions: <Widget>[
BasicDialogAction(
title: ActionText(
L.of(context)!.cancel_button_label,
),
onPressed: () {
Navigator.pop(context);
},
),
BasicDialogAction(
title: ActionText(
Theme.of(context).platform == TargetPlatform.iOS
? L.of(context)!.queue_clear_button_label.toUpperCase()
: L.of(context)!.queue_clear_button_label,
),
iosIsDefaultAction: true,
iosIsDestructiveAction: true,
onPressed: () {
queueBloc.queueEvent(QueueClearEvent());
Navigator.pop(context);
},
),
],
),
iosIsDefaultAction: true,
iosIsDestructiveAction: true,
onPressed: () {
queueBloc.queueEvent(QueueClearEvent());
Navigator.pop(context);
},
),
],
),
);
},
child: Text(
L.of(context)!.clear_queue_button_label,
style: Theme.of(context).textTheme.titleSmall!.copyWith(
fontSize: 12.0,
color: Theme.of(context).primaryColor,
);
},
child: snapshot.hasData && snapshot.data!.queue.isEmpty
? Text(
L.of(context)!.clear_queue_button_label,
style: Theme.of(context).textTheme.titleSmall!.copyWith(
fontSize: 12.0,
color: Theme.of(context).disabledColor,
),
)
: Text(
L.of(context)!.clear_queue_button_label,
style: Theme.of(context).textTheme.titleSmall!.copyWith(
fontSize: 12.0,
color: Theme.of(context).primaryColor,
),
),
),
),
),
],
Expand Down

0 comments on commit a0a2bc3

Please sign in to comment.