Modal<T extends InputBase>.ok constructor

Modal<T extends InputBase>.ok(
  1. String panelText, {
  2. bool showCancel = false,
  3. PanelBorder borderType = PanelBorder.single,
  4. int? padding,
  5. Color? panelTextColor,
  6. Color? actionTextColor,
  7. Color? backgroundColor,
  8. Color? borderColor,
  9. Object? okResult,
  10. Object? cancelResult,
})

Creates a simple modal with "OK" (enter key) and optionally "Cancel" (esc key) actions. The modal panel will be rendered in the center of the Terminal that is used to render the modal's Layer.

Implementation

factory Modal.ok(String panelText,
    {bool showCancel = false,
    PanelBorder borderType = PanelBorder.single,
    int? padding,
    Color? panelTextColor,
    Color? actionTextColor,
    Color? backgroundColor,
    Color? borderColor,
    Object? okResult,
    Object? cancelResult}) {
  var actionText = showCancel ? _okCancelText : _okText;

  var modal = Modal<T>.builder(panelText, actionText,
      borderType: borderType,
      padding: padding ?? 1,
      panelTextColor: panelTextColor,
      actionTextColor: actionTextColor,
      backgroundColor: backgroundColor,
      borderColor: borderColor);

  modal.onOk = () {
    modal.ui.pop(okResult);
  };

  if (showCancel) {
    modal.onCancel = () {
      modal.ui.pop(cancelResult);
    };
  }

  return modal;
}