-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
155 lines (135 loc) · 3.69 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import React, { Component } from 'react';
import {
View,
StyleSheet,
StatusBar,
TouchableOpacity,
AsyncStorage
} from 'react-native';
// import Header from './src/components/header';
// import Footer from './src/components/footer';
import Bar from './src/components/bar';
import IdCard from './src/components/idCard';
import ContactCard from './src/components/contactCard';
import Scan from './src/components/scan';
import ContactForm from './src/components/contactForm';
import IdCardForm from './src/components/idCardForm';
import Settings from './src/components/settings';
import { Pages } from 'react-native-pages';
import { createStackNavigator } from 'react-navigation';
class App extends Component {
static navigationOptions = { header: null };
constructor(props) {
super(props);
}
data = {
title: String,
subtitle: String,
firstName: String,
lastName: String,
company: String,
phone: String,
fax: String,
email: String,
}
openScanViewController = () => {
this.props.navigation.navigate('Scan')
}
openFirstContactBlankViewController = () => {
this.props.navigation.navigate('ContactForm', { card: 'firstProfile'})
}
openSecondContactBlankViewController = () => {
this.props.navigation.navigate('ContactForm', { card: 'secondProfile'})
}
openIdCardBlankViewController = () => {
this.props.navigation.navigate('IdCardForm')
}
openSettingsViewController = () => {
this.props.navigation.navigate('Settings')
}
async profilesData(profile) {
try {
let objects = await AsyncStorage.getItem(profile);
let parsed = JSON.parse(objects);
newData = {
title: parsed.title,
subtitle: parsed.subtitle,
firstName: parsed.firstName,
lastName: parsed.lastName,
company: parsed.company,
phone: parsed.phone,
fax: parsed.fax,
email: parsed.email
}
return objects
} catch (error) {
console.log("Error retrieving data" + error);
}
}
componentWillMount() {
console.log(this.profilesData('firstProfile'))
}
render() {
return (
<View style={[StyleSheet.absoluteFill, styles.container]}>
<StatusBar
barStyle="light-content"
/>
<Pages
indicatorPosition={'top'}
containerStyle={styles.cards}
onScrollEnd={() => console.log('Hello!')}>
<IdCard
setBlank={this.openIdCardBlankViewController}/>
{/* setBlank={() => this.openIdCardBlankViewController}/> */}
<ContactCard
setBlank={this.openFirstContactBlankViewController}
card={'firstProfile'}
// title={this.profilesData('firstProfile').title}
subtitle={'Description'}
data={this.profilesData('firstProfile')}/>
<ContactCard
setBlank={this.openSecondContactBlankViewController}
card={'secondProfile'}
title={'Profile'}
subtitle={'Description'}
data={this.profilesData('secondProfile')}/>
</Pages>
<Bar
toScan={this.openScanViewController}
toSettings={this.openSettingsViewController}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
backgroundColor: 'black'
},
cards: {
flexDirection: 'column',
justifyContent: 'flex-start',
backgroundColor: '#000000',
marginTop: 88,
},
})
export default createStackNavigator({
Home: {
screen: App,
},
Scan: {
screen: Scan,
},
ContactForm: {
screen: ContactForm,
},
IdCardForm: {
screen: IdCardForm,
},
Settings: {
screen: Settings,
}
}, {
mode: 'modal'
});