import {GlobalState} from '@/utils/stateMapper'; import {DeviceEventEmitter} from 'react-native'; import panels from './types'; type IPanel = typeof panels; type IPanelkeys = keyof IPanel; interface IPanelInfo { name: IPanelkeys | null; payload: any; } /** 浮层信息 */ export const panelInfoStore = new GlobalState({ name: null, payload: null, }); export function showPanel( name: T, payload?: Parameters[0], ) { if (panelInfoStore.getValue().name) { DeviceEventEmitter.emit('hidePanel', () => { panelInfoStore.setValue({ name, payload, }); }); } else { panelInfoStore.setValue({ name, payload, }); } } export function hidePanel() { DeviceEventEmitter.emit('hidePanel'); }