/** * @flow */ import React from 'react'; import { FlatList, SafeAreaView, StatusBar, Text, View } from 'react-native'; import { NavigationEvents } from 'react-navigation'; import { createMaterialBottomTabNavigator } from 'react-navigation-material-bottom-tabs'; import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; const Event = ({ event }) => ( {event.type} {event.action.type.replace('Navigation/', '')} {event.action.routeName ? '=>' + event.action.routeName : ''} ); const createTabScreen = (name, icon, focusedIcon) => { class TabScreen extends React.Component { static navigationOptions = { tabBarLabel: name, tabBarIcon: ({ tintColor, focused }) => ( ), }; state = { eventLog: [] }; append = navigationEvent => { this.setState(({ eventLog }) => ({ eventLog: eventLog.concat(navigationEvent), })); }; render() { return ( Events for tab {name} `${this.state.eventLog.indexOf(item)}`} renderItem={({ item }) => ( )} /> ); } } return TabScreen; }; const TabsWithNavigationEvents = createMaterialBottomTabNavigator( { One: { screen: createTabScreen('One', 'numeric-1-box-outline', 'numeric-1-box'), }, Two: { screen: createTabScreen('Two', 'numeric-2-box-outline', 'numeric-2-box'), }, Three: { screen: createTabScreen( 'Three', 'numeric-3-box-outline', 'numeric-3-box' ), }, }, { shifting: false, activeTintColor: '#F44336', } ); export default TabsWithNavigationEvents;