Skip to content

Commit

Permalink
Merge pull request #432 from TimeFinderApp/default-action
Browse files Browse the repository at this point in the history
Configure `CupertinoActionButton` `isDefaultAction` property when needed
  • Loading branch information
larryaasen authored Sep 13, 2024
2 parents b986f7a + 1e6ab75 commit c0d478e
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions lib/src/upgrade_alert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,28 @@ class UpgradeAlertState extends State<UpgradeAlert> {
)));
final actions = <Widget>[
if (showIgnore)
button(cupertino, messages.message(UpgraderMessage.buttonTitleIgnore),
context, () => onUserIgnored(context, true)),
button(
cupertino: cupertino,
text: messages.message(UpgraderMessage.buttonTitleIgnore),
context: context,
onPressed: () => onUserIgnored(context, true),
isDefaultAction: false,
),
if (showLater)
button(cupertino, messages.message(UpgraderMessage.buttonTitleLater),
context, () => onUserLater(context, true)),
button(cupertino, messages.message(UpgraderMessage.buttonTitleUpdate),
context, () => onUserUpdated(context, !widget.upgrader.blocked())),
button(
cupertino: cupertino,
text: messages.message(UpgraderMessage.buttonTitleLater),
context: context,
onPressed: () => onUserLater(context, true),
isDefaultAction: false,
),
button(
cupertino: cupertino,
text: messages.message(UpgraderMessage.buttonTitleUpdate),
context: context,
onPressed: () => onUserUpdated(context, !widget.upgrader.blocked()),
isDefaultAction: true,
),
];

return cupertino
Expand All @@ -337,12 +352,18 @@ class UpgradeAlertState extends State<UpgradeAlert> {
key: key, title: textTitle, content: content, actions: actions);
}

Widget button(bool cupertino, String? text, BuildContext context,
VoidCallback? onPressed) {
Widget button({
required bool cupertino,
String? text,
required BuildContext context,
VoidCallback? onPressed,
bool isDefaultAction = false,
}) {
return cupertino
? CupertinoDialogAction(
textStyle: widget.cupertinoButtonTextStyle,
onPressed: onPressed,
isDefaultAction: isDefaultAction,
child: Text(text ?? ''))
: TextButton(onPressed: onPressed, child: Text(text ?? ''));
}
Expand Down

0 comments on commit c0d478e

Please sign in to comment.