-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
79 lines (73 loc) · 2.6 KB
/
index.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
/**
Author Name : WeblineIndia | https://www.weblineindia.com/
For more such software development components and code libraries, visit us at
https://www.weblineindia.com/software-development-resources.html
Our Github URL : https://github.com/weblineindia
**/
import React, { Component } from 'react';
import { TextInput, Alert } from 'react-native';
import Validation from './Validation';
class InputClass extends Component {
onChangeText = (value) => {
if (value.trim().length > 0) {
if (this.props.type === 'Text') {
if (Validation.onChangePlainTextCharacter(value)) {
this.props.onChangeText && this.props.onChangeText(value);
}
} else if (this.props.type === 'Number') {
if (Validation.onChangeNumberValidate(value)) {
this.props.onChangeText && this.props.onChangeText(value);
}
} else if (this.props.type === 'FreeContent') {
if (Validation.onChangeFreeTextValidate(value)) {
this.props.onChangeText && this.props.onChangeText(value);
}
} else if (this.props.type === 'Email') {
if (Validation.onChangeEmailValidate(value)) {
this.props.onChangeText && this.props.onChangeText(value);
}
} else if (this.props.type === 'PhoneNumber') {
if (Validation.onChangePhoneNumberValidate(value)) {
this.props.onChangeText && this.props.onChangeText(value);
}
}
} else {
this.props.onChangeText && this.props.onChangeText(value);
}
};
onEndEditing = (e) => {
if (e.nativeEvent.text.trim().length > 0) {
if (this.props.type === 'Text') {
} else if (this.props.type === 'Number') {
} else if (this.props.type === 'FreeContent') {
} else if (this.props.type === 'Email') {
if (!Validation.isValidEmail(e.nativeEvent.text)) {
if(this.props.onEndError) {
this.props.onEndError(true)
}
}
} else if (this.props.type === 'PhoneNumber') {
}
}
}
render() {
const {
placeholder, secure, autoCapitalize, keyboardType, value, placeholderTextColor, style,
} = this.props;
return (
<TextInput
placeholder={placeholder}
value={value}
secureTextEntry={secure}
autoCapitalize={autoCapitalize}
onChangeText={(text) => this.onChangeText(text)}
onEndEditing={(e) => this.onEndEditing(e)}
style={style}
placeholderTextColor={placeholderTextColor}
keyboardType={keyboardType}
maxLength={this.props.maxLength ? this.props.maxLength : 24}
/>
);
}
}
export default InputClass;