import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:gap/gap.dart';
import 'package:krow/core/data/static/contacts_data.dart';
import 'package:krow/core/presentation/gen/assets.gen.dart';
import 'package:krow/core/presentation/styles/kw_box_decorations.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/contact_icon_button.dart';
import 'package:krow/core/presentation/widgets/ui_kit/kw_app_bar.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:whatsapp_unilink/whatsapp_unilink.dart';

@RoutePage()
class WaitingValidationScreen extends StatefulWidget {
  const WaitingValidationScreen({super.key});

  @override
  State<WaitingValidationScreen> createState() =>
      _WaitingValidationScreenState();
}

class _WaitingValidationScreenState extends State<WaitingValidationScreen> {
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Positioned.fill(
          child: Container(
            color: AppColors.bgColorDark,
            child: SvgPicture.asset(
              Assets.images.bg.path,
              fit: BoxFit.cover,
            ),
          ),
        ),
        Scaffold(
          backgroundColor: Colors.transparent,
          appBar: buildAppBar(),
          body: SafeArea(
            child: Column(
              children: [
                Container(
                  margin: const EdgeInsets.only(top: 120, left: 16, right: 16),
                  padding: const EdgeInsets.all(12),
                  decoration: KwBoxDecorations.primaryDark,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Assets.images.waitingValidation.coffeeBreak.svg(),
                      const Gap(24),
                      Text(
                        'your_account_is_being_verified'.tr(),
                        textAlign: TextAlign.center,
                        style: AppTextStyles.headingH1.copyWith(
                          color: Colors.white,
                        ),
                      ),
                      const Gap(8),
                      Text(
                        'waiting_for_email_interview'.tr(),
                        style: AppTextStyles.bodyMediumReg.copyWith(
                          color: AppColors.textPrimaryInverted,
                        ),
                      ),
                      const Gap(24),
                      Text(
                        '${'contact_support_via'.tr()}:',
                        style: AppTextStyles.bodyMediumMed.copyWith(
                          color: AppColors.primaryYellow,
                        ),
                      ),
                      const Gap(12),
                      buildContactsGroup()
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),
      ],
    );
  }

  Row buildContactsGroup() {
    return Row(
      spacing: 24,
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        ContactIconButton(
          icon: Assets.images.waitingValidation.call,
          onTap: () {
            launchUrlString('tel:${ContactsData.supportPhone}');
          },
        ),
        ContactIconButton(
          icon: Assets.images.waitingValidation.sms,
          onTap: () {
            launchUrlString('mailto:${ContactsData.supportEmail}');
          },
        ),
        ContactIconButton(
          icon: Assets.images.waitingValidation.whatsapp,
          onTap: () {
            const link = WhatsAppUnilink(
              phoneNumber: ContactsData.supportPhone,
              text: 'Hey!',
            );
            launchUrlString(link.toString());
          },
        ),
      ],
    );
  }

  AppBar buildAppBar() {
    return KwAppBar(
      backgroundColor: Colors.transparent,
      iconColorStyle: AppBarIconColorStyle.inverted,
      showNotification: false,
      contentColor: AppColors.primaryYellow,
    );
  }
}
