import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class ConfirmDialog {
  final BuildContext context;

  final confirmMessage;
  final okText;
  final cancelText;
  final Function okFunction;
  final Function cancelFunction;

  ConfirmDialog(
      {@required this.context,
      @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: Text(this.cancelText),
        onPressed: () {
          Navigator.of(context).pop();
        });
    Widget continueButton =
        FlatButton(child: Text(this.okText), onPressed: this.okFunction);

    // set up the AlertDialog
    AlertDialog alert = AlertDialog(
      title: Text(TranslationBase.of(context).confirm),
      content: Text(this.confirmMessage),
      actions: [
        cancelButton,
        continueButton,
      ],
    );

    // show the dialog
    showDialog(
      barrierDismissible: false,
      context: context,
      builder: (BuildContext context) {
        return alert;
      },
    );
  }

  static closeAlertDialog(BuildContext context) {
    Navigator.of(context).pop();
  }

}
