You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
diplomatic-quarter/lib/widgets/dialogs/confirm_dialog.dart

58 lines
1.4 KiB
Dart

import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class ConfirmDialog {
final BuildContext context;
final title;
final confirmMessage;
final okText;
final cancelText;
final Function okFunction;
final Function cancelFunction;
ConfirmDialog(
{@required this.context,
this.title,
@required this.confirmMessage,
@required this.okText,
@required this.cancelText,
@required this.okFunction,
@required this.cancelFunction});
showAlertDialog(BuildContext context) {
// set up the buttons
Widget cancelButton = FlatButton(
child: Texts(this.cancelText),
onPressed: () {
Navigator.of(context).pop();
});
Widget continueButton = FlatButton(child: Texts(okText), onPressed: okFunction);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: title != null ? Text(title) : Text(TranslationBase.of(context).confirm),
content: Text(this.confirmMessage),
actions: [
cancelButton,
continueButton,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
static closeAlertDialog(BuildContext context) {
Navigator.of(context).pop();
}
}