-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
99 lines (79 loc) · 2.93 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import React from 'react'
import {
Navigator,
Platform,
View,
ToolbarAndroid,
Text,
} from 'react-native'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import store from './src/store'
import * as actionCreators from './src/actions/actionCreators'
import APIClient from './src/utils/APIClient'
import HomeScene from './src/components/Home'
import BaseView from './src/components/BaseView'
import ListOfCocktails from './src/components/ListOfCocktails'
import CocktailDetail from './src/components/CocktailDetail'
import NavigationBarRouter from './src/components/NavigationBarRouter'
// class Main extends React.Component {
class App extends React.Component {
// componentDidMount() {
// let client = new APIClient()
// ingredients_request_data = '{allSpirits{edges{node{id,name,slug}}},allMixers{edges{node{id,name,slug}}}}'
// console.log(ingredients_request_data)
// client.get('', ingredients_request_data)
// .then(json => console.log(json))
// .catch(error => console.error(error))
// }
render() {
return (
<Navigator
style={{flex: 1}}
initialRoute={{name: 'home'}}
configureScene={(route) => Navigator.SceneConfigs.FloatFromRight}
renderScene={this._routeMapper}
navigationBar={Platform.OS === 'ios' ? <Navigator.NavigationBar routeMapper={NavigationBarRouter} /> : null}
/>
)
}
_getToolbar(navigator, showBackIcon, title) {
if (Platform.OS === 'ios') {
return null
}
return (
<ToolbarAndroid
title={title}
navIcon={showBackIcon ? require('./src/imgs/back_android.png') : null}
onIconClicked={() => navigator.pop()}
titleColor='white'
/>
)
}
_routeMapper(route, navigator) {
_navigator = navigator
let defaultProps = {navigator: _navigator}
if (route.name === 'home') {
return <HomeScene {...defaultProps} toolbar={() => this._getToolbar(navigator, false, 'Mixees')} />
} else if (['search', 'mixer', 'favorites'].indexOf(route.name) != -1) {
return <BaseView {...defaultProps} {...this.props} toolbar={() => this._getToolbar(navigator, true, 'Test')} selectedTab={route.name}/>
} else if (route.name === 'favorites') {
return <ListOfCocktails {...defaultProps} toolbar={() => this._getToolbar(navigator, true, 'Cocktails')} />
} else if (route.name === 'detail') {
return <CocktailDetail {...defaultProps} wikiURL={route.wikiURL} toolbar={() => this._getToolbar(navigator, true, route.cocktailName)}/>
}
return null
}
}
// function mapStateToProps(state) {
// return {
// ingredients: state.ingredients,
// cocktails: state.cocktails,
// selected_ingredients: state.selected_ingredients
// }
// }
// function mapDispatchToProps(dispatch) {
// return bindActionCreators(actionCreators, dispatch)
// }
// const App = connect(mapStateToProps, mapDispatchToProps)(Main)
export default App