import React, { useState } from "react"
import AwesomeAlert from 'react-native-awesome-alerts';
const ReactNative = require('react-native');
const AlertModal = props => {
const [alert, setAlert] = useState({
show: false,
showProgress: false,
title: "خطا",
message: "خطای ناشناخته",
closeOnTouchOutside: false,
closeOnHardwareBackPress: false,
showCancelButton: true,
showConfirmButton: true,
cancelText: "بیخیال",
confirmText: "باشه",
confirmButtonColor: "#2980b9",
onCancel: () => {
},
onConfirm: () => {
},
})
const [apiAlert, setApiAlert] = useState({
show: false,
showProgress: false,
title: "خطا",
message: "خطای ناشناخته",
closeOnTouchOutside: false,
closeOnHardwareBackPress: false,
showCancelButton: true,
showConfirmButton: true,
cancelText: "بیخیال",
confirmText: "باشه",
confirmButtonColor: "#2980b9",
onCancel: () => {
},
onConfirm: () => {
},
})
global.globalAlert = (params) => {
setAlert({
...alert,
...params
})
}
global.globalApiAlert = (params) => {
setApiAlert({
...apiAlert,
...params
})
}
function hideAlert() {
setAlert({ ...alert, show: false })
}
function onApiCancelPressed(){
globalApiAlert({ show: false })
apiAlert.onCancel()
}
function onApiConfirmPressed(){
globalApiAlert({ show: false })
apiAlert.onConfirm()
}
function onCancelPressed(){
hideAlert()
alert.onCancel()
}
function onConfirmPressed(){
hideAlert()
alert.onConfirm()
}
return <>
>
}
export default AlertModal;