import 'package:em2rp/utils/colors.dart';
import 'package:flutter/material.dart';

class EmailTextFieldWidget extends StatelessWidget {
  final TextEditingController emailController;
  final bool highlightEmailField;
  final VoidCallback? onSubmitted;

  const EmailTextFieldWidget({
    super.key,
    required this.emailController,
    required this.highlightEmailField,
    this.onSubmitted,
  });

  @override
  Widget build(BuildContext context) {
    return TextField(
      controller: emailController,
      keyboardType: TextInputType.emailAddress,
      autofillHints: const [AutofillHints.email, AutofillHints.username],
      textInputAction: TextInputAction.next,
      onSubmitted: (_) => onSubmitted?.call(),
      decoration: InputDecoration(
        labelText: 'Email',
        border: OutlineInputBorder(
          borderSide: highlightEmailField
              ? const BorderSide(color: Colors.red)
              : const BorderSide(),
        ),
        filled: true,
        fillColor: AppColors.blanc,
      ),
    );
  }
}
