Skip to content

Instantly share code, notes, and snippets.

@timolins
Created February 1, 2016 10:59
Show Gist options
  • Save timolins/4c20dab87fc2eedf473f to your computer and use it in GitHub Desktop.
Save timolins/4c20dab87fc2eedf473f to your computer and use it in GitHub Desktop.
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
import React, {
AppRegistry,
Navigator,
TouchableHighlight,
View,
Text,
} from 'react-native';
const styles = {
wrapper: {
backgroundColor: '#161616',
},
};
class Main extends React.Component {
constructor(props) {
super(props);
}
_goToAccount = () => {
this.props.navigator.push({
id: 'demo',
sceneConfig: Navigator.SceneConfigs.FloatFromLeft,
});
};
render() {
return (
<View style={styles.wrapper}>
<TouchableHighlight onPress={this._goToAccount} style={{ padding: 20, backgroundColor: '#FFFFFF', flex: 1 }}>
<Text>Main</Text>
</TouchableHighlight>
</View>
);
}
}
class Demo extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<View style={{ padding: 20, backgroundColor: '#FFFFFF', flex: 1 }}>
<Text>Demo</Text>
</View>
);
}
}
class NavigatorWarning extends React.Component {
constructor(props) {
super(props);
}
_renderScene(route, nav) {
switch (route.id) {
case 'demo':
return <Demo navigator={nav} />;
default:
return <Main navigator={nav} />;
}
}
_configureScene(route) {
return route.sceneConfig || Navigator.SceneConfigs.FloatFromBottom;
}
render() {
return (
<Navigator
style={styles.wrapper}
initialRoute={{ type: 'right' }}
configureScene={this._configureScene}
renderScene={this._renderScene}
/>
);
}
}
AppRegistry.registerComponent('NavigatorWarning', () => NavigatorWarning);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment