import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:location/dialog/common_confirm_dialog.dart';
import 'package:location/resource/string.gen.dart';
import 'package:location/utils/common_expand.dart';

Widget getKindlyReminder() {
  return Text(StringName.kindlyReminder,
      style: TextStyle(
          fontSize: 17.sp,
          color: '#333333'.color,
          fontWeight: FontWeight.bold));
}

void requestContactsPermissionDialog({required VoidCallback onConfirm}) {
  CommonConfirmDialog.show(
      titleWidget: getKindlyReminder(),
      descWidget: Text(
        StringName.requestContactsContent,
        style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
      ),
      confirmText: Platform.isIOS
          ? StringName.nextStep
          : StringName.goRequestContactsPermission,
      confirmOnTap: onConfirm);
}

void showAddFriendConfirmDialog({required VoidCallback onConfirm}) {
  CommonConfirmDialog.show(
      titleWidget: getKindlyReminder(),
      descWidget: Text(
        StringName.friendAddExplain,
        style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
      ),
      confirmText: StringName.dialogSure,
      confirmOnTap: onConfirm);
}

void showLoginDialog({required VoidCallback onConfirm}) {
  CommonConfirmDialog.show(
      titleWidget: getKindlyReminder(),
      descWidget: Text(
        StringName.dialogNotLogin,
        style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
      ),
      confirmText: StringName.dialogGoLogin,
      confirmOnTap: onConfirm);
}

void showNotRegisteredDialog({required VoidCallback onConfirm}) {
  CommonConfirmDialog.show(
      titleWidget: getKindlyReminder(),
      descWidget: Text(
        StringName.inviteContent,
        style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
      ),
      confirmText: StringName.inviteBtn,
      confirmOnTap: onConfirm);
}

void showAppShareDialog({required VoidCallback onConfirm}) {
  CommonConfirmDialog.show(
      titleWidget: Text(StringName.shareFriendTitle,
          style: TextStyle(
              fontSize: 17.sp,
              color: '#333333'.color,
              fontWeight: FontWeight.bold)),
      descWidget: Text(
        StringName.shareFriendDesc,
        style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
      ),
      confirmText: StringName.inviteBtn,
      confirmOnTap: onConfirm);
}

void showTraceTipsDialog({required VoidCallback onConfirm}) {
  CommonConfirmDialog.show(
      titleWidget: Text(StringName.kindlyReminder,
          style: TextStyle(
              fontSize: 17.sp,
              color: '#333333'.color,
              fontWeight: FontWeight.bold)),
      descWidget: Text(
        StringName.dialogNotLoginViewTraceTip,
        style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
      ),
      confirmText: StringName.dialogGoLogin,
      confirmOnTap: onConfirm);
}

void showTraceNoDataDialog({required VoidCallback onConfirm}) {
  CommonConfirmDialog.show(
      titleWidget: Text(StringName.kindlyReminder,
          style: TextStyle(
              fontSize: 17.sp,
              color: '#333333'.color,
              fontWeight: FontWeight.bold)),
      descWidget: Text(
        StringName.trackNoData,
        style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
      ),
      confirmText: StringName.gotIt,
      confirmOnTap: onConfirm);
}

void showAgreeAddFriendTipDialog({required VoidCallback onConfirm}) {
  CommonConfirmDialog.show(
      titleWidget: Text(StringName.kindlyReminder,
          style: TextStyle(
              fontSize: 17.sp,
              color: '#333333'.color,
              fontWeight: FontWeight.bold)),
      descWidget: Text(
        StringName.messageAddFriendSureContent,
        style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
      ),
      confirmText: StringName.dialogSure,
      confirmOnTap: onConfirm);
}

void showPaymentSuccessDialog(
    {required VoidCallback onConfirm, required VoidCallback onCancel}) {
  CommonConfirmDialog.show(
      backDismiss: false,
      clickMaskDismiss: false,
      titleWidget: Text(StringName.paySuccessTitle,
          style: TextStyle(
              fontSize: 17.sp,
              color: '#333333'.color,
              fontWeight: FontWeight.bold)),
      descWidget: Text(
        StringName.paySuccessDesc,
        style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
      ),
      confirmText: StringName.dialogSure,
      cancelOnTap: onCancel,
      confirmOnTap: onConfirm);
}

void permissionRefuseDialog({required VoidCallback settingClick}) {
  CommonConfirmDialog.show(
      titleWidget: Text(StringName.kindlyReminder,
          style: TextStyle(
              fontSize: 17.sp,
              color: '#333333'.color,
              fontWeight: FontWeight.bold)),
      descWidget: Text(
        StringName.locationPermissionRefuseDesc,
        style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
      ),
      cancelOnTap: () {
        CommonConfirmDialog.dismiss();
      },
      confirmText: StringName.dialogLocationAlwaysPermissionConfirmTxt,
      confirmOnTap: () {
        CommonConfirmDialog.dismiss();
        settingClick.call();
      });
}
