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 LoginPasswordField extends StatelessWidget {
  const LoginPasswordField({super.key});

  @override
  Widget build(BuildContext context) {
    return AppPasswordTextFormField(
      label: 'Password',
      keyboardType: TextInputType.visiblePassword,
      textInputAction: TextInputAction.done,
      validator: (value) => AppValidator.validatePassword(
        context.read<LoginFormBloc>().state.password,
      ),
      onChanged: (value) => context.read<LoginFormBloc>().add(
        LoginFormEvent.passwordChanged(value),
      ),
    );
  }
}
