-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask-form.js
More file actions
93 lines (84 loc) · 2.22 KB
/
task-form.js
File metadata and controls
93 lines (84 loc) · 2.22 KB
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
import React, { Component } from 'react';
import { View, TouchableHighlight, Text, TextInput, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'flex-start',
paddingTop: 150,
backgroundColor: '#F7F7F7',
},
input: {
borderWidth: 1,
borderColor: '#D7D7D7',
height: 50,
marginLeft: 10,
marginRight: 10,
padding: 15,
borderRadius: 3,
},
buttonText: {
fontSize: 18,
fontWeight: '600',
color: '#FAFAFA',
},
button: {
height: 45,
alignSelf: 'stretch',
backgroundColor: '#05A5D1',
marginTop: 10,
marginLeft: 10,
marginRight: 10,
alignItems: 'center',
justifyContent: 'center',
borderRadius: 10,
},
cancelButton: {
backgroundColor: '#666',
}
})
class TaskForm extends Component {
constructor(props, context) {
super(props, context);
}
onChange(text) {
this.task = text;
}
onAddPressed() {
this.props.onAdd(this.task);
}
render() {
return (
<View style={styles.container}>
<TextInput
onChangeText={this.onChange.bind(this)}
style={styles.input}
/>
<TouchableHighlight
onPress={this.onAddPressed.bind(this)}
style={styles.button}
>
<Text
style={styles.buttonText}
>
Add
</Text>
</TouchableHighlight>
<TouchableHighlight
onPress={this.props.onCancel}
style={[styles.button, styles.cancelButton]}
>
<Text
style={styles.buttonText}
>
Cancel
</Text>
</TouchableHighlight>
</View>
);
}
}
TaskForm.propTypes = {
onAdd: React.PropTypes.func.isRequired,
onCancel: React.PropTypes.func.isRequired,
};
export default TaskForm;