-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
83 lines (68 loc) · 2.11 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
import React, { Component } from 'react';
import {StyleSheet, Image, View} from 'react-native'
import { Container, Title, Content, FooterTab, Footer, Button, Left, Right, Body, Icon, Text } from 'native-base';
import { Col, Row, Grid } from 'react-native-easy-grid';
import Header from './components/Header';
import Main from './components/Main'
import OnTap from './components/OnTap'
import Contact from './components/Contact'
import KegList from './components/KegList'
import Expo from 'expo';
const brewsURL = 'https://raspberry-pint-api.herokuapp.com'
export default class App extends Component {
constructor() {
super()
this.state = {
index: 0,
beers: [],
};
}
switchScreen(index){
this.setState({ index: index })
}
async componentDidMount() {
const beerResponse = await fetch(`${brewsURL}/beers`)
const beerJSON = await beerResponse.json()
this.setState({beers: beerJSON})
Expo.Font.loadAsync({
'Roboto_medium': require('./assets/fonts/Roboto_medium.ttf'),
});
}
render() {
let AppComponent = 0;
if (this.state.index == 0) {
AppComponent = <Main />
} else if (this.state.index == 1) {
AppComponent = <OnTap beers={this.state.beers}/>
} else if (this.state.index == 2) {
AppComponent = <Contact />
}
return (
<Container style={styles.container}>
<Header />
{AppComponent}
<Footer>
<FooterTab>
<Button vertical onPress={() => this.switchScreen(0) }>
<Icon name="ios-home" />
<Text>Home</Text>
</Button>
<Button vertical onPress={() => this.switchScreen(1) }>
<Icon name="ios-beer" />
<Text>My Keg(s)</Text>
</Button>
<Button vertical onPress={() => this.switchScreen(2) }>
<Icon active name="ios-contact" />
<Text>Info</Text>
</Button>
</FooterTab>
</Footer>
</Container>
);
}
}
const styles = StyleSheet.create({
container: {
backgroundColor: '#d4ab1d'
},
});