| 1234567891011121314151617181920212223242526272829303132333435 |
- import { Toast, Portal } from '@ant-design/react-native'
- const myToast = (now) => ({
- tKey: '',
- loading() {
- const { tKey } = now()
- if (!tKey) {
- const newKey = Toast.loading('Loading...', 0)
- now({
- tKey: newKey,
- })
- }
- },
- success(title) {
- const { clearLoading } = now()
- clearLoading()
- Toast.success(title, 2)
- },
- warnning(title) {
- const { clearLoading } = now()
- clearLoading()
- Toast.info(title, 2)
- },
- clearLoading() {
- const { tKey } = now()
- if (tKey) {
- Portal.remove(tKey)
- now({
- tKey: '',
- })
- }
- },
- })
- export default myToast
|