import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:gap/gap.dart';
import 'package:krow/core/presentation/styles/kw_text_styles.dart';
import 'package:krow/core/presentation/styles/theme.dart';
import 'package:krow/core/presentation/widgets/ui_kit/kw_input.dart';
import 'package:krow/features/sign_in/domain/bloc/sign_in_bloc.dart';

class ResetEmailForm extends StatefulWidget {
  const ResetEmailForm({super.key});

  @override
  State<ResetEmailForm> createState() => _ResetEmailFormState();
}

class _ResetEmailFormState extends State<ResetEmailForm> {
  var textEditingController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        const Gap(36),
        const Text(
          'Forgot Password?',
          style: AppTextStyles.headingH1,
        ),
        const Gap(8),
        Text(
          'Enter the email address associated with your account',
          style:
              AppTextStyles.bodyMediumReg.copyWith(color: AppColors.blackGray),
        ),
        const Gap(24),
        BlocBuilder<SignInBloc, SignInState>(
          builder: (context, state) {
            return KwTextInput(
                title: 'Email',
                hintText: 'Enter your email',
                keyboardType: TextInputType.emailAddress,
                onChanged: (str) {
                  context.read<SignInBloc>().add(SignInEventEmailChanged(str));
                },
                helperText: state.inputValidationError,
                showError: state.inputValidationError.isNotEmpty,
                controller: textEditingController);
          },
        ),
        const Gap(24),
      ],
    );
  }
}
