import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:keyboard/resource/string.gen.dart';

import '../data/consts/web_url.dart';
import '../module/browser/browser_page.dart';
import '../resource/assets.gen.dart';
import '../resource/colors.gen.dart';
import '../utils/styles.dart';
import '../widget/click_text_span.dart';

// 支付失败
class PaymentFailDialog {
  static const String tag = 'PaymentFailDialog';

  static void show({Function? btnCancel, Function? btnConfirm}) {
    SmartDialog.show(
      tag: tag,
      backType: SmartBackType.block,
      clickMaskDismiss: true,
      maskColor: ColorName.black70,
      builder: (_) {
        return Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              margin: EdgeInsets.symmetric(horizontal: 31.w),
              decoration: ShapeDecoration(
                color: Colors.white,
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(20.r),
                ),
              ),
              child: Stack(
                children: [
                  Container(
                    width: double.infinity,
                    padding: EdgeInsets.symmetric(
                      horizontal: 16.w,
                      vertical: 16.h,
                    ),
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Assets.images.iconDialogPayFail.image(
                          width: 88.w,
                          height: 88.h,
                        ),
                        SizedBox(height: 8.h),
                        Text(
                          StringName.payFailDialogTitle,
                          style: Styles.getTextStyleBlack204W500(16.sp),
                        ),
                        Text(
                          StringName.payFailDialogDesc,
                          style: Styles.getTextStyleBlack153W400(14.sp),
                        ),
                        SizedBox(height: 24.h),
                        Row(
                          children: [
                            Expanded(
                              child: GestureDetector(
                                onTap: () {
                                  SmartDialog.dismiss();
                                  BrowserPage.start(WebUrl.qiyuService);
                                },
                                child: Container(
                                  height: 40.h,

                                  decoration: ShapeDecoration(
                                    color: const Color(0xFFF5F4F9),
                                    shape: RoundedRectangleBorder(
                                      borderRadius: BorderRadius.circular(50.r),
                                    ),
                                  ),
                                  child: Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Assets.images.iconDialogPayFailService
                                          .image(width: 22.w, height: 22.w),
                                      Text(
                                        StringName.payFailDialogCancel,
                                        style: Styles.getTextStyleBlack102W500(
                                          16.sp,
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                            ),
                            SizedBox(width: 8.w),
                            Expanded(
                              child: GestureDetector(
                                onTap: () {
                                  SmartDialog.dismiss();
                                  btnConfirm?.call();
                                },
                                child: Container(
                                  height: 40.h,
                                  decoration: Styles.getActivateButtonDecoration(
                                    22.r,
                                  ),
                                  child: Center(
                                    child: Text(
                                      StringName.payFailDialogContinue,
                                      style: Styles.getTextStyleWhiteW500(
                                        16.sp,
                                      ),
                                    ),
                                  ),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ],
                    ),
                  ),
                  Positioned(
                    right: 14.w,
                    top: 14.h,
                    child: GestureDetector(
                      onTap: () {
                        SmartDialog.dismiss();
                      },
                      child: Assets.images.iconCustomDialogClose.image(
                        width: 24.w,
                        height: 24.h,
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        );
      },
    );
  }
}
