import 'package:flutter/cupertino.dart';
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/colors.gen.dart';
import 'package:location/resource/string.gen.dart';

class UrgentContactMoreActionPopup {
  static void show(BuildContext context, bool favor,
      {required VoidCallback onSetDefault, required VoidCallback onDelete}) {
    SmartDialog.showAttach(
        alignment: Alignment.bottomLeft,
        targetBuilder: (targetOffset, targetSize) =>
            targetOffset + Offset(-30.w, -10.w),
        animationType: SmartAnimationType.fade,
        maskColor: ColorName.transparent,
        targetContext: context,
        builder: (_) {
          return Container(
            decoration: BoxDecoration(
              image: DecorationImage(
                image: Assets.images.bgUrgentContactPopup.provider(),
                fit: BoxFit.fill,
              ),
            ),
            width: 140.w,
            height: 128.w,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                GestureDetector(
                  behavior: HitTestBehavior.translucent,
                  onTap: () {
                    SmartDialog.dismiss();
                    onSetDefault();
                  },
                  child: Container(
                    padding: EdgeInsets.symmetric(vertical: 8.w),
                    child: Text(
                      favor
                          ? StringName.urgentContactCancelDefault
                          : StringName.urgentContactSetDefault,
                      style: TextStyle(fontSize: 14.sp, color: ColorName.black),
                    ),
                  ),
                ),
                GestureDetector(
                  behavior: HitTestBehavior.translucent,
                  onTap: () {
                    SmartDialog.dismiss();
                    onDelete();
                  },
                  child: Container(
                    padding: EdgeInsets.symmetric(vertical: 8.w),
                    child: Text(
                      StringName.urgentContactSetDelete,
                      style: TextStyle(fontSize: 14.sp, color: ColorName.black),
                    ),
                  ),
                )
              ],
            ),
          );
        });
  }
}
