import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_export.dart';
import 'package:hmg_patient_app_new/core/cache_consts.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/services/cache_service.dart';
import 'package:hmg_patient_app_new/services/navigation_service.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';

class QuickLogin extends StatefulWidget {
  final VoidCallback onPressed;
  final bool isDone;

  const QuickLogin({super.key, required this.onPressed, this.isDone = false});

  @override
  QuickLoginState createState() => QuickLoginState();
}

class QuickLoginState extends State<QuickLogin> {
  final CacheService cacheService = GetIt.instance<CacheService>();

  @override
  Widget build(BuildContext context) {
    NavigationService navigationService = getIt.get<NavigationService>();
    return Padding(
      padding: EdgeInsets.all(24.h),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          widget.isDone
              ? Column(
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        InkWell(
                            onTap: () {
                              navigationService.pop();
                            },
                            child: Utils.buildSvgWithAssets(icon: AppAssets.cross_circle)),
                      ],
                    ),
                    Utils.showLottie(context: context, assetPath: AppAnimations.checkmark, width: 120, height: 120, repeat: true),
                    LocaleKeys.allSet.tr(context: context).toText16(textAlign: TextAlign.center, isBold: true)
                    // Text(
                    //  ' TranslationBase.of(context).allSet',
                    //   textAlign: TextAlign.center,
                    //   style: context.dynamicTextStyle(
                    //     fontSize: 16,
                    //     isBold: true,
                    //     color: Colors.black,
                    //   ),
                    //  ),
                  ],
                )
              : Column(
                  mainAxisSize: MainAxisSize.min,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    // Image.asset(AppAssets.lockIcon, height: 100),
                    Utils.buildSvgWithAssets(icon: AppAssets.biometricLockIcon, iconColor: AppColors.textColor, width: 100.h, height: 100.h),
                    SizedBox(height: 10.h),
                    LocaleKeys.quickLogin.tr(context: context).toText26(isBold: true),
                    // Text(
                    //  ' TranslationBase.of(context).enableQuickLogin',
                    //   style: context.dynamicTextStyle(
                    //     fontSize: 26,
                    //     fontWeight: FontWeight.bold,
                    //     color: Colors.black,
                    //   ),
                    //  ),
                    // SizedBox(height: 5.h),
                    // LocaleKeys.enableQuickLogin.tr(context: context).toText16(color: AppColors.quickLoginColor),
                    // Description
                    // Text(
                    //   'TranslationBase.of(context).enableMsg',
                    //   style: context.dynamicTextStyle(
                    //     fontSize: 16,
                    //     color: Color(0xFF666666),
                    //     height: 1.5,
                    //   ),
                    //),
                    const SizedBox(height: 24),
                    // Buttons
                    Row(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        Expanded(
                            child: CustomButton(
                          text: LocaleKeys.enableQuickLoginBtn.tr(context: context),
                          onPressed: () {
                            widget.onPressed();
                          },
                          backgroundColor: Color(0xffED1C2B),
                          borderColor: Color(0xffED1C2B),
                          textColor: Colors.white,
                          icon: AppAssets.apple_finder,
                          height: 56.h,
                        )),
                      ],
                    ),
                    SizedBox(
                      height: 16.h,
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        Expanded(
                            child: CustomButton(
                          text: LocaleKeys.notNow.tr(context: context),
                          onPressed: () {
                            cacheService.saveBool(key: CacheConst.quickLoginEnabled, value: false);
                            Navigator.pop(context, "true");
                          },
                          backgroundColor: Color(0xffFEE9EA),
                          borderColor: Color(0xffFEE9EA),
                          textColor: Colors.red,
                          height: 56.h,
                          // icon: "assets/images/svg/apple-finder.svg",
                        )),
                      ],
                    ),
                  ],
                )
        ],
      ),
    );
  }
}
