xSch_DateFormField_Builder method

Widget xSch_DateFormField_Builder({
  1. required XCol xCol,
  2. required dynamic onDateSelected(
    1. DateTime
    )?,
  3. bool editable = true,
  4. DateTime? value,
  5. Color? borderColor,
  6. Color? borderColor_Disabled,
  7. Color? labelColor_Disabled,
  8. dynamic onBefore_Edit()?,
  9. TextEditingController? controller,
  10. String? format,
})

DateTime Editor Generico da Usare

Implementation

Widget xSch_DateFormField_Builder({
  required XCol xCol,
  required Function(DateTime)? onDateSelected,
  bool editable = true,
  DateTime? value,
  Color? borderColor,
  Color? borderColor_Disabled,
  Color? labelColor_Disabled,
  Function()? onBefore_Edit,
  TextEditingController? controller,
  String? format,
}) {
  OutlineInputBorder o = OutlineInputBorder(borderSide: BorderSide(color: xCol.readOnly.not() ? (borderColor_Active ? xCol.xmodelXprop.col_Color : borderColor ?? Colors.grey[400]!) : (borderColor_Disabled ?? Colors.grey[800]!), width: 1));
  return GestureDetector(
      child: Container(
          margin: EdgeInsets.only(top: 1),
          child: xCol.readOnly.not()
              ? DateTimeFormField(
                  decoration: InputDecoration(
                    contentPadding: EdgeInsets.only(right: 2, top: 6, bottom: 6, left: 4),
                    hintStyle: XStyles.xStyTextForDescr(fontSize: 15, textColor: XSchedaState.color_HintText),
                    errorStyle: TextStyle(color: Colors.redAccent),
                    border: o,
                    disabledBorder: o,
                    enabledBorder: o,
                    labelText: xCol.colCaption,
                    constraints: BoxConstraints(maxHeight: 48),
                    labelStyle: value != null
                        ? XStyles.xStyTextForLabel(textColor: xCol.readOnly ? (labelColor_Disabled ?? borderColor_Disabled ?? Colors.grey[900]!) : (labelColor_Disabled ?? borderColor ?? Colors.grey[600]!)) //
                        : XStyles.xStyTextForDescr(textColor: editable.not() ? (labelColor_Disabled ?? borderColor_Disabled ?? Colors.grey[700]!) : (xCol.xmodelXprop.col_Color != Colors.black ? xCol.xmodelXprop.col_Color : XColors.foregroundLight)),
                  ),
                  onChanged: (value) => onDateSelected!(value!),
                  onTap: xCol.readOnly.not() ? null : () {},
                  // enabled: xCol.readOnly.not(),
                  initialValue: value,
                  style: XStyles.xStyTextForDescr(fontSize: 15, textColor: Colors.white),
                  materialDatePickerOptions: MaterialDatePickerOptions(
                    initialEntryMode: DatePickerEntryMode.calendar,
                    initialDatePickerMode: DatePickerMode.day,
                  ),
                  dateFormat: DateFormat(format ?? "dd/MM/yy"),
                  mode: DateTimeFieldPickerMode.date,
                  autovalidateMode: AutovalidateMode.onUserInteraction,
                  validator: (e) => (e?.day ?? 0) == 1 ? 'Perfavore sistema la data' : null,
                )
              : XTextFormField(
                  controller: value != null ? null : controller,
                  border: o,
                  disabledBorder: o,
                  enabledBorder: o,
                  label: xCol.colCaption + (editable ? "🔒" : ""),
                  onTap: () {
                    if (controller != null && xCol.dataType != String) controller.selection = TextSelection(baseOffset: 0, extentOffset: controller.text.length);
                    onBefore_Edit!();
                  },
                  initialValue: XUtils.dateToString(value, format: format ?? "dd/MM/yy"),
                  isCollapsed: false,
                  enabled: editable.not(),
                  height: null,
                  fillColor: editable ? Colors.transparent : XSchedaState.color_CellBackGorundDisabled,
                  filled: XSchedaState.color_CellBackGorundDisabled != null ? true : false,
                  suffixIcon: xCol.format == "C" ? Icon(Icons.euro, size: 20) : null,
                  suffixIconConstraints: BoxConstraints(maxWidth: 20, minWidth: 20, maxHeight: 30, minHeight: 30),
                  contentPadding: EdgeInsets.only(top: 8, left: 5, bottom: 8),
                  textStyle: XStyles.xStyTextForDescr(textColor: labelColor_Disabled ?? XSchedaState.color_Text),
                  textAlign: xCol.dataType is int || xCol.dataType is double ? TextAlign.end : TextAlign.start,
                  labelStyle: XStyles.xStyTextForLabel(textColor: xCol.xmodelXprop.col_Color == Colors.black ? XColors.foregroundLight : xCol.xmodelXprop.col_Color), //XSchedaState.colorOfHintText
                  hintStyle: XStyles.xStyTextForSubDescr(textColor: XSchedaState.color_HintText),
                )));
}