1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 08:15:16 +00:00

Created comments form

This commit is contained in:
2019-05-18 09:45:15 +02:00
parent 28de22f427
commit c267940ce6
2 changed files with 167 additions and 18 deletions

View File

@ -118,3 +118,36 @@ Future<String> askUserString({
return controller.text;
}
/// Show an alert dialog to get user confirmation for something
///
/// Return value of this function is never null
Future<bool> askUserConfirmation({
@required BuildContext context,
String title,
@required String message,
}) async {
if (title == null) title = tr("Confirm operation");
final result = await showDialog<bool>(
context: context,
builder: (c) => AlertDialog(
title: Text(title),
content: Text(message),
actions: <Widget>[
FlatButton(
onPressed: () => Navigator.pop(context, false),
child: Text(tr("Cancel").toUpperCase()),
),
FlatButton(
onPressed: () => Navigator.pop(context, true),
child: Text(
tr("Confirm").toUpperCase(),
style: TextStyle(color: Colors.red),
),
),
],
));
return result != null && result;
}