This repository was archived by the owner on Nov 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathGetEventName.js
More file actions
70 lines (61 loc) · 1.42 KB
/
GetEventName.js
File metadata and controls
70 lines (61 loc) · 1.42 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
import React, { Component, PropTypes } from "react";
import { View, StyleSheet } from "react-native";
import t from "tcomb-form-native";
import newEventFormStylesheet from "../config/newEventFormStylesheet";
const Form = t.form.Form;
const nameRefined = t.refinement(
t.String,
string => string.length > 0 && string.length < 45
);
const Name = t.struct({
name: nameRefined
});
const NameOptions = {
fields: {
name: {
label: "Event Name",
underlineColorAndroid: "transparent",
placeholder: "Insert name here",
stylesheet: newEventFormStylesheet,
error: "Name should be an appropriate length."
}
}
};
export default class GetEventName extends Component {
static propTypes = {
value: PropTypes.any,
onChange: PropTypes.func
};
isValid = () => {
return this.name.validate().isValid();
};
componentDidMount() {
this.name.validate();
}
render() {
return (
<View style={styles.container}>
<Form
{...this.props}
type={Name}
ref={r => {
this.name = r;
}}
value={this.props.value}
onChange={name => {
this.props.onChange(name);
this.name.validate();
}}
options={NameOptions}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center"
}
});