-
-
Save sweatC/b2bd24fcd13227e3afdfa9e7a74e0571 to your computer and use it in GitHub Desktop.
Routing. App router component.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { StatusBar, Platform } from 'react-native'; | |
import { Router, Scene, Actions } from 'react-native-router-flux'; | |
import { connect } from 'react-redux'; | |
import { Text, TextInput } from 'react-native'; | |
import { getAccessToken } from './reducers/auth/authActions'; | |
import Welcome from './scenes/Welcome'; | |
import AllProducts from './scenes/AllProducts'; | |
import SignUp from './scenes/SignUp'; | |
import Login from './scenes/Login'; | |
import YourRentfiles from './scenes/YourRentfiles'; | |
import ProductShow from './scenes/ProductShow'; | |
import ProductBookCalendar from './scenes/ProductBookCalendar'; | |
import FilterCalendar from './scenes/FilterCalendar'; | |
import ProductWizardForm from './scenes/ProductWizardForm'; | |
import ProductEdit from './scenes/ProductEdit'; | |
import ProductBookSuccess from './scenes/ProductBookSuccess'; | |
import SpinnerModal from './components/SpinnerModal'; | |
import ProductThread from './scenes/ProductThread'; | |
import Inbox from './scenes/Inbox'; | |
import ProductAvailability from './scenes/ProductAvailability'; | |
import ViewDetails from './scenes/ViewDetails'; | |
import { statusBarColor } from './assets/styles/elements'; | |
class AppRouter extends Component { | |
constructor(props) { | |
super(props); | |
// Disallow dynamic type on iOS | |
Text.defaultProps.allowFontScaling = false; | |
TextInput.defaultProps.allowFontScaling = false; | |
} | |
componentDidMount() { | |
this.setStatusBarBackgroundColor(); | |
this.props.getAccessToken(); | |
} | |
setStatusBarBackgroundColor() { | |
if (Platform.OS == 'android') { | |
StatusBar.setBackgroundColor(statusBarColor.background); | |
} | |
} | |
onBackPress = () => { | |
return Actions.pop(); | |
}; | |
render() { | |
return ( | |
<Router backAndroidHandler={this.onBackPress}> | |
<Scene key="lightbox" lightbox> | |
<Scene key='root' hideNavBar> | |
<Scene key='Welcome' component={Welcome} initial /> | |
<Scene key='SignUp' component={SignUp} /> | |
<Scene key='Login' component={Login} /> | |
<Scene key='YourRentfiles' component={YourRentfiles} /> | |
<Scene key='AllProducts' component={AllProducts} /> | |
<Scene key='ProductShow' component={ProductShow} /> | |
<Scene key='ProductBookCalendar' component={ProductBookCalendar} /> | |
<Scene key='FilterCalendar' component={FilterCalendar} /> | |
<Scene key='ProductWizardForm' component={ProductWizardForm} /> | |
<Scene key='ProductEdit' component={ProductEdit} /> | |
<Scene key='ProductBookSuccess' component={ProductBookSuccess} /> | |
<Scene key='ProductThread' component={ProductThread} /> | |
<Scene key='Inbox' component={Inbox} /> | |
<Scene key='ProductAvailability' component={ProductAvailability} /> | |
<Scene key='ViewDetails' component={ViewDetails} /> | |
</Scene> | |
<Scene key='SpinnerModal' component={SpinnerModal} /> | |
</Scene> | |
</Router> | |
); | |
} | |
} | |
const mapDispatchToProps = dispatch => ({ | |
getAccessToken: () => dispatch(getAccessToken()) | |
}); | |
export default connect(undefined, mapDispatchToProps)(AppRouter); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment