-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
80 lines (62 loc) · 1.48 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
import React, { Component } from 'react';
import { FlatList, SafeAreaView, StyleSheet } from 'react-native';
import Conv from './components/conversion'
import Measure from './components/measure'
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
var convert = require('convert-units')
class Home extends Component {
static navigationOptions = {
title: 'Converter',
headerStyle: {
backgroundColor: '#f4511e',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
};
constructor(props) {
super(props);
this.state = {
loading: false,
conversions: [],
}
}
componentDidMount() {
this.makeDataRequest();
}
makeDataRequest = () => {
this.setState({ loading: true });
const data = convert().measures()
this.setState({
loading: false,
conversions: data
});
}
render() {
return (
<SafeAreaView style={styles.container}>
<FlatList
data={this.state.conversions}
renderItem={({ item }) => <Conv title={item} />}
keyExtractor={item => item}
/>
</SafeAreaView>
);
}
}
const AppNavigator = createStackNavigator({
Home: { screen: Home },
Measure:{screen:Measure},
},
{
initialRouteName: 'Home',
});
const App = createAppContainer(AppNavigator);
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
},
});