-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
46 lines (40 loc) · 1.33 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React, { Component } from 'react'
import { StyleSheet, Button, View, TouchableOpacity, Text } from 'react-native'
import Driver from './screens/Driver'
import Passenger from './screens/Passenger'
import Login from './screens/Login'
import GenericContainer from './components/GenericContainer'
import DriverOrPassenger from './screens/DriverOrPassenger'
import SignUp from './screens/SignUp'
const DriverWithGenericContainer = GenericContainer(Driver)
const PassengerWithGenericContainer = GenericContainer(Passenger)
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
isDriver: false,
isPassenger: false,
token: '',
createAccount: false
}
this.handleChange = this.handleChange.bind(this)
}
handleChange(name, value) {
this.setState({ [name]: value })
}
render() {
if (this.state.createAccount) {
return <SignUp handleChange={this.handleChange} />
}
if (this.state.token === '') {
return <Login handleChange={this.handleChange} />
}
if (this.state.isDriver) {
return <DriverWithGenericContainer token={this.state.token} />
}
if (this.state.isPassenger) {
return <PassengerWithGenericContainer token={this.state.token} />
}
return <DriverOrPassenger handleChange={this.handleChange} />
}
}