import React from 'react'; import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, Image, TouchableOpacity, View, DeviceEventEmitter } from 'react-native'; import { colors, onePx, px2dp } from '../../utils'; interface Props { navigationState: { routes: Array index?: number } jumpTo?: Function onActiveIndexChange?: Function } interface State { } export default class HomePageTabBar extends React.Component { constructor(props: Props) { super(props); }; public readonly state: Readonly = { }; handleJumpTo(ele, index) { const { jumpTo, onActiveIndexChange } = this.props; console.log("jumpTo", ele) jumpTo && jumpTo(ele.key); onActiveIndexChange && onActiveIndexChange(index) }; openSelectResearchTypeToast(){ const researchTypeList = [ { name: "幼树调查", type: 'smallTreeResearch', icon: null, active: false }, { name: "幼苗调查", type: 'smallSeedlingResearch', icon: null, active: false } ] DeviceEventEmitter.emit('show-selete-research-type-toast', { key: 'ActualMeasurementResearchTable', researchTypeList }) }; render() { console.log("HomePageTabBar", this.props) console.log("HomePageTabBar", JSON.stringify(this.props.navigationState.routes)) const { navigationState: { routes, index } } = this.props; return ( { routes && routes.map((ele, eleIndex) => { return ( { eleIndex == 0 ? this.handleJumpTo(ele, eleIndex)} > {ele.title} 幼 : this.handleJumpTo(ele, eleIndex)} key={eleIndex + ''} > {ele.title} } ) }) } ) } } const styles = StyleSheet.create({ container: { width: px2dp(375), height: px2dp(38), backgroundColor: '#fff', borderBottomColor: '#d2d2d2', borderBottomWidth: onePx }, content: { justifyContent: 'flex-start', alignItems: 'flex-end', paddingLeft: px2dp(12.5) }, btn1: { height: px2dp(32), width: px2dp(96), borderWidth: onePx, borderColor: '#d2d2d2', borderTopLeftRadius: px2dp(8), borderTopRightRadius: px2dp(8), overflow: 'hidden', justifyContent: 'center', alignItems: 'center', marginRight: px2dp(5), backgroundColor: '#fff', flexDirection: 'row', borderBottomWidth: 0 }, mainBtn: { flex: 1, height: '100%', justifyContent: 'center', alignItems: 'center' }, inlineBtn: { width: px2dp(24), height: px2dp(24), backgroundColor: colors.themeColor, justifyContent: 'center', alignItems: 'center', marginRight: px2dp(10), borderRadius: px2dp(2) }, btn: { width: px2dp(52), height: px2dp(32), borderWidth: onePx, borderColor: '#d2d2d2', borderTopLeftRadius: px2dp(8), borderTopRightRadius: px2dp(8), overflow: 'hidden', justifyContent: 'center', alignItems: 'center', marginRight: px2dp(5), backgroundColor: '#f2f2f2', borderBottomWidth: 0 } })