import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import '../../../../../application/auth/login_form/login_form_bloc.dart';
import '../../../../../common/validator/validator.dart';
import '../../../../components/field/field.dart';

class LoginEmailField extends StatelessWidget {
  const LoginEmailField({super.key});

  @override
  Widget build(BuildContext context) {
    return AppTextFormField(
      label: 'Email',
      keyboardType: TextInputType.emailAddress,
      textInputAction: TextInputAction.next,
      validator: (value) =>
          AppValidator.validateEmail(context.read<LoginFormBloc>().state.email),
      onChanged: (value) =>
          context.read<LoginFormBloc>().add(LoginFormEvent.emailChanged(value)),
    );
  }
}
