alertDialog method
Widget
alertDialog(
- Key? key,
- String title,
- String message,
- String? releaseNotes,
- BuildContext context,
- bool cupertino,
- HcUpgradeMessages messages,
Implementation
Widget alertDialog(
Key? key,
String title,
String message,
String? releaseNotes,
BuildContext context,
bool cupertino,
HcUpgradeMessages messages) {
// If installed version is below minimum app version, or is a critical update,
// disable ignore and later buttons.
final isBlocked = widget.upgrade.blocked();
final showIgnore = isBlocked ? false : widget.showIgnore;
final showLater = isBlocked ? false : widget.showLater;
Widget? notes;
if (releaseNotes != null) {
notes = Padding(
padding: const EdgeInsets.only(top: 15.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: cupertino
? CrossAxisAlignment.center
: CrossAxisAlignment.start,
children: <Widget>[
Text(messages.message(HcUpgradeMessage.releaseNotes) ?? '',
style: const TextStyle(fontWeight: FontWeight.bold)),
Text(releaseNotes),
],
));
}
final textTitle = Column(
children: [
Text(title, key: const Key('upgrade.dialog.title'), style: HcAppTextStyle.boldTextStyle(size: 20),),
Divider(color: widget.buttonBorderColor,)
],
);
final content = Container(
constraints: const BoxConstraints(maxHeight: 400),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment:
cupertino ? CrossAxisAlignment.center : CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(message),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: Text(messages.message(HcUpgradeMessage.prompt) ?? '')),
if (notes != null) notes,
],
)));
final actions = <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (showIgnore)
button(cupertino, messages.message(HcUpgradeMessage.buttonTitleIgnore),
context, () => onUserIgnored(context, true), widget.ignoreColor),
if (showLater)
button(cupertino, messages.message(HcUpgradeMessage.buttonTitleLater),
context, () => onUserLater(context, true), widget.laterColor),
button(cupertino, messages.message(HcUpgradeMessage.buttonTitleUpdate),
context, () => onUserUpdated(context, !widget.upgrade.blocked()), widget.primaryColor),
],
)
];
return cupertino
? CupertinoAlertDialog(
key: key, title: textTitle, content: content, actions: actions)
: AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
key: key, title: textTitle, content: content, actions: actions);
}