-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
116 lines (104 loc) · 2.15 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
// @flow
import React, { PureComponent } from 'react';
import {
StatusBar,
StyleSheet,
Text,
View,
} from 'react-native';
import Tags from './src/components/Tags';
import NewTagModal from './src/components/NewTagModal';
const TAGS = [
'#love',
'#instagood',
'#photooftheday',
'#beautiful',
'#fashion',
'#happy',
'#tbt',
'#cute',
'#followme',
'#like4like',
'#follow',
'#followme',
'#picoftheday',
'#me',
'#selfie',
'#summer',
'#instadaily',
'#photooftheday',
'#friends',
'#girl',
'#fun',
'#style',
'#instalike',
'#food',
'#family',
'#tagsforlikes',
'#igers',
];
type State = {
modalVisible: boolean,
};
export default class Main extends PureComponent {
state: State = {
modalVisible: false,
};
// Reference Tags component
_tagsComponent: ?Tags;
openModal = (): void => {
this.setState({ modalVisible: true });
};
closeModal = (): void => {
this.setState({ modalVisible: false });
};
onSubmitNewTag = (tag: string) => {
this._tagsComponent && this._tagsComponent.onSubmitNewTag(tag);
};
render() {
const { modalVisible } = this.state;
return (
<View style={styles.container}>
<StatusBar hidden={true} />
<NewTagModal
visible={modalVisible}
onSubmit={this.onSubmitNewTag}
onClose={this.closeModal}
/>
<View style={styles.header}>
<Text style={[styles.text, styles.title]}>
Let's drag and drop some tags!
</Text>
<Text style={styles.text}>
Drag and drop tags to reorder, tap to remove or press Add New to add new tags.
</Text>
</View>
<Tags
ref={component => this._tagsComponent = component }
tags={TAGS}
onPressAddNewTag={this.openModal}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#2196F3',
},
header: {
marginHorizontal: 20,
marginVertical: 50,
},
title: {
fontSize: 22,
fontWeight: 'bold',
marginBottom: 10,
},
text: {
color: '#FFFFFF',
fontSize: 16,
textAlign: 'center',
},
});