import React from 'react'; import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, Image, TouchableOpacity, View, DeviceEventEmitter } from 'react-native'; import { colors, size, statusBarHeight, toastShort } from '../../utils'; import { BjTypeSheetOption } from '../../utils/types'; import NormalHeader from '../kits/NormalHeader'; interface Props { navigation?: any route?: { params?: { any } } headerTitle?: string headerSubTitle?: string children: any pageBackgroundColor?: string headerType?: 'normal' | 'search', headerMode?: 'dark' | 'light', headerBackgroundColor?: string pageKey?: string onPickerResult?: Function optionListMap?: Array<{ id: string title?: string options: Array }> headerRightComponent?: any } interface State { } export default class PageWrapper extends React.Component { constructor(props: Props) { super(props); }; public onSheetPickerListener = null; public readonly state: Readonly = { }; componentDidMount() { this.onSheetPickerListener = DeviceEventEmitter.addListener('on-common-sheet-change', (a) => { const { onPickerResult, pageKey } = this.props; if (a.pageKey == pageKey) { onPickerResult && onPickerResult({ key: a.key, e: a.e }) } }) }; componentWillUnmount(): void { this.onSheetPickerListener && this.onSheetPickerListener?.remove(); } showSheet(key) { console.log("showSheet", key) const { pageKey, optionListMap, } = this.props; const findSheetOptions = optionListMap.find(ele => { return ele.id === key; }); if (findSheetOptions) { DeviceEventEmitter.emit('show-common-sheet', { key: key, pageKey: pageKey, sheetTitle: findSheetOptions.title, sheetOptions: findSheetOptions.options }) } else { toastShort("无数据") } } render() { const { children, pageBackgroundColor = '#fff', headerType, headerTitle, headerBackgroundColor = colors.themeColor, headerMode = 'light', headerRightComponent, headerSubTitle } = this.props; return ( { headerType && headerType === 'normal' ? : null } {children} ) } } const styles = StyleSheet.create({ page: { position: 'relative', width: '100%', flex: 1, backgroundColor: '#fff' }, header: { width: '100%', height: statusBarHeight + size.head_height, backgroundColor: colors.themeColor } })