import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:krow/core/presentation/styles/kw_text_styles.dart';
import 'package:krow/core/presentation/styles/theme.dart';
import 'package:krow/features/profile/email_verification/domain/bloc/email_verification_bloc.dart';

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

  @override
  State<VerificationActionsWidget> createState() =>
      _VerificationActionsWidgetState();
}

//TODO: Finish this widget incorporating increasing timer on each code resend.
class _VerificationActionsWidgetState extends State<VerificationActionsWidget> {
  double secondsToHold = 1;
  bool onHold = false;

  @override
  Widget build(BuildContext context) {
    final screenHeight = MediaQuery.sizeOf(context).height;
    return Center(
      child: Padding(
        padding: EdgeInsets.only(top: screenHeight / 4.6),
        child: RichText(
          textAlign: TextAlign.center,
          text: TextSpan(
            text: 'didnt_receive'.tr(),
            style: AppTextStyles.bodyMediumReg
                .copyWith(color: AppColors.blackGray),
            children: [
              TextSpan(
                text: 'resend'.tr(),
                style: AppTextStyles.bodyMediumSmb,
                recognizer: TapGestureRecognizer()
                  ..onTap = () {
                    context
                        .read<EmailVerificationBloc>()
                        .add(const ResendVerificationEmail());
                  },
              ),
              TextSpan(
                text: ' ${'or'.tr()} ',
                style: AppTextStyles.bodyMediumReg
                    .copyWith(color: AppColors.blackGray),
              ),
              TextSpan(
                text: 'contact_support_1'.tr(),
                style: AppTextStyles.bodyMediumSmb,
                recognizer: TapGestureRecognizer()..onTap = () {
                  //TODO: Add Contact support action.
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}
