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

import '../../../../../application/auth/login_form/login_form_bloc.dart';
import '../../../../../common/extension/extension.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(
      title: context.lang.password,
      prefixIcon: LineIcons.lock,
      hintText: context.lang.password_placeholder,
      validator: (value) => AppValidator.validatePassword(
        context.read<LoginFormBloc>().state.password,
      ),
      onChanged: (value) => context.read<LoginFormBloc>().add(
        LoginFormEvent.passwordChanged(value),
      ),
    );
  }
}
