2015-02-20 04:10:52 +00:00
|
|
|
/**
|
2015-03-28 05:18:47 +00:00
|
|
|
* The examples provided by Facebook are for non-commercial testing and
|
|
|
|
* evaluation purposes only.
|
2015-03-23 20:35:08 +00:00
|
|
|
*
|
2015-03-28 05:18:47 +00:00
|
|
|
* Facebook reserves all rights not expressly granted.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2015-03-23 20:35:08 +00:00
|
|
|
*
|
2015-03-23 18:36:57 +00:00
|
|
|
* @flow
|
2015-02-20 04:10:52 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2015-03-23 03:32:49 +00:00
|
|
|
var React = require('react-native');
|
2015-02-20 04:10:52 +00:00
|
|
|
var ViewExample = require('./ViewExample');
|
2015-04-03 17:02:49 +00:00
|
|
|
var createExamplePage = require('./createExamplePage');
|
2015-02-20 04:10:52 +00:00
|
|
|
var {
|
2015-05-07 14:16:59 +00:00
|
|
|
AlertIOS,
|
2015-02-20 04:10:52 +00:00
|
|
|
PixelRatio,
|
|
|
|
ScrollView,
|
|
|
|
StyleSheet,
|
|
|
|
Text,
|
|
|
|
TouchableHighlight,
|
|
|
|
View,
|
|
|
|
} = React;
|
|
|
|
|
|
|
|
var EmptyPage = React.createClass({
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
return (
|
|
|
|
<View style={styles.emptyPage}>
|
|
|
|
<Text style={styles.emptyPageText}>
|
|
|
|
{this.props.text}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
var NavigatorIOSExample = React.createClass({
|
|
|
|
|
|
|
|
statics: {
|
|
|
|
title: '<NavigatorIOS>',
|
|
|
|
description: 'iOS navigation capabilities',
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
var recurseTitle = 'Recurse Navigation';
|
|
|
|
if (!this.props.topExampleRoute) {
|
|
|
|
recurseTitle += ' - more examples here';
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<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.group}>
|
|
|
|
{this._renderRow(recurseTitle, () => {
|
|
|
|
this.props.navigator.push({
|
|
|
|
title: NavigatorIOSExample.title,
|
|
|
|
component: NavigatorIOSExample,
|
|
|
|
backButtonTitle: 'Custom Back',
|
|
|
|
passProps: {topExampleRoute: this.props.topExampleRoute || this.props.route},
|
|
|
|
});
|
|
|
|
})}
|
|
|
|
{this._renderRow('Push View Example', () => {
|
|
|
|
this.props.navigator.push({
|
|
|
|
title: 'Very Long Custom View Example Title',
|
2015-04-03 17:02:49 +00:00
|
|
|
component: createExamplePage(null, ViewExample),
|
2015-02-20 04:10:52 +00:00
|
|
|
});
|
|
|
|
})}
|
|
|
|
{this._renderRow('Custom Right Button', () => {
|
|
|
|
this.props.navigator.push({
|
|
|
|
title: NavigatorIOSExample.title,
|
|
|
|
component: EmptyPage,
|
|
|
|
rightButtonTitle: 'Cancel',
|
|
|
|
onRightButtonPress: () => this.props.navigator.pop(),
|
|
|
|
passProps: {
|
|
|
|
text: 'This page has a right button in the nav bar',
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})}
|
2015-05-07 14:16:59 +00:00
|
|
|
{this._renderRow('Custom Left & Right Icons', () => {
|
|
|
|
this.props.navigator.push({
|
|
|
|
title: NavigatorIOSExample.title,
|
|
|
|
component: EmptyPage,
|
|
|
|
leftButtonTitle: 'Custom Left',
|
|
|
|
onLeftButtonPress: () => this.props.navigator.pop(),
|
|
|
|
rightButtonIcon: require('image!NavBarButtonPlus'),
|
|
|
|
onRightButtonPress: () => {
|
|
|
|
AlertIOS.alert(
|
|
|
|
'Bar Button Action',
|
|
|
|
'Recognized a tap on the bar button icon',
|
|
|
|
[
|
|
|
|
{
|
|
|
|
text: 'OK',
|
|
|
|
onPress: () => console.log('Tapped OK'),
|
|
|
|
},
|
|
|
|
]
|
|
|
|
);
|
|
|
|
},
|
|
|
|
passProps: {
|
|
|
|
text: 'This page has an icon for the right button in the nav bar',
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})}
|
2015-02-20 04:10:52 +00:00
|
|
|
{this._renderRow('Pop', () => {
|
|
|
|
this.props.navigator.pop();
|
|
|
|
})}
|
|
|
|
{this._renderRow('Pop to top', () => {
|
|
|
|
this.props.navigator.popToTop();
|
|
|
|
})}
|
|
|
|
{this._renderRow('Replace here', () => {
|
|
|
|
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._renderReplacePreviousAndPop()}
|
|
|
|
{this._renderPopToTopNavExample()}
|
|
|
|
</View>
|
|
|
|
<View style={styles.line}/>
|
|
|
|
</ScrollView>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
_renderPopToTopNavExample: function() {
|
|
|
|
if (!this.props.topExampleRoute) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return this._renderRow('Pop to top NavigatorIOSExample', () => {
|
|
|
|
this.props.navigator.popToRoute(this.props.topExampleRoute);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_renderReplacePrevious: function() {
|
|
|
|
if (!this.props.topExampleRoute) {
|
|
|
|
// this is to avoid replacing the UIExplorerList at the top of the stack
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return this._renderRow('Replace previous', () => {
|
|
|
|
this.props.navigator.replacePrevious({
|
|
|
|
title: 'Replaced',
|
|
|
|
component: EmptyPage,
|
|
|
|
passProps: {
|
|
|
|
text: 'This is a replaced "previous" page',
|
|
|
|
},
|
|
|
|
wrapperStyle: styles.customWrapperStyle,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_renderReplacePreviousAndPop: function() {
|
|
|
|
if (!this.props.topExampleRoute) {
|
|
|
|
// this is to avoid replacing the UIExplorerList at the top of the stack
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return this._renderRow('Replace previous and pop', () => {
|
|
|
|
this.props.navigator.replacePreviousAndPop({
|
|
|
|
title: 'Replaced and Popped',
|
|
|
|
component: EmptyPage,
|
|
|
|
passProps: {
|
|
|
|
text: 'This is a replaced "previous" page',
|
|
|
|
},
|
|
|
|
wrapperStyle: styles.customWrapperStyle,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2015-03-23 18:36:57 +00:00
|
|
|
_renderRow: function(title: string, onPress: Function) {
|
2015-02-20 04:10:52 +00:00
|
|
|
return (
|
|
|
|
<View>
|
|
|
|
<TouchableHighlight onPress={onPress}>
|
|
|
|
<View style={styles.row}>
|
|
|
|
<Text style={styles.rowText}>
|
|
|
|
{title}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
</TouchableHighlight>
|
|
|
|
<View style={styles.separator} />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
customWrapperStyle: {
|
|
|
|
backgroundColor: '#bbdddd',
|
|
|
|
},
|
|
|
|
emptyPage: {
|
|
|
|
flex: 1,
|
|
|
|
paddingTop: 64,
|
|
|
|
},
|
|
|
|
emptyPageText: {
|
|
|
|
margin: 10,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
backgroundColor: '#eeeeee',
|
|
|
|
marginTop: 10,
|
|
|
|
},
|
|
|
|
group: {
|
|
|
|
backgroundColor: 'white',
|
|
|
|
},
|
|
|
|
groupSpace: {
|
|
|
|
height: 15,
|
|
|
|
},
|
|
|
|
line: {
|
|
|
|
backgroundColor: '#bbbbbb',
|
|
|
|
height: 1 / PixelRatio.get(),
|
|
|
|
},
|
|
|
|
row: {
|
|
|
|
backgroundColor: 'white',
|
|
|
|
justifyContent: 'center',
|
|
|
|
paddingHorizontal: 15,
|
|
|
|
paddingVertical: 15,
|
|
|
|
},
|
|
|
|
separator: {
|
|
|
|
height: 1 / PixelRatio.get(),
|
|
|
|
backgroundColor: '#bbbbbb',
|
|
|
|
marginLeft: 15,
|
|
|
|
},
|
|
|
|
rowNote: {
|
|
|
|
fontSize: 17,
|
|
|
|
},
|
|
|
|
rowText: {
|
|
|
|
fontSize: 17,
|
2015-03-25 23:22:59 +00:00
|
|
|
fontWeight: '500',
|
2015-02-20 04:10:52 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = NavigatorIOSExample;
|