mirror of
https://github.com/status-im/react-native.git
synced 2025-02-26 16:10:58 +00:00
Seperate NavigatorIOS Example from UIExplorer Navigation
Summary: We want to use a different navigation system for UIExplorer Reviewed By: javache Differential Revision: D2948412 fb-gh-sync-id: 43f2ff5e00582f065a992e32ea6d6ef159b92f60 shipit-source-id: 43f2ff5e00582f065a992e32ea6d6ef159b92f60
This commit is contained in:
parent
fa3a67e251
commit
26402ea0b5
@ -15,11 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var React = require('react-native');
|
const React = require('react-native');
|
||||||
var ViewExample = require('./ViewExample');
|
const ViewExample = require('./ViewExample');
|
||||||
var createExamplePage = require('./createExamplePage');
|
const createExamplePage = require('./createExamplePage');
|
||||||
var {
|
const {
|
||||||
AlertIOS,
|
AlertIOS,
|
||||||
|
NavigatorIOS,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
@ -27,8 +28,7 @@ var {
|
|||||||
View,
|
View,
|
||||||
} = React;
|
} = React;
|
||||||
|
|
||||||
var EmptyPage = React.createClass({
|
const EmptyPage = React.createClass({
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<View style={styles.emptyPage}>
|
<View style={styles.emptyPage}>
|
||||||
@ -38,41 +38,24 @@ var EmptyPage = React.createClass({
|
|||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var NavigatorIOSExample = React.createClass({
|
const NavigatorIOSExamplePage = React.createClass({
|
||||||
|
|
||||||
statics: {
|
|
||||||
title: '<NavigatorIOS>',
|
|
||||||
description: 'iOS navigation capabilities',
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var recurseTitle = 'Recurse Navigation';
|
var recurseTitle = 'Recurse Navigation';
|
||||||
if (!this.props.topExampleRoute) {
|
if (!this.props.depth || this.props.depth === 1) {
|
||||||
recurseTitle += ' - more examples here';
|
recurseTitle += ' - more examples here';
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<ScrollView style={styles.list}>
|
<ScrollView style={styles.list}>
|
||||||
<View style={styles.line}/>
|
|
||||||
<View style={styles.group}>
|
|
||||||
<View style={styles.row}>
|
|
||||||
<Text style={styles.rowNote}>
|
|
||||||
See <UIExplorerApp> for top-level usage.
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
<View style={styles.line}/>
|
|
||||||
<View style={styles.groupSpace}/>
|
|
||||||
<View style={styles.line}/>
|
<View style={styles.line}/>
|
||||||
<View style={styles.group}>
|
<View style={styles.group}>
|
||||||
{this._renderRow(recurseTitle, () => {
|
{this._renderRow(recurseTitle, () => {
|
||||||
this.props.navigator.push({
|
this.props.navigator.push({
|
||||||
title: NavigatorIOSExample.title,
|
title: NavigatorIOSExample.title,
|
||||||
component: NavigatorIOSExample,
|
component: NavigatorIOSExamplePage,
|
||||||
backButtonTitle: 'Custom Back',
|
backButtonTitle: 'Custom Back',
|
||||||
passProps: {topExampleRoute: this.props.topExampleRoute || this.props.route},
|
passProps: {depth: this.props.depth ? this.props.depth + 1 : 1},
|
||||||
});
|
});
|
||||||
})}
|
})}
|
||||||
{this._renderRow('Push View Example', () => {
|
{this._renderRow('Push View Example', () => {
|
||||||
@ -122,40 +105,39 @@ var NavigatorIOSExample = React.createClass({
|
|||||||
{this._renderRow('Pop to top', () => {
|
{this._renderRow('Pop to top', () => {
|
||||||
this.props.navigator.popToTop();
|
this.props.navigator.popToTop();
|
||||||
})}
|
})}
|
||||||
{this._renderRow('Replace here', () => {
|
{this._renderReplace()}
|
||||||
var prevRoute = this.props.route;
|
|
||||||
this.props.navigator.replace({
|
|
||||||
title: 'New Navigation',
|
|
||||||
component: EmptyPage,
|
|
||||||
rightButtonTitle: 'Undo',
|
|
||||||
onRightButtonPress: () => this.props.navigator.replace(prevRoute),
|
|
||||||
passProps: {
|
|
||||||
text: 'The component is replaced, but there is currently no ' +
|
|
||||||
'way to change the right button or title of the current route',
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
{this._renderReplacePrevious()}
|
{this._renderReplacePrevious()}
|
||||||
{this._renderReplacePreviousAndPop()}
|
{this._renderReplacePreviousAndPop()}
|
||||||
{this._renderPopToTopNavExample()}
|
{this._renderRow('Exit NavigatorIOS Example', this.props.onExampleExit)}
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.line}/>
|
<View style={styles.line}/>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderPopToTopNavExample: function() {
|
_renderReplace: function() {
|
||||||
if (!this.props.topExampleRoute) {
|
if (!this.props.depth) {
|
||||||
|
// this is to avoid replacing the top of the stack
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this._renderRow('Pop to top NavigatorIOSExample', () => {
|
return this._renderRow('Replace here', () => {
|
||||||
this.props.navigator.popToRoute(this.props.topExampleRoute);
|
var prevRoute = this.props.route;
|
||||||
|
this.props.navigator.replace({
|
||||||
|
title: 'New Navigation',
|
||||||
|
component: EmptyPage,
|
||||||
|
rightButtonTitle: 'Undo',
|
||||||
|
onRightButtonPress: () => this.props.navigator.replace(prevRoute),
|
||||||
|
passProps: {
|
||||||
|
text: 'The component is replaced, but there is currently no ' +
|
||||||
|
'way to change the right button or title of the current route',
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderReplacePrevious: function() {
|
_renderReplacePrevious: function() {
|
||||||
if (!this.props.topExampleRoute) {
|
if (!this.props.depth || this.props.depth < 2) {
|
||||||
// this is to avoid replacing the UIExplorerList at the top of the stack
|
// this is to avoid replacing the top of the stack
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this._renderRow('Replace previous', () => {
|
return this._renderRow('Replace previous', () => {
|
||||||
@ -171,8 +153,8 @@ var NavigatorIOSExample = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_renderReplacePreviousAndPop: function() {
|
_renderReplacePreviousAndPop: function() {
|
||||||
if (!this.props.topExampleRoute) {
|
if (!this.props.depth || this.props.depth < 2) {
|
||||||
// this is to avoid replacing the UIExplorerList at the top of the stack
|
// this is to avoid replacing the top of the stack
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this._renderRow('Replace previous and pop', () => {
|
return this._renderRow('Replace previous and pop', () => {
|
||||||
@ -203,7 +185,34 @@ var NavigatorIOSExample = React.createClass({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var styles = StyleSheet.create({
|
const NavigatorIOSExample = React.createClass({
|
||||||
|
statics: {
|
||||||
|
title: '<NavigatorIOS>',
|
||||||
|
description: 'iOS navigation capabilities',
|
||||||
|
external: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
const {onExampleExit} = this.props;
|
||||||
|
return (
|
||||||
|
<NavigatorIOS
|
||||||
|
style={styles.container}
|
||||||
|
initialRoute={{
|
||||||
|
title: NavigatorIOSExample.title,
|
||||||
|
component: NavigatorIOSExamplePage,
|
||||||
|
passProps: {onExampleExit},
|
||||||
|
}}
|
||||||
|
itemWrapperStyle={styles.itemWrapper}
|
||||||
|
tintColor="#008888"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
customWrapperStyle: {
|
customWrapperStyle: {
|
||||||
backgroundColor: '#bbdddd',
|
backgroundColor: '#bbdddd',
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user