xLayout_CellWidget_Editable method
Container
xLayout_CellWidget_Editable(
- XCol xCol,
- T item,
- BuildContext context,
- void parentSetState(
- void ()
BUILDER DEI WIDGET EDITABILI///
Implementation
Container xLayout_CellWidget_Editable(XCol xCol, T item, BuildContext context, void Function(void Function()) parentSetState) {
Widget _widgetForCell = Container();
//WIDGET NEL CASO FOSSE UNA STRING
if (xCol.dataType == String && xCol.colKey.startsWith("li").not()) {
_widgetForCell = xSch_TextFormField_Builder(
height: null,
context: context,
xCol: xCol,
multiLines: xCol.multilines,
maxLines: xCol.multilines ? 4 : 1,
editable: xCol.readOnly,
borderColor: widget.cell_borderColor,
borderColor_Disabled: widget.cell_borderColor_Disabled,
labelColor_Disabled: widget.cell_labelColor_Disabled,
onSubmitted: (value) {
xOnXCell_Edit_SubmitValue(xCol, double.parse(value), parentSetState);
},
onBefore_Edit: () {
xOnBefore_Edit(xCol, item);
},
value: item[xCol.colKey] ?? "",
onChanged: (value) {
xOnXCell_Edit_OnChanged(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,
onBefore_Edit: () => xOnBefore_Edit(xCol, item),
value: item[xCol.colKey] == DateTime(1900, 01, 01) ? null : item[xCol.colKey],
onDateSelected: (value) {
// setState(() {
// btnUpdateChangesShow = true;
xOnXCell_Edit_SubmitValue(xCol, value, parentSetState);
//});
});
}
//WIDGET NEL CASO FOSSE UN DOUBLE
else if (xCol.dataType == double) {
_widgetForCell = xSch_TextFormField_Builder(
context: context,
selectText: true,
editable: xCol.readOnly,
xCol: xCol,
maxLines: 1,
borderColor: widget.cell_borderColor,
borderColor_Disabled: widget.cell_borderColor_Disabled,
labelColor_Disabled: widget.cell_labelColor_Disabled,
onBefore_Edit: () {
xOnBefore_Edit(xCol, item);
},
keyboardType: TextInputType.number,
value: item[xCol.colKey].toString() == "0.0" ? "" : double.parse(item[xCol.colKey].toString()).toString(),
inputFormatters: [FilteringTextInputFormatter.deny(RegExp("[- /,\\\\]"))],
onSubmitted: (value) {
xOnXCell_Edit_SubmitValue(xCol, double.parse(value), parentSetState);
},
onChanged: (value) {
if (value != "") {
xOnXCell_Edit_OnChanged(xCol, double.parse(value));
} else {
xOnXCell_Edit_OnChanged(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,
xCol: xCol,
borderColor: widget.cell_borderColor,
borderColor_Disabled: widget.cell_borderColor_Disabled,
labelColor_Disabled: widget.cell_labelColor_Disabled,
keyboardType: TextInputType.number,
onBefore_Edit: () {
xOnBefore_Edit(xCol, item);
},
onSubmitted: (value) {
xOnXCell_Edit_SubmitValue(xCol, value, parentSetState);
},
value: item[xCol.colKey].toString() == "0.0" ? "" : item[xCol.colKey].toString(),
inputFormatters: [FilteringTextInputFormatter.deny(RegExp("[- /,\\\\]"))],
onChanged: (value) {
if (value != "") {
xOnXCell_Edit_OnChanged(xCol, int.parse(value));
} else {
xOnXCell_Edit_OnChanged(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);
}
//DD 2023.01.28 qui i widget sono WRAPPED;, quind per ora il concetto del resizeStyle non ha un senso,m visto che lo U non può resizare
//Se la colonna è Width FLEX
// if (xCol.resizeStyle == 0) {
// // return Container(height: 40, constraints: BoxConstraints(minWidth: double.infinity, maxWidth: double.infinity), child: Container(margin: EdgeInsets.symmetric(horizontal: 2), child: _widgetForCell));
// return Container(margin: EdgeInsets.only(right: 5), constraints: BoxConstraints.tightForFinite(height: XSchedaState.heightOfEntryField), child: Container(margin: EdgeInsets.symmetric(horizontal: 2), child: _widgetForCell));
// }
// //Se la colonna è Width PROPORTIONAL
// else if (xCol.resizeStyle == 1) {
// return Container(margin: EdgeInsets.only(right: 5), height: XSchedaState.heightOfEntryField, constraints: BoxConstraints(minWidth: xCol.width * .5, maxWidth: xCol.width * 1), child: _widgetForCell);
// }
//Se la colonna è Width FIX
//else {
return Container(
width: xCol.width,
child: StatefulBuilder(builder: (context, setState) {
return _widgetForCell;
}),
);
//}
}