mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Created comments form
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user