/** * Copyright (c) 2015-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ 'use strict'; var React = require('react-native'); var { Navigator, StyleSheet, ScrollView, Text, TouchableHighlight, View, } = React; 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;