forked from cloudipsp/react-native-cloudipsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard-input.js
96 lines (89 loc) · 2.98 KB
/
card-input.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
import React from 'react';
import {
View,
Text
} from 'react-native';
import CardLayout from './card-layout';
import CardInputNumber from './card-field-number';
import CardInputExpMm from './card-field-exp-mm';
import CardInputExpYy from './card-field-exp-yy';
import CardInputCvv from './card-field-cvv';
export class CardInput extends React.Component {
constructor(props) {
super(props);
}
getCard = () => {
return this.cardLayout.getCard();
}
showCard = (card) => {
this.cardLayout.showCard(card);
}
test = () => {
this.cardLayout.test();
}
focus = () => {
this.inputNumber.focus();
}
render() {
return (
<CardLayout
ref={(ref) => {
this.cardLayout = ref
}}
inputNumber={() => this.inputNumber}
inputExpMm={() => this.inputMm}
inputExpYy={() => this.inputYy}
inputCvv={() => this.inputCvv}
>
<Text
style={this.props.textStyle}
onPress={this.props.debug ? this.test : undefined}>
Card Number:
</Text>
<CardInputNumber
ref={(ref) => {
this.inputNumber = ref
}}
onSubmitEditing={() => {
this.inputMm.focus();
}}
style={this.props.textInputStyle}
/>
<Text style={this.props.textStyle}>Expiry:</Text>
<View style={{flexDirection: 'row'}}>
<CardInputExpMm
ref={(ref) => {
this.inputMm = ref
}}
placeholder='MM'
onSubmitEditing={() => {
this.inputYy.focus();
}}
style={[{flex: 1}, this.props.textInputStyle]}
/>
<CardInputExpYy
ref={(ref) => {
this.inputYy = ref
}}
placeholder='YY'
onSubmitEditing={() => {
this.inputCvv.focus();
}}
style={[{flex: 1}, this.props.textInputStyle]}/>
</View>
<Text style={this.props.textStyle}>CVV:</Text>
<CardInputCvv
ref={(ref) => {
this.inputCvv = ref
}}
onSubmitEditing={() => {
if (this.props.onCompletion != undefined) {
this.props.onCompletion(this);
}
}}
style={this.props.textInputStyle}
/>
</CardLayout>
);
}
}