import React from 'react'; import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, Image, TouchableOpacity, View, DeviceEventEmitter, } from 'react-native'; import { BjTypeSheetOption } from '../../utils/types'; import NormalActionSheet from './NormalActionSheet'; interface Props { } interface State { sheetTitle?: string sheetOptions?: Array } export default class KitComActionSheet extends React.Component { constructor(props: Props) { super(props); }; public comSheetRef = null; public tempSheetEnventKey = ""; public tempSheetPageKey = ""; public sheetShowListener = null; public readonly state: Readonly = { sheetTitle: "请选择", sheetOptions: [] }; componentDidMount() { this.sheetShowListener = DeviceEventEmitter.addListener('show-common-sheet', (a) => { this.tempSheetEnventKey = a.key; this.tempSheetPageKey = a.pageKey; this.setState({ sheetTitle: a.sheetTitle, sheetOptions: a.sheetOptions, }, () => this.comSheetRef.show() ) }) } componentWillUnmount(): void { this.sheetShowListener && this.sheetShowListener?.remove(); } onChange(e) { DeviceEventEmitter.emit('on-common-sheet-change', { e: e, key: this.tempSheetEnventKey, pageKey: this.tempSheetPageKey, }) }; render() { const { sheetTitle = "请选择", sheetOptions } = this.state; return ( <> this.comSheetRef = c} headerText={sheetTitle} options={sheetOptions} onChange={this.onChange.bind(this)} /> ) } }