/** * Copyright 2004-present Facebook. All Rights Reserved. * * @providesModule JumpingNavSample */ 'use strict'; var Navigator = require('Navigator'); var React = require('React'); var StyleSheet = require('StyleSheet'); var ScrollView = require('ScrollView'); var Text = require('Text'); var TouchableBounce = require('TouchableBounce'); var View = require('View'); var _getRandomRoute = function() { return { randNumber: Math.random(), }; }; var INIT_ROUTE = _getRandomRoute(); var ROUTE_STACK = [ _getRandomRoute(), _getRandomRoute(), INIT_ROUTE, _getRandomRoute(), _getRandomRoute(), ]; var renderScene = function(route, navigator) { return ( {route.randNumber} { navigator.jumpBack(); }}> jumpBack { navigator.jumpForward(); }}> jumpForward { navigator.jumpTo(INIT_ROUTE); }}> jumpTo initial route { navigator.push(_getRandomRoute()); }}> destructive: push { navigator.replace(_getRandomRoute()); }}> destructive: replace { navigator.pop(); }}> destructive: pop { navigator.immediatelyResetRouteStack([ _getRandomRoute(), _getRandomRoute(), ]); }}> destructive: Immediate set two routes { navigator.popToTop(); }}> destructive: pop to top ); }; class JumpingNavBar extends React.Component { render() { return ( {this.props.routeStack.map((route, index) => ( { this.props.navigator.jumpTo(route); }}> {index} ))} ); } } var JumpingNavSample = React.createClass({ render: function() { return ( } shouldJumpOnBackstackPop={true} /> ); }, }); var styles = StyleSheet.create({ scene: { backgroundColor: '#eeeeee', }, scroll: { flex: 1, }, button: { backgroundColor: '#cccccc', margin: 50, marginTop: 26, padding: 10, }, buttonText: { fontSize: 12, textAlign: 'center', }, appContainer: { overflow: 'hidden', backgroundColor: '#dddddd', flex: 1, }, navBar: { position: 'absolute', bottom: 0, left: 0, right: 0, height: 90, flexDirection: 'row', }, navButton: { flex: 1, }, navButtonText: { textAlign: 'center', fontSize: 32, marginTop: 25, }, navButtonActive: { color: 'green', }, }); module.exports = JumpingNavSample;