xSch_TextFormField_Builder<T> method

Widget xSch_TextFormField_Builder<T>({
  1. required BuildContext context,
  2. required XCol xCol,
  3. dynamic onChanged(
    1. String
    )?,
  4. dynamic onSubmitted(
    1. String
    )?,
  5. String? hintText,
  6. List<TextInputFormatter>? inputFormatters,
  7. TextInputType? keyboardType,
  8. bool editable = true,
  9. bool label_Visible = true,
  10. bool autoFocus = false,
  11. String? value,
  12. bool? selectText,
  13. bool? multiLines,
  14. double? height,
  15. int? maxLines,
  16. Color? borderColor,
  17. Color? borderColor_Disabled,
  18. Color? labelColor_Disabled,
  19. Color? backgorundColor,
  20. Color? textColor,
  21. Color? backgorundColor_Disabled,
  22. TextEditingController? controller,
  23. dynamic onBefore_Edit()?,
})

TextFormField Editor Generico da Usare

Implementation

Widget xSch_TextFormField_Builder<T>({
  required BuildContext context,
  required XCol xCol,
  Function(String)? onChanged,
  Function(String)? onSubmitted,
  String? hintText,
  List<TextInputFormatter>? inputFormatters,
  TextInputType? keyboardType,
  bool editable = true,
  bool label_Visible = true,
  bool autoFocus = false,
  String? value,
  bool? selectText,
  bool? multiLines,
  double? height,
  int? maxLines,
  Color? borderColor,
  Color? borderColor_Disabled,
  Color? labelColor_Disabled,
  Color? backgorundColor,
  Color? textColor,
  Color? backgorundColor_Disabled,
  TextEditingController? controller,
  Function()? onBefore_Edit,
}) {
  OutlineInputBorder o = OutlineInputBorder(borderSide: BorderSide(color: editable.not() ? (borderColor_Active ? (xCol.xmodelXprop.col_Color == Colors.black ? (borderColor ?? Colors.grey[400]!) : xCol.xmodelXprop.col_Color) : borderColor ?? Colors.grey[400]!) : (borderColor_Disabled ?? Colors.grey[400]!), width: 1));
  return Container(
      margin: EdgeInsets.only(top: 2),
      child: XTextFormField(
        controller: value != null ? null : controller,
        border: o,
        disabledBorder: o,
        enabledBorder: o,
        label: label_Visible ? xCol.colCaption + (editable ? "🔒" : "") : "",
        onChanged: onChanged,
        onFieldSubmitted: (value) => onSubmitted == null ? null : onSubmitted(value!),
        autoFocus: autoFocus,
        onTap: () async {
          if (controller != null && xCol.dataType != String) controller.selection = TextSelection(baseOffset: 0, extentOffset: controller.text.length);
          if (onBefore_Edit != null) {
            // FocusScope.of(context).unfocus();
            await onBefore_Edit();
          }
        },
        initialValue: controller != null ? null : value,
        maxLines: maxLines,
        maxLenght: xCol.maxLenght == 0 ? null : xCol.maxLenght,
        isCollapsed: false,
        enabled: editable.not(),
        height: null,
        fillColor: editable ? Colors.transparent : XSchedaState.color_CellBackGorundDisabled,
        filled: XSchedaState.color_CellBackGorundDisabled != null ? true : false,
        multiLines: (xCol.colCaption.toLowerCase().contains("email") || (xCol.colKey.contains("sconti") || xCol.colKey.contains("sconto")) || xCol.colCaption.toLowerCase().contains("inidrizzo") || xCol.colCaption.toLowerCase().contains("ind"))
            ? false
            : ((xCol.colCaption.toLowerCase().contains("cell")) || (xCol.colCaption.toLowerCase().contains("tel")))
                ? false
                : multiLines ?? 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: textColor ?? 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
        keyboardType: keyboardType ??
            ((xCol.colCaption.toLowerCase().contains("email"))
                ? TextInputType.emailAddress
                : ((xCol.colCaption.toLowerCase().contains("cell")) || (xCol.colCaption.toLowerCase().contains("tel")))
                    ? TextInputType.phone
                    : (xCol.colKey.contains("sconti") || xCol.colKey.contains("sconto"))
                        ? TextInputType.number
                        : TextInputType.text),
        textCapitalization: (xCol.dataType == String && xCol.colKey.startsWith("li").not())
            ? TextCapitalization.sentences //
            : TextCapitalization.none,
        hintText: editable ? "..." : (hintText ?? "..."),
        hintStyle: XStyles.xStyTextForSubDescr(textColor: XSchedaState.color_HintText),
        inputFormatters: inputFormatters ?? [],
      ));
}