Skip to content

Commit c0d478e

Browse files
authored
Merge pull request #432 from TimeFinderApp/default-action
Configure `CupertinoActionButton` `isDefaultAction` property when needed
2 parents b986f7a + 1e6ab75 commit c0d478e

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

lib/src/upgrade_alert.dart

+29-8
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,28 @@ class UpgradeAlertState extends State<UpgradeAlert> {
321321
)));
322322
final actions = <Widget>[
323323
if (showIgnore)
324-
button(cupertino, messages.message(UpgraderMessage.buttonTitleIgnore),
325-
context, () => onUserIgnored(context, true)),
324+
button(
325+
cupertino: cupertino,
326+
text: messages.message(UpgraderMessage.buttonTitleIgnore),
327+
context: context,
328+
onPressed: () => onUserIgnored(context, true),
329+
isDefaultAction: false,
330+
),
326331
if (showLater)
327-
button(cupertino, messages.message(UpgraderMessage.buttonTitleLater),
328-
context, () => onUserLater(context, true)),
329-
button(cupertino, messages.message(UpgraderMessage.buttonTitleUpdate),
330-
context, () => onUserUpdated(context, !widget.upgrader.blocked())),
332+
button(
333+
cupertino: cupertino,
334+
text: messages.message(UpgraderMessage.buttonTitleLater),
335+
context: context,
336+
onPressed: () => onUserLater(context, true),
337+
isDefaultAction: false,
338+
),
339+
button(
340+
cupertino: cupertino,
341+
text: messages.message(UpgraderMessage.buttonTitleUpdate),
342+
context: context,
343+
onPressed: () => onUserUpdated(context, !widget.upgrader.blocked()),
344+
isDefaultAction: true,
345+
),
331346
];
332347

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

340-
Widget button(bool cupertino, String? text, BuildContext context,
341-
VoidCallback? onPressed) {
355+
Widget button({
356+
required bool cupertino,
357+
String? text,
358+
required BuildContext context,
359+
VoidCallback? onPressed,
360+
bool isDefaultAction = false,
361+
}) {
342362
return cupertino
343363
? CupertinoDialogAction(
344364
textStyle: widget.cupertinoButtonTextStyle,
345365
onPressed: onPressed,
366+
isDefaultAction: isDefaultAction,
346367
child: Text(text ?? ''))
347368
: TextButton(onPressed: onPressed, child: Text(text ?? ''));
348369
}

0 commit comments

Comments
 (0)