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

class MemberUserCancelPayDialog {
  static final String _tag = 'MemberUserCancelPayDialog';

  static void show(
      {required VoidCallback payClick, required VoidCallback cancelClick}) {
    SmartDialog.show(
        tag: _tag,
        backDismiss: false,
        clickMaskDismiss: false,
        builder: (_) {
          return _MemberUserCancelPayDialogWidget(
              payClick: payClick, cancelClick: cancelClick);
        });
  }

  static void dismiss() {
    SmartDialog.dismiss(tag: _tag);
  }
}

class _MemberUserCancelPayDialogWidget extends Dialog {
  final VoidCallback payClick;
  final VoidCallback cancelClick;

  const _MemberUserCancelPayDialogWidget(
      {required this.payClick, required this.cancelClick});

  @override
  Widget build(BuildContext context) {
    return Container(
      child: IntrinsicHeight(
        child: Column(
          children: [
            Stack(
              children: [
                AspectRatio(
                    aspectRatio: 1110 / 1296,
                    child: Assets.images.imgMemberUserCancelsContainer
                        .image(width: 301.w)),
                Positioned(
                  top: 360.w,
                  left: 60.w,
                  right: 60.w,
                  child: GestureDetector(
                    onTap: () {
                      MemberUserCancelPayDialog.dismiss();
                      payClick();
                    },
                    child: Container(
                      height: 40.w,
                      decoration: BoxDecoration(
                        gradient: LinearGradient(
                          begin: Alignment.centerLeft, // 90度相当于从左到右
                          end: Alignment.centerRight,
                          colors: [
                            Color(0xFF7B7DFF), // #7B7DFF
                            Color(0xFF6365FF), // #6365FF
                          ],
                          stops: [0.0, 1.0],
                          // 从0%到100%
                        ),
                        borderRadius: BorderRadius.circular(40.w / 2.0),
                      ),
                      //getPrimaryBtnDecoration(100.w),
                      child: Center(
                        child: Text("立即领取",
                            style: TextStyle(
                                fontSize: 15.sp, color: Colors.white)),
                      ),
                    ),
                  ),
                ),
              ],
            ),
            SizedBox(height: 24.w,),
            Center(
              child: GestureDetector(
                onTap: () {
                  MemberUserCancelPayDialog.dismiss();
                  cancelClick();
                },
                child: Assets.images.iconMemberRetainClose
                    .image(width: 32.w, height: 32.w),
              ),
            )
          ],
        ),
      ),
    );
  }
}
