part of 'field.dart';

class AppTextFormField extends StatelessWidget {
  const AppTextFormField({
    super.key,
    this.controller,
    required this.title,
    this.hintText,
    required this.prefixIcon,
    this.validator,
  });

  final TextEditingController? controller;
  final String title;
  final String? hintText;
  final IconData prefixIcon;
  final String? Function(String?)? validator;

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: AppStyle.lg.copyWith(
            fontWeight: FontWeight.w600,
            color: AppColor.textPrimary,
          ),
        ),
        const SpaceHeight(8),
        TextFormField(
          controller: controller,
          keyboardType: TextInputType.emailAddress,
          cursorColor: AppColor.primary,
          style: AppStyle.md.copyWith(color: AppColor.textPrimary),
          decoration: InputDecoration(
            hintText: hintText,
            prefixIcon: LineIcon(prefixIcon, color: AppColor.textSecondary),
          ),
          validator: validator,
        ),
      ],
    );
  }
}
