/
AddProject.js
56 lines (45 loc) · 1.43 KB
/
AddProject.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
import React from 'react';
import { connect } from 'react-redux';
import * as actions from './actions/actions';
import { View, Text } from 'react-native';
import NavigationBar from 'react-native-navbar';
import { FormLabel, FormInput, Button } from 'react-native-elements';
class AddProject extends React.Component {
handleHome = () => {
const { navigator } = this.props;
navigator.pop();
};
handleSubmit = () => {
const { startAddProject, navigator } = this.props;
const { title, url } = this;
const project = {
title, url
};
startAddProject(project).then(() => {
navigator.pop();
});
}
render() {
return (
<View style={{backgroundColor: '#FFF'}}>
<NavigationBar containerStyle={{ backgroundColor: '#EEE' }}
title={{ title: 'Add project' }}
leftButton={ {title: 'Back', handler: this.handleHome } }
/>
<View style={{ marginBottom: 25 }}>
<FormLabel>Project name</FormLabel>
<FormInput onChangeText={(title) => {this.title = title}}/>
<FormLabel>Project URL</FormLabel>
<FormInput onChangeText={(url) => {this.url = url}}/>
</View>
<Button
title='Create project'
onPress={ this.handleSubmit }
backgroundColor='green'
butonStyle={{ marginTop: 15 }}
/>
</View>
)
}
}
export default connect((state) => state, actions)(AddProject);