2025-10-24 01:16:50 +07:00
|
|
|
part of 'field.dart';
|
|
|
|
|
|
|
|
|
|
class AppTextFormField extends StatelessWidget {
|
|
|
|
|
final TextEditingController? controller;
|
|
|
|
|
final String label;
|
|
|
|
|
final Function(String value)? onChanged;
|
|
|
|
|
final bool obscureText;
|
|
|
|
|
final TextInputType? keyboardType;
|
|
|
|
|
final TextInputAction? textInputAction;
|
|
|
|
|
final TextCapitalization? textCapitalization;
|
|
|
|
|
final bool showLabel;
|
|
|
|
|
final Widget? prefixIcon;
|
|
|
|
|
final Widget? suffixIcon;
|
|
|
|
|
final bool readOnly;
|
|
|
|
|
final int maxLines;
|
|
|
|
|
final String? Function(String?)? validator;
|
|
|
|
|
|
|
|
|
|
const AppTextFormField({
|
|
|
|
|
super.key,
|
|
|
|
|
this.controller,
|
|
|
|
|
required this.label,
|
|
|
|
|
this.onChanged,
|
|
|
|
|
this.obscureText = false,
|
|
|
|
|
this.keyboardType,
|
|
|
|
|
this.textInputAction,
|
|
|
|
|
this.textCapitalization,
|
|
|
|
|
this.showLabel = true,
|
|
|
|
|
this.prefixIcon,
|
|
|
|
|
this.suffixIcon,
|
|
|
|
|
this.readOnly = false,
|
|
|
|
|
this.maxLines = 1,
|
|
|
|
|
this.validator,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
if (showLabel) ...[
|
|
|
|
|
Text(label, style: AppStyle.md.copyWith(fontWeight: FontWeight.w700)),
|
|
|
|
|
const SpaceHeight(12.0),
|
|
|
|
|
],
|
|
|
|
|
TextFormField(
|
|
|
|
|
controller: controller,
|
|
|
|
|
onChanged: onChanged,
|
|
|
|
|
obscureText: obscureText,
|
|
|
|
|
keyboardType: keyboardType,
|
|
|
|
|
textInputAction: textInputAction,
|
|
|
|
|
textCapitalization: textCapitalization ?? TextCapitalization.none,
|
|
|
|
|
readOnly: readOnly,
|
|
|
|
|
maxLines: maxLines,
|
|
|
|
|
validator: validator,
|
|
|
|
|
decoration: InputDecoration(
|
2025-10-31 14:33:02 +07:00
|
|
|
contentPadding: EdgeInsets.symmetric(vertical: 4, horizontal: 12),
|
2025-10-24 01:16:50 +07:00
|
|
|
prefixIcon: prefixIcon,
|
|
|
|
|
suffixIcon: suffixIcon,
|
|
|
|
|
hintText: label,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|