This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
Sphere/app/components/app.js

66 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-02-01 20:58:00 +00:00
import React from 'react-native';
import RouteMaster from './routes/RouteMaster';
2016-02-06 15:07:29 +00:00
import RouteMapper from './navigation/RouteMapper';
2016-02-06 15:49:57 +00:00
import GlobalStyles from '../settings/styles';
2016-02-21 12:05:14 +00:00
import BusyIndicator from 'react-native-busy-indicator';
2016-02-01 20:58:00 +00:00
const {
Navigator,
2016-02-06 15:07:29 +00:00
StyleSheet,
Platform,
View
2016-02-01 20:58:00 +00:00
} = React;
2016-02-06 15:07:29 +00:00
const styles = StyleSheet.create({
navbar: {
2016-02-06 15:49:57 +00:00
backgroundColor: GlobalStyles.get('CIRCLE_NAVBAR_BG'),
2016-02-06 15:07:29 +00:00
flexDirection:'row',
justifyContent: 'center',
},
container: {
flex: 1,
marginTop: (Platform.OS === 'ios' ? 64 : 56)
}
});
2016-02-01 20:58:00 +00:00
export default class extends React.Component {
renderScene(route, nav) {
2016-02-06 15:07:29 +00:00
const Component = route.component;
2016-02-01 20:58:00 +00:00
const props = route.props || {};
2016-02-06 15:07:29 +00:00
return (
<View style={styles.container}>
<Component
nav={nav}
currentRoute={props.route}
{...props} />
2016-02-21 12:05:14 +00:00
<BusyIndicator />
2016-02-06 15:07:29 +00:00
</View>
);
2016-02-01 20:58:00 +00:00
}
2016-02-01 21:50:50 +00:00
componentWillMount() {
2016-02-01 20:58:00 +00:00
this.initialRoute = RouteMaster.get('LOGIN');
}
render() {
return (
<Navigator
renderScene={this.renderScene}
initialRoute={this.initialRoute}
2016-02-06 15:07:29 +00:00
navigationBar={
<Navigator.NavigationBar
style={styles.navbar}
routeMapper={RouteMapper} />
}
2016-02-01 20:58:00 +00:00
configureScene={(route) => {
if (route.sceneConfig) {
return route.sceneConfig;
}
return Navigator.SceneConfigs.PushFromRight;
}}
/>
);
}
};