import { Image, View } from '@tarojs/components'
import classnames from 'classnames'
import { useEffect, useState } from 'react'
import style from './index.module.scss'
import { usePropsValue } from '@/use/useCommon'
interface PropsType {
showOverLay?: boolean
show: boolean
onClose?: (show: boolean) => void
onChange?: (isShow) => void
children?: React.ReactNode
}
// 弹出框
const Dialog = (props: PropsType) => {
const { showOverLay = true, show = false, onClose: _onClose, onChange: _onChange, children } = props
const [_show, setShow] = usePropsValue({
value: show,
defaultValue: false,
onChange: (value) => {
_onChange?.(value)
},
})
const [animShow, setAnimShow] = useState(false)
const handleAnimShow = () => {
setShow(true)
setTimeout(() => {
setAnimShow(true)
}, 200)
}
const handleAnimHide = () => {
setAnimShow(false)
setTimeout(() => {
setShow(false)
}, 200)
}
const onClose = () => {
handleAnimHide()
_onClose?.(_show)
}
useEffect(() => {
if (show) {
handleAnimShow()
}
}, [show])
return _show
?
{/* 遮罩层 start */}
{/* 遮罩层 end */}
{children}
:
}
export default Dialog