xPreview_Dialog method

Future<XFDataItem?> xPreview_Dialog(
  1. XView xView,
  2. dynamic value
)

Preview con i vari DataEntry per l'aggiunta o modifica o visualizzazione di un Item che non ha scheda

Implementation

Future<XFDataItem?> xPreview_Dialog(XView xView, dynamic value) async {
  dynamic valueUI = value.getCloneFull();
  var liCols = xView.cols.where((element) => element.colKey.startsWith("li").not() && element.readOnly == false);
  var view_UI = XView("viewPreview");
  view_UI.cols.addAll(liCols);
  return await showDialog<XFDataItem>(
      context: context,
      barrierColor: Colors.black.withAlpha(230),
      builder: (context) {
        return StatefulBuilder(builder: (context, setState) {
          return Container(
              width: MediaQuery.of(context).size.width - 20,
              alignment: Alignment.center,
              child: SingleChildScrollView(
                  child: XAlertDialog(
                      actionsBTNarea_Padding: EdgeInsets.symmetric(horizontal: 5),
                      content_insetPadding: EdgeInsets.all(3),
                      content_VerticalPadding: 5,
                      width: isWeb ? null : MediaQuery.of(context).size.width - 20,
                      colorBackGround: XSchedaState.color_BackGround_EditDialog,
                      actionsBTNarea_Child: Container(
                          padding: EdgeInsets.only(bottom: 10),
                          child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
                            XBtnbase(
                              width: 120,
                              label: "Annulla",
                              label_Style: XStyles.xStyTextForSubLabel(textColor: Colors.red),
                              backGroundColor: Colors.red.withAlpha(60),
                              onPressed: () => Navigator.pop(context, null),
                            ),
                            SizedBox(width: 10),
                            XBtnbase(
                              width: 120,
                              label: "Conferma",
                              label_Style: XStyles.xStyTextForSubLabel(textColor: Colors.green),
                              backGroundColor: Colors.green.withAlpha(60),
                              onPressed: () {
                                xView.cols.forEach((e) {
                                  if (valueUI[e.colKey] != null) setState(() => value[e.colKey] = valueUI[e.colKey]);
                                });
                                return Navigator.pop(context, valueUI);
                              },
                            ),
                          ])),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisSize: MainAxisSize.min,
                        children: liCols.length == 1
                            ? [Container(width: 500, margin: EdgeInsets.symmetric(vertical: 5, horizontal: 10), child: xLayout_CellWidget_Editable(liCols.first, valueUI, context, valueUI, parentSetState: setState, onBeforeCMD_Active: false, autoFocus: true))]
                            : liCols.map((e) {
                                // TextEditingController textController = TextEditingController(text: valueUI[e.colKey].runtimeType != DateTime ? valueUI[e.colKey].toString() : XUtils.dateToString(valueUI[e.colKey], format: "dd/MM/yyyy", noDateLabel: ""));
                                return Container(margin: EdgeInsets.symmetric(vertical: 5, horizontal: 10), child: xLayout_CellWidget_Editable(e, valueUI, context, valueUI, parentSetState: setState, onBeforeCMD_Active: false)); //: xEditDialog_CellBuilder(valueUI, e, context, setState, textController, label_Visible: true, autoFocus: false));
                              }).toList(),
                      ))));
        });
      });
}