import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.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/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/presentation/habib_wallet/habib_wallet_page.dart';
import 'package:hmg_patient_app_new/presentation/habib_wallet/recharge_wallet_page.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
import 'package:provider/provider.dart';

class HabibWalletCard extends StatelessWidget {
  const HabibWalletCard({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        // Row(
        //   mainAxisAlignment: MainAxisAlignment.spaceBetween,
        //   children: [
        //     LocaleKeys.myBalanceSubtitle.tr(context: context).toText16(isBold: true),
        //     // Row(
        //     //   children: [
        //     //     LocaleKeys.viewAllServices.tr(context: context).toText12(color: AppColors.primaryRedColor, isBold: true),
        //     //     SizedBox(width: 2.h),
        //     //     Icon(Icons.arrow_forward_ios, color: AppColors.primaryRedColor, size: 14.h),
        //     //   ],
        //     // ),
        //   ],
        // ).paddingSymmetrical(24.h, 0.h),
        SizedBox(height: 16.h),
        Container(
          // height: 150.h,
          width: 355.h,
          decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
            color: AppColors.whiteColor,
            borderRadius: 24,
          ),
          child: Stack(children: [
            Positioned(
              right: 0,
              child: ClipRRect(
                  borderRadius: BorderRadius.circular(24.0),
                  child: Utils.buildSvgWithAssets(icon: AppAssets.habib_background_icon, width: 150.h, height: 150.h, applyThemeColor: false)),
            ),
            Padding(
              padding: EdgeInsets.all(16.h),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  // Row(
                  //   mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  //   children: [
                  LocaleKeys.habibWallet.tr(context: context).toText16(isBold: true, letterSpacing: -0.2),
                  // Container(
                  //   height: 40.h,
                  //   width: 40.h,
                  //   decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
                  //     color: AppColors.textColor,
                  //     borderRadius: 8.h,
                  //   ),
                  //   child: Padding(
                  //     padding: EdgeInsets.all(8.h),
                  //     child: Utils.buildSvgWithAssets(
                  //       icon: AppAssets.show_icon,
                  //       width: 12.h,
                  //       height: 12.h,
                  //       fit: BoxFit.contain,
                  //     ),
                  //   ),
                  // ),
                  // ],
                  // ),
                  SizedBox(height: 4.h),
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Consumer<HabibWalletViewModel>(builder: (context, habibWalletVM, child) {
                        return Row(
                          mainAxisSize: MainAxisSize.max,
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Row(
                              children: [
                                Utils.buildSvgWithAssets(
                                  icon: (getIt.get<AppState>().getAuthenticatedUser()!.outSa == 1) ? AppAssets.uae_dirham_symbol : AppAssets.saudi_riyal_icon,
                                  iconColor: AppColors.inputLabelTextColor,
                                  width: 24.h,
                                  height: 24.h,
                                  fit: BoxFit.contain,
                                ),
                                SizedBox(width: 8.h),
                                NumberFormat.decimalPattern()
                                    .format(habibWalletVM.habibWalletAmount)
                                    .toString()
                                    .toText32(isBold: true, isEnglishOnly: true)
                                    .toShimmer2(isShow: habibWalletVM.isWalletAmountLoading, radius: 12.h, width: 80.h, height: 40.h),
                              ],
                            ),
                            Spacer(),
                            Utils.getPaymentMethods(spacing: 3, width: 30, height: 30),
                          ],
                        );
                      }),
                    ],
                  ),
                  SizedBox(height: 16.h),
                  Row(
                    children: [
                      Expanded(
                        flex: 6,
                        child: CustomButton(
                          height: 40.h,
                          icon: AppAssets.recharge_icon,
                          iconColor: AppColors.infoColor,
                          iconSize: 24.h,
                          backgroundColor: AppColors.infoColor.withAlpha(15),
                          textColor: AppColors.infoColor,
                          text: LocaleKeys.recharge.tr(context: context),
                          borderWidth: 0.w,
                          fontWeight: FontWeight.w600,
                          borderColor: AppColors.infoColor.withAlpha(15),
                          padding: EdgeInsets.fromLTRB(4, 0, 12, 0),
                          fontSize: 14.f,
                          onPressed: () {
                            Navigator.of(context).push(CustomPageRoute(page: RechargeWalletPage()));
                          },
                        ),
                      ),
                      SizedBox(width: 8.h),
                      Expanded(
                        flex: 1,
                        child: Container(
                          height: (isFoldable || isTablet) ? 50.h : 40.h,
                          decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
                            color: AppColors.textColor,
                            borderRadius: 10.h,
                            side: BorderSide(
                              color: AppColors.textColor,
                              width: 1.2,
                            ),
                          ),
                          child: Transform.flip(
                            flipX: getIt.get<AppState>().isArabic(),
                            child: Utils.buildSvgWithAssets(
                              icon: AppAssets.forward_arrow_icon,
                              iconColor: AppColors.whiteColor,
                              width: 24.w,
                              height: 24.h,
                              fit: BoxFit.contain,
                            ),
                          ),
                        ).onPress(() {
                          Navigator.of(context).push(
                            CustomPageRoute(
                              page: HabibWalletPage(),
                            ),
                          );
                        }),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ]),
        ).paddingSymmetrical(0.h, 0.h).onPress(() {
          Navigator.of(context).push(
            CustomPageRoute(
              page: HabibWalletPage(),
            ),
          );
        }),
      ],
    );
  }
}
