xLayout_DateFormField_Builder method

Widget xLayout_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,
})

Widget DateTime Editor Generico

Implementation

Widget xLayout_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 outLineBorder = OutlineInputBorder(borderSide: BorderSide(color: xCol.readOnly.not() ? (xCellEditable_borderColor_Visible ? xCol.xmodelXprop.col_Color : borderColor ?? Colors.grey[400]!) : (borderColor_Disabled ?? Colors.grey[800]!), width: 1));
  UnderlineInputBorder underLineBorder = UnderlineInputBorder(borderSide: BorderSide(color: xCol.readOnly.not() ? (xCellEditable_borderColor_Visible ? xCol.xmodelXprop.col_Color : borderColor ?? Colors.grey[400]!) : (borderColor_Disabled ?? Colors.grey[800]!), width: 1));
  return DateTimeFormField(
    decoration: InputDecoration(
      contentPadding: EdgeInsets.only(right: 2, top: 2, bottom: 2, left: 4),
      hintStyle: XStyles.xStyTextForDescr(fontSize: 15, textColor: XSchedaState.color_HintText),
      errorStyle: TextStyle(color: Colors.redAccent),
      border: widget.isEditable ? underLineBorder : outLineBorder,
      disabledBorder: widget.isEditable ? underLineBorder : outLineBorder,
      enabledBorder: widget.isEditable ? underLineBorder : outLineBorder,
      focusedBorder: widget.isEditable ? underLineBorder : outLineBorder,
      labelText: xCol.colCaption,
      constraints: BoxConstraints(maxHeight: 40),
      floatingLabelBehavior: FloatingLabelBehavior.always,
      labelStyle: value != null
          ? XStyles.xStyTextForLabel(textColor: xCol.readOnly ? (labelColor_Disabled ?? borderColor_Disabled ?? Colors.grey[800]!) : (borderColor ?? Colors.grey[600]!)) //
          : XStyles.xStyTextForLabel(textColor: editable.not() ? (labelColor_Disabled ?? borderColor_Disabled ?? Colors.grey[800]!) : (xCol.xmodelXprop.col_Color != Colors.black ? xCol.xmodelXprop.col_Color : XColors.foregroundLight)),
    ),
    onChanged: (value) => onDateSelected!(value),
    onTap: xCol.readOnly.not() ? null : () {},
    initialValue: value,
    dateFormat: DateFormat(format ?? "dd/MM/yy"),
    style: XStyles.xStyTextForDescr(fontSize: 15, textColor: Colors.white),
    materialDatePickerOptions: MaterialDatePickerOptions(
      initialEntryMode: DatePickerEntryMode.calendar,
      initialDatePickerMode: DatePickerMode.day,
    ),
    mode: DateTimeFieldPickerMode.date,
    autovalidateMode: AutovalidateMode.onUserInteraction,
    validator: (e) => (e?.day ?? 0) == 1 ? 'Perfavore sistema la data' : null,
  );
}