
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:location/resource/colors.gen.dart';
import 'package:location/utils/common_expand.dart';

import '../../resource/assets.gen.dart';

class UrgentContactClickHelpDialog {
  static void show({
    VoidCallback? cancelOnTap,
    VoidCallback? confirmOnTap,}) {
    Get.dialog(
        SimpleDialog(
          titlePadding: EdgeInsets.zero,
          contentPadding: EdgeInsets.zero,
          insetPadding: EdgeInsets.zero,
          backgroundColor:Colors.transparent,
          children: [
            MemberPaymentCompletedTipView(
                cancelOnTap: () {
                  Get.back();
                  cancelOnTap!();
                },
                confirmOnTap: confirmOnTap)
          ],
        )
    );
  }
}

class MemberPaymentCompletedTipView extends StatefulWidget {
  final VoidCallback? cancelOnTap;
  final VoidCallback? confirmOnTap;


  const MemberPaymentCompletedTipView({
    super.key,
    this.cancelOnTap,
    required this.confirmOnTap,
  });

  @override
  State<MemberPaymentCompletedTipView> createState() => _MemberPaymentCompletedTipViewState();
}

class _MemberPaymentCompletedTipViewState extends State<MemberPaymentCompletedTipView> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      width: 1.sw,
      margin: EdgeInsets.symmetric(horizontal: 42.w),
      child: IntrinsicHeight(
        child: Column(
          children: [
            Container(
              decoration: BoxDecoration(
                  color: Colors.transparent,
                  image: DecorationImage(
                    image: Assets.images.iconUrgentContactTipBg.provider(),
                    fit: BoxFit.fill,
                  )
              ),
              child: Column(
                children: [
                  SizedBox(
                    height: 150.w,
                  ),
                  Text("使用一键求助",
                      style: TextStyle(
                          fontSize: 20.sp,
                          color: "#333333".color,
                          fontWeight: FontWeight.bold)),
                  SizedBox(height: 8.w,),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Container(
                        decoration: BoxDecoration(
                          gradient: LinearGradient(
                            // 渐变方向：90度（从左到右）
                            begin: Alignment.centerLeft,
                            end: Alignment.centerRight,
                            // 渐变颜色：从透明灰到#AAA
                            colors: [
                              Color.fromRGBO(170, 170, 170, 0.0), // rgba(170, 170, 170, 0.00)
                              Color(0xFFAAAAAA), // #AAA
                            ],
                            // 渐变位置：0%到100%
                            stops: [0.0, 1.0],
                          ),
                        ),
                        width: 14.w,
                        height: 1.w,
                      ),
                      SizedBox(width: 6.w,),
                      Text("紧急情况，快速求助",
                          style: TextStyle(fontSize: 12.sp, color: ColorName.black60)),
                      SizedBox(width: 6.w,),
                      Container(
                        width: 14.w,
                        height: 1.w,
                        decoration: BoxDecoration(
                          gradient: LinearGradient(
                            // 90度渐变（从左到右）
                            begin: Alignment(1.0, 0.0), // 左侧起点
                            end: Alignment(-1.0, 0.0),   // 右侧终点
                            // 渐变颜色：透明灰到#AAA
                            colors: [
                              Color.fromARGB(0, 170, 170, 170), // rgba(170, 170, 170, 0.00)
                              Color(0xFFAAAAAA),               // #AAA
                            ],
                            // 颜色分布位置
                            stops: [0.0, 1.0],
                          ),
                        ),
                      )
                    ],
                  ),
                  SizedBox(
                    height: 32.w,
                  ),
                  GestureDetector(
                    onTap: () {
                      Get.back();
                      widget.confirmOnTap!();
                    },
                    child: Container(
                      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),
                      ),
                      margin: EdgeInsets.symmetric(horizontal: 20.w),
                      height: 40.w,
                      alignment: Alignment.center,
                      child: Text("立即求助",
                          style: TextStyle(
                              fontSize: 14.sp,
                              color: '#FFFFFF'.color,
                              fontWeight: FontWeight.w500)
                      ),
                    ),
                  ),
                  SizedBox(
                    height: 10.w,
                  ),
                  GestureDetector(
                    onTap: widget.cancelOnTap,
                    child: Container(
                      height: 20.w,
                      child: Text("下次再说",
                          style: TextStyle(
                              fontSize: 11.sp,
                              color: '#898996'.color,
                              fontWeight: FontWeight.w500)
                      ),
                    ),
                  ),

                  SizedBox(
                    height: 12.w,
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}