UNPKG

@ant-design/react-native

Version:

基于蚂蚁金服移动设计规范的 React Native 组件库

35 lines (34 loc) 1.47 kB
import React from 'react'; import Portal from '../portal'; import ToastContainer from './ToastContainer'; function notice(content, type) { var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; var onClose = arguments[3]; var mask = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; var key = Portal.add(React.createElement(ToastContainer, { content: content, duration: duration, onClose: onClose, type: type, mask: mask, onAnimationEnd: function onAnimationEnd() { return Portal.remove(key); } })); return key; } export default { SHORT: 3, LONG: 8, show: function show(content, duration, mask) { return notice(content, 'info', duration, function () {}, mask); }, info: function info(content, duration, onClose, mask) { return notice(content, 'info', duration, onClose, mask); }, success: function success(content, duration, onClose, mask) { return notice(content, 'success', duration, onClose, mask); }, fail: function fail(content, duration, onClose, mask) { return notice(content, 'fail', duration, onClose, mask); }, offline: function offline(content, duration, onClose, mask) { return notice(content, 'offline', duration, onClose, mask); }, loading: function loading(content, duration, onClose, mask) { return notice(content, 'loading', duration, onClose, mask); } };