forked from eatvio/eatvio_app
211 lines
7.3 KiB
Dart
211 lines
7.3 KiB
Dart
import 'package:eatvio_app/core/app_export.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
class CustomTextFormField extends StatelessWidget {
|
|
CustomTextFormField({
|
|
Key? key,
|
|
this.alignment,
|
|
this.width,
|
|
this.controller,
|
|
this.focusNode,
|
|
this.autofocus = true,
|
|
this.textStyle,
|
|
this.obscureText = false,
|
|
this.textInputAction = TextInputAction.next,
|
|
this.textInputType = TextInputType.text,
|
|
this.maxLines,
|
|
this.hintText,
|
|
this.hintStyle,
|
|
this.prefix,
|
|
this.prefixConstraints,
|
|
this.suffix,
|
|
this.suffixConstraints,
|
|
this.contentPadding,
|
|
this.inputFormatters,
|
|
this.borderDecoration,
|
|
this.fillColor,
|
|
this.filled = true,
|
|
this.validator,
|
|
this.keyboardType,
|
|
this.onSaved,
|
|
}) : super(
|
|
key: key,
|
|
);
|
|
|
|
final Alignment? alignment;
|
|
final double? width;
|
|
final TextEditingController? controller;
|
|
final FocusNode? focusNode;
|
|
final bool? autofocus;
|
|
final TextStyle? textStyle;
|
|
final bool? obscureText;
|
|
final List<TextInputFormatter>? inputFormatters;
|
|
final TextInputAction? textInputAction;
|
|
final TextInputType? textInputType;
|
|
final int? maxLines;
|
|
final String? hintText;
|
|
final TextStyle? hintStyle;
|
|
final Widget? prefix;
|
|
final BoxConstraints? prefixConstraints;
|
|
final Widget? suffix;
|
|
final BoxConstraints? suffixConstraints;
|
|
final EdgeInsets? contentPadding;
|
|
final InputBorder? borderDecoration;
|
|
final Color? fillColor;
|
|
final bool? filled;
|
|
final TextInputType? keyboardType;
|
|
final FormFieldValidator<String>? validator;
|
|
final void Function(String?)? onSaved;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return alignment != null
|
|
? Align(
|
|
alignment: alignment ?? Alignment.center,
|
|
child: SizedBox(
|
|
width: width ?? double.maxFinite,
|
|
child: TextFormField(
|
|
controller: controller,
|
|
focusNode: focusNode ?? FocusNode(),
|
|
autofocus: autofocus!,
|
|
style: textStyle ?? theme.textTheme.titleMedium,
|
|
obscureText: obscureText!,
|
|
textInputAction: textInputAction,
|
|
maxLines: maxLines ?? 1,
|
|
decoration: InputDecoration(
|
|
hintText: hintText ?? "",
|
|
hintStyle: hintStyle ?? theme.textTheme.bodyLarge,
|
|
prefixIcon: prefix,
|
|
prefixIconConstraints: prefixConstraints,
|
|
suffixIcon: suffix,
|
|
suffixIconConstraints: suffixConstraints,
|
|
isDense: true,
|
|
contentPadding: contentPadding ?? EdgeInsets.all(6.h),
|
|
fillColor: fillColor ?? theme.colorScheme.onPrimary,
|
|
filled: filled,
|
|
border: borderDecoration ??
|
|
OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8.h),
|
|
borderSide: BorderSide(
|
|
color: appTheme.blueA400,
|
|
width: 1,
|
|
),
|
|
),
|
|
enabledBorder: borderDecoration ??
|
|
OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8.h),
|
|
borderSide: BorderSide(
|
|
color: appTheme.blueA400,
|
|
width: 1,
|
|
),
|
|
),
|
|
focusedBorder: borderDecoration ??
|
|
OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8.h),
|
|
borderSide: BorderSide(
|
|
color: appTheme.blueA400,
|
|
width: 1,
|
|
),
|
|
),
|
|
),
|
|
keyboardType: keyboardType,
|
|
validator: validator,
|
|
onSaved: onSaved,
|
|
inputFormatters: inputFormatters,
|
|
),
|
|
),
|
|
)
|
|
: SizedBox(
|
|
width: width ?? double.maxFinite,
|
|
child: TextFormField(
|
|
controller: controller,
|
|
focusNode: focusNode ?? FocusNode(),
|
|
autofocus: autofocus!,
|
|
style: textStyle ?? theme.textTheme.titleMedium,
|
|
obscureText: obscureText!,
|
|
textInputAction: textInputAction,
|
|
maxLines: maxLines ?? 1,
|
|
decoration: InputDecoration(
|
|
hintText: hintText ?? "",
|
|
hintStyle: hintStyle ?? theme.textTheme.bodyLarge,
|
|
prefixIcon: prefix,
|
|
prefixIconConstraints: prefixConstraints,
|
|
suffixIcon: suffix,
|
|
suffixIconConstraints: suffixConstraints,
|
|
isDense: true,
|
|
contentPadding: contentPadding ?? EdgeInsets.all(6.h),
|
|
fillColor: fillColor ?? theme.colorScheme.onPrimary,
|
|
filled: filled,
|
|
border: borderDecoration ??
|
|
OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8.h),
|
|
borderSide: BorderSide(
|
|
color: appTheme.blueA400,
|
|
width: 1,
|
|
),
|
|
),
|
|
enabledBorder: borderDecoration ??
|
|
OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8.h),
|
|
borderSide: BorderSide(
|
|
color: appTheme.blueA400,
|
|
width: 1,
|
|
),
|
|
),
|
|
focusedBorder: borderDecoration ??
|
|
OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8.h),
|
|
borderSide: BorderSide(
|
|
color: appTheme.blueA400,
|
|
width: 1,
|
|
),
|
|
),
|
|
),
|
|
keyboardType: keyboardType,
|
|
validator: validator,
|
|
onSaved: onSaved,
|
|
inputFormatters: inputFormatters,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
/* InputDecoration _buildInputDecoration() {
|
|
return InputDecoration(
|
|
hintText: hintText ?? "",
|
|
hintStyle: hintStyle ?? theme.textTheme.bodyLarge,
|
|
prefixIcon: prefix,
|
|
prefixIconConstraints: prefixConstraints,
|
|
suffixIcon: suffix,
|
|
suffixIconConstraints: suffixConstraints,
|
|
isDense: true,
|
|
contentPadding: contentPadding ?? EdgeInsets.all(6.h),
|
|
fillColor: fillColor ?? theme.colorScheme.onPrimary,
|
|
filled: filled,
|
|
border: borderDecoration ??
|
|
OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8.h),
|
|
borderSide: BorderSide(
|
|
color: appTheme.blueA400,
|
|
width: 1,
|
|
),
|
|
),
|
|
enabledBorder: borderDecoration ??
|
|
OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8.h),
|
|
borderSide: BorderSide(
|
|
color: appTheme.blueA400,
|
|
width: 1,
|
|
),
|
|
),
|
|
focusedBorder: borderDecoration ??
|
|
OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8.h),
|
|
borderSide: BorderSide(
|
|
color: appTheme.blueA400,
|
|
width: 1,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}*/ |