-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
108 lines (95 loc) · 2.68 KB
/
App.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
97
98
99
100
101
102
103
104
105
106
107
108
// https://medium.com/reactnative/tabbing-through-input-fields-ef283f923ab1
import React, { Component } from 'react';
import { TextInput, Platform, StyleSheet, Text, View } from 'react-native';
type Props = {};
const LASTINPUT = "lastInput"
export default class App extends Component<Props> {
constructor(props) {
super(props);
this.focusNextField = this.focusNextField.bind(this);
this.inputs = {};
this.state={
value:""
}
}
focusNextField(id) {
this.inputs[id].focus();
}
onChange(event){
this.setState({value:9})
Object.values(event).map((item)=>{console.log(item)})
console.log("onChange",event.target)
console.log("ASDASD");
}
componentDidMount(){
this.focusNextField("one");
}
onKeyPress(event){
console.log("onKeyPress", Object.keys(event).toString())
console.log("ASDSA")
}
renderTextInput(params) {
return (
<View style={{ height: 80, width:80}}>
<TextInput
placeholder="*"
blurOnSubmit={false}
value={this.state.value}
onChangeText={(value) => {
// if(params.refereneKey !== LASTINPUT){
// this.focusNextField(params.nextField);
// }else{
// alert("handle submit Logic")
// }
this.setState({value: value})
}}
onChange={(e)=>{
this.onChange(e);
}}
maxLength={20}
returnKeyType={"next"}
style={styles.textInput}
ref={input => {
if(params.refereneKey){
this.inputs[params.refereneKey] = input;
}
}}
/>
<View style={{alignSelf:'center', width:40, height:1, backgroundColor:"black"}}/>
</View>)
}
render() {
return (
<View style={{width:300, height:300}}>
<TextInput
placeholder="dummy"
blurOnSubmit={false}
value={this.state.value}
style={{width:200, height:40}}
/>
<View style={styles.outerContainer}>
{this.renderTextInput({nextField:"two", refereneKey:"one",})}
{this.renderTextInput({nextField:"three", refereneKey:"two"})}
{this.renderTextInput({nextField:"LASTINPUT", refereneKey:"three"})}
{this.renderTextInput({nextField:"", refereneKey:"LASTINPUT"})}
</View>
</View>
);
};
}
const styles = StyleSheet.create({
outerContainer: {
flex: 1,
paddingTop: 60,
alignItems: 'center',
flexDirection: 'row',
},
textInput: {
// alignSelf: 'stretch',
// borderRadius: 5,
// borderWidth: 1,
height: 0,
paddingHorizontal: 10,
marginHorizontal: 20,
},
});