2023-03-30 07:34:12 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import '../../app/themes/app_colors.dart';
|
|
|
|
|
|
|
|
class MyTextFormField extends StatelessWidget {
|
|
|
|
const MyTextFormField({
|
|
|
|
Key? key,
|
|
|
|
this.labelText,
|
|
|
|
this.hintText,
|
|
|
|
this.obscureText,
|
|
|
|
this.validator,
|
|
|
|
this.suffixIcon,
|
|
|
|
this.prefixIcon,
|
|
|
|
this.focusNode,
|
|
|
|
this.controller,
|
|
|
|
this.maxLines = 1,
|
|
|
|
this.onEditingComplete,
|
2023-05-18 08:04:03 +00:00
|
|
|
this.readOnly = false,
|
|
|
|
this.onTap,
|
|
|
|
this.keyboardType = TextInputType.text,
|
2023-07-14 03:31:03 +00:00
|
|
|
this.initialValue,
|
|
|
|
this.enabled = true,
|
2023-03-30 07:34:12 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final String? labelText;
|
|
|
|
final String? hintText;
|
|
|
|
final bool? obscureText;
|
|
|
|
final FormFieldValidator<String>? validator;
|
|
|
|
final Widget? suffixIcon;
|
|
|
|
final Widget? prefixIcon;
|
|
|
|
final FocusNode? focusNode;
|
|
|
|
final TextEditingController? controller;
|
|
|
|
final int maxLines;
|
|
|
|
final VoidCallback? onEditingComplete;
|
2023-05-18 08:04:03 +00:00
|
|
|
final bool readOnly;
|
|
|
|
final VoidCallback? onTap;
|
|
|
|
final TextInputType keyboardType;
|
2023-07-14 03:31:03 +00:00
|
|
|
final String? initialValue;
|
|
|
|
final bool enabled;
|
2023-03-30 07:34:12 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return TextFormField(
|
2023-07-14 03:31:03 +00:00
|
|
|
enabled: enabled,
|
|
|
|
initialValue: initialValue,
|
2023-03-30 07:34:12 +00:00
|
|
|
onEditingComplete: onEditingComplete,
|
|
|
|
maxLines: maxLines,
|
|
|
|
controller: controller,
|
|
|
|
focusNode: focusNode,
|
|
|
|
obscureText: obscureText ?? false,
|
2023-05-18 08:04:03 +00:00
|
|
|
readOnly: readOnly,
|
|
|
|
onTap: onTap,
|
|
|
|
keyboardType: keyboardType,
|
2023-03-30 07:34:12 +00:00
|
|
|
decoration: InputDecoration(
|
|
|
|
prefixIcon: prefixIcon,
|
|
|
|
suffixIcon: suffixIcon,
|
|
|
|
enabledBorder: const OutlineInputBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(25)),
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: mainColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
focusedBorder: const OutlineInputBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(25)),
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: mainColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
focusedErrorBorder: const OutlineInputBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(25)),
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: dangerColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
errorBorder: const OutlineInputBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(25)),
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: dangerColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
labelText: labelText,
|
|
|
|
hintText: hintText,
|
|
|
|
labelStyle: const TextStyle(color: fontColor),
|
|
|
|
),
|
|
|
|
validator: validator,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|