/** * Dialog * @邠心vbe on 2021/02/20 */ import React from 'react'; import * as Progress from 'react-native-progress'; import {Pressable, StyleSheet, Text, View, Image} from 'react-native'; import Toast from 'react-native-root-toast'; import utils from '../utils/utils'; import ModalPortal from './ModalPortal'; import Button from './Button'; const maxDef = isIOS ? 480 : 540; var _maxWidth = isIOS ? $vw(75) : $vw(87); const maxWidth = _maxWidth > maxDef ? maxDef: _maxWidth; const BUTTON_OK = 'ok'; const BUTTON_CANCEL = 'cancel'; export const getDialogWidth = () => { return maxWidth; } /** * 显示一个弹窗 * @param {*} props 参数{title, message, ok, cancel, showCancel, callback(button)} */ const showDialog = (props) => { var param = { align: props.align || 'left', title: props.title || '', message: props.message || '', ok: props.ok || 'OK', cancel: props.cancel || 'CANCEL', showCancel: props.showCancel != undefined ? props.showCancel : true, callback: props.callback } ModalPortal.show(( isIOS ? : )); } /** * 显示一个只有确认按钮的弹窗 * @param {}} message 消息 * @param {*} ok 按钮文字 * @param {*} back callback(btn) */ const showResultDialog = (message, ok, back) => { var param = { title: isIOS ? message : '', message: !isIOS ? message : '', showCancel: false, ok: ok || 'I Known', callback: back } showDialog(param); } const showProgressDialog = (message='Loading...') => { //message = message ?? 'Waiting...'; ModalPortal.showLoading(( isIOS ? : )); } const dismissDialog = () => { ModalPortal.dismiss(); } const dismissLoading = () => { ModalPortal.dismissLoading(); } const dismissAll = () => { ModalPortal.dismissAll(); } const IOSDialog = (props) => { return ( { props.title != '' && {props.title} } { props.message != '' && {props.message} }