/** * Copyright 2004-present Facebook. All Rights Reserved. * * @providesModule BreadcrumbNavSample */ 'use strict'; var BreadcrumbNavigationBar = require('BreadcrumbNavigationBar'); var ReactNavigator = require('ReactNavigator'); var React = require('React'); var StyleSheet = require('StyleSheet'); var ScrollView = require('ScrollView'); var TabBarItemIOS = require('TabBarItemIOS'); var TabBarIOS = require('TabBarIOS'); var Text = require('Text'); var TouchableBounce = require('TouchableBounce'); var View = require('View'); var SAMPLE_TEXT = 'Top Pushes. Middle Replaces. Bottom Pops.'; var _getRandomRoute = function() { return { backButtonTitle: 'Back' + ('' + 10 * Math.random()).substr(0, 1), content: SAMPLE_TEXT + '\nHere\'s a random number ' + Math.random(), title: Math.random() > 0.5 ? 'Hello' : 'There', rightButtonTitle: Math.random() > 0.5 ? 'Right' : 'Button', }; }; var SampleNavigationBarRouteMapper = { rightContentForRoute: function(route, navigator) { if (route.rightButtonTitle) { return ( {route.rightButtonTitle} ); } else { return null; } }, titleContentForRoute: function(route, navigator) { return ( navigator.push(_getRandomRoute())}> {route.title} ); }, iconForRoute: function(route, navigator) { var onPress = navigator.popToRoute.bind(navigator, route); return ( ); }, separatorForRoute: function(route, navigator) { return ( ); } }; var _delay = 400; // Just to test for race conditions with native nav. var renderScene = function(route, navigator) { var content = route.content; return ( request push soon {content} {content} {content} {content} {content} request pop soon Immediate set two routes pop to top soon ); }; var _popToTopLater = function(popToTop) { return () => setTimeout(popToTop, _delay); }; var _pushRouteLater = function(push) { return () => setTimeout( () => push(_getRandomRoute()), _delay ); }; var _immediatelySetTwoItemsLater = function(immediatelyResetRouteStack) { return () => setTimeout( () => immediatelyResetRouteStack([ _getRandomRoute(), _getRandomRoute(), ]) ); }; var _popRouteLater = function(pop) { return () => setTimeout(pop, _delay); }; var BreadcrumbNavSample = React.createClass({ getInitialState: function() { return { selectedTab: 0, }; }, render: function() { var initialRoute = { backButtonTitle: 'Start', // no back button for initial scene content: SAMPLE_TEXT, title: 'Campaigns', rightButtonTitle: 'Filter', }; return ( } /> ReactNavigator.SceneConfigs.FloatFromBottom} debugOverlay={false} style={[styles.appContainer]} initialRoute={initialRoute} renderScene={renderScene} navigationBar={ } /> ); }, onTabSelect: function(tab, event) { if (this.state.selectedTab !== tab) { this.setState({selectedTab: tab}); } }, }); var styles = StyleSheet.create({ navigationItem: { backgroundColor: '#eeeeee', }, scene: { paddingTop: 50, flex: 1, }, button: { backgroundColor: '#cccccc', margin: 50, marginTop: 26, padding: 10, }, buttonText: { fontSize: 12, textAlign: 'center', }, appContainer: { overflow: 'hidden', backgroundColor: '#dddddd', flex: 1, }, titleText: { fontSize: 18, color: '#666666', textAlign: 'center', fontWeight: '500', lineHeight: 32, }, filterText: { color: '#5577ff', }, // TODO: Accept icons from route. crumbIconPlaceholder: { flex: 1, backgroundColor: '#666666', }, crumbSeparatorPlaceholder: { flex: 1, backgroundColor: '#aaaaaa', }, }); module.exports = BreadcrumbNavSample;