xLayout_AddBTN_Widget method

Widget xLayout_AddBTN_Widget()

Override per cambiare il Bottone di aggiunta nell'Elenco

Implementation

Widget xLayout_AddBTN_Widget() {
  return XBtnbase(
    margin: EdgeInsets.only(left: 5),
    width: 150,
    icon_WidthArea: 30,
    toolTip_Message: "Aggiungi ${xUI_AddNewCmd_Caption ?? widget.title_Text}",
    icon: Icons.add,
    icon_Size: 20,
    label: (xUI_AddNewCmd_Caption ?? widget.title_Text),
    label_Style: XStyles.xStyTextForSubLabel(textColor: widget.title_Color ?? widget.searchBar_Color),
    icon_Color: widget.title_Color ?? widget.searchBar_Color,
    backGroundColor: Colors.grey[900],
    onPressed: widget.cmd_Add != null && widget.xCells_EditType!.value != XEnums.editType.scheda.value
        ? () async => await widget.cmd_Add!(setState).then((value) async => initXFilters()).then((value) => onComeBack()) //
        : () async {
            if (widget.xCells_EditType!.value == XEnums.editType.scheda.value) {
              await widget.cmd_Add!(setState).then((value) async => initXFilters()).then((value) => onComeBack());
            } else if (widget.xCells_EditType!.value == XEnums.editType.form.value) {
              var xclObj = XFDataItem(Uuid().v4(), isNew: true);
              var _view = XView("AddView");
              _view.cols.addAll(widget.liCols_EditData!);
              var res = await xPreview_Dialog(widget.liCols_EditData!.isEmpty ? widget.xView_ForEditItem ?? widget.view ?? widget.viewDetts! : _view, xclObj as K);
              await xOnAfter_AddCMD(res as K?);
              if (res != null) {
                if (widget.liDetts != null) {
                  widget.liDetts!.add(res);
                } else {
                  list.add(res);
                }
              }
            } else if (widget.xCells_EditType!.value == XEnums.editType.stepByStep.value) {
              var xclObj = XFDataItem(Uuid().v4(), isNew: true);
              var _view = XView("AddView");
              _view.cols.addAll(widget.liCols_EditData!);
              var res = await xEditDialog_xOnAddItem(widget.liCols_EditData!.isEmpty ? widget.xView_ForEditItem ?? widget.view ?? widget.viewDetts! : _view, xclObj, setState);
              await xOnAfter_AddCMD(res as K?);
              if (res != null) {
                if (widget.liDetts != null) {
                  widget.liDetts!.add(res);
                } else {
                  list.add(res);
                }
              }
            } else {
              if (widget.isEditable) {
                var xclObj = XFDataItem(Uuid().v4(), isNew: true);
                if (widget.liDetts != null) {
                  widget.liDetts!.add(xclObj);
                } else {
                  list.add(xclObj as K);
                }
              } else {
                var xclObj = XFDataItem(Uuid().v4(), isNew: true);
                var _view = XView("AddView");
                _view.cols.addAll(widget.liCols_EditData!);
                var res = await xPreview_Dialog(widget.liCols_EditData!.isEmpty ? widget.xView_ForEditItem ?? widget.view ?? widget.viewDetts! : _view, xclObj as K);
                await xOnAfter_AddCMD(res as K?);
                if (res != null) {
                  if (widget.liDetts != null) {
                    widget.liDetts!.add(res);
                  } else {
                    list.add(res);
                  }
                }
              }
            }
          },
  );
}