package com.yidian.bcommon.utils

import android.app.Activity
import com.yidian.bcommon.widget.DialogBuilder
import com.yidian.xpage.XPageManager

object DialogUtils {

  /**
   * 确定退出activity的提示框
   */
  fun showConfirmDialog(activity: Activity, remindMsg: String) {
    var dialog = DialogBuilder.CommonDialog(activity)
    dialog = DialogBuilder()
      .showMsg(true, remindMsg)
      .showPositive(true) {
        activity.finish()
        dialog.dismiss()
      }
      .showNavigate(true)
      .build(activity)
    dialog?.show()
  }

  /**
   * 权限提示弹框
   */
  fun showPermissionDialog(activity: Activity, permission: String) {
    var dialog: DialogBuilder.CommonDialog? = null
    dialog = DialogBuilder()
      .showTitle(true, permission + "权限，请到 “应用信息 -> 权限” 中授予！")
      .showPositive(true) {
        SystemSettingUtils.openAppSettingDetail(activity)
        dialog?.dismiss()
      }
      .showNavigate(true)
      .build(activity)
    dialog?.show()
  }
}
