xLayout_CellWidget_Editable method

Container xLayout_CellWidget_Editable(
  1. XCol xCol,
  2. dynamic item,
  3. BuildContext context,
  4. dynamic itemToSet, {
  5. bool onBeforeCMD_Active = true,
  6. TextEditingController? controller,
})

BUILDER DEI WIDGET EDITABILI///

Implementation

Container xLayout_CellWidget_Editable(XCol xCol, dynamic item, BuildContext context, dynamic itemToSet, {bool onBeforeCMD_Active = true, TextEditingController? controller}) {
  late Widget _widgetForCell;
  //WIDGET NEL CASO FOSSE UNA STRING
  if (xCol.dataType == String && xCol.colKey.startsWith("li").not()) {
    _widgetForCell = xSch_TextFormField_Builder(
      height: null,
      context: context,
      controller: controller,
      xCol: xCol,
      multiLines: xCol.width >= 200 ? true : false,
      editable: xCol.readOnly,
      borderColor: widget.cell_borderColor,
      borderColor_Disabled: widget.cell_borderColor_Disabled,
      labelColor_Disabled: widget.cell_labelColor_Disabled,
      onSubmitted: (value) {
        xOnXCell_Edit_SubmitValue_INTERNAL(item, xCol, value);
      },
      onBefore_Edit: () {
        if (onBeforeCMD_Active) {
          xOnXCell_Before_Edit(xCol, item[xCol.colKey], itemToSet: itemToSet);
        }
      },
      value: item[xCol.colKey] ?? "",
      onChanged: (value) {
        xOnXCell_Edit_OnChanged(item, xCol, value);
      },
    );
  }
  //WIDGET NEL CASO FOSSE UN DATETIME
  else if (xCol.dataType == DateTime) {
    _widgetForCell = xSch_DateFormField_Builder(
        xCol: xCol,
        borderColor: widget.cell_borderColor,
        borderColor_Disabled: widget.cell_borderColor_Disabled,
        labelColor_Disabled: widget.cell_labelColor_Disabled,
        format: xFormat_Date,
        onBefore_Edit: () => xOnXCell_Before_Edit(xCol, item),
        value: item[xCol.colKey] == DateTime(1900, 01, 01) ? null : item[xCol.colKey],
        onDateSelected: (value) {
          xOnXCell_Edit_SubmitValue_INTERNAL(item, xCol, value);
        });
  }
  //WIDGET NEL CASO FOSSE UN DOUBLE
  else if (xCol.dataType == double) {
    _widgetForCell = xSch_TextFormField_Builder(
        context: context,
        selectText: true,
        editable: xCol.readOnly,
        xCol: xCol,
        controller: controller,
        maxLines: 1,
        borderColor: widget.cell_borderColor,
        borderColor_Disabled: widget.cell_borderColor_Disabled,
        labelColor_Disabled: widget.cell_labelColor_Disabled,
        onBefore_Edit: () {
          if (onBeforeCMD_Active) {
            xOnXCell_Before_Edit(xCol, item, itemToSet: itemToSet);
          }
        },
        keyboardType: TextInputType.number,
        value: (item[xCol.colKey] == null || item[xCol.colKey].toString() == "0.0") ? "" : XUtils.xFormatDouble(context, item[xCol.colKey]),
        inputFormatters: [FilteringTextInputFormatter.deny(RegExp("[- /,\\\\]"))],
        onSubmitted: (value) {
          xOnXCell_Edit_SubmitValue_INTERNAL(item, xCol, double.parse(value));
        },
        onChanged: (value) {
          if (value != "") {
            xOnXCell_Edit_OnChanged(item, xCol, double.parse(value));
          } else {
            xOnXCell_Edit_OnChanged(item, xCol, 0.0);
          }
        });
  }
  //WIDGET NEL CASO FOSSE UN INTERO
  else if (xCol.dataType == int) {
    _widgetForCell = xSch_TextFormField_Builder(
      context: context,
      editable: xCol.readOnly,
      selectText: true,
      maxLines: 1,
      controller: controller,
      xCol: xCol,
      borderColor: widget.cell_borderColor,
      borderColor_Disabled: widget.cell_borderColor_Disabled,
      labelColor_Disabled: widget.cell_labelColor_Disabled,
      keyboardType: TextInputType.number,
      onBefore_Edit: () {
        if (onBeforeCMD_Active) {
          xOnXCell_Before_Edit(xCol, item, itemToSet: itemToSet);
        }
      },
      onSubmitted: (value) {
        xOnXCell_Edit_SubmitValue_INTERNAL(item, xCol, value);
      },
      value: item[xCol.colKey].toString() == "0.0" ? "" : XUtils.xFormatInt(context, item[xCol.colKey]),
      inputFormatters: [FilteringTextInputFormatter.deny(RegExp("[- /,\\\\]"))],
      onChanged: (value) {
        if (value != "") {
          xOnXCell_Edit_OnChanged(item, xCol, int.parse(value));
        } else {
          xOnXCell_Edit_OnChanged(item, xCol, 0);
        }
      },
    );
  } else {
    //DEVE essere W e H = 0 se no il Wrap fa casino nel gestirlo e va a "un po' a capo" dopo l'ultimo Widget
    return Container(width: 0, height: 0);
  }
  return Container(
    width: xCol.width,
    padding: xCol.dataType == DateTime ? EdgeInsets.only(top: 1 * (XUtils.kforScale)) : null,
    child: _widgetForCell,
  );
  //}
}