Skip to content

Commit 75e3755

Browse files
committed
Sample enable/disable option
1 parent d33d2b3 commit 75e3755

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

Sample/index.ios.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import {
2929
Text,
3030
View,
3131
TextInput,
32-
ScrollView
32+
ScrollView,
33+
Switch
3334
} from 'react-native';
3435

3536
import KeyboardManager from 'react-native-keyboard-manager'
@@ -46,7 +47,9 @@ KeyboardManager.setShouldResignOnTouchOutside(true);
4647

4748
class SampleKeyboardManager extends Component {
4849

49-
state = {};
50+
state = {
51+
enableDisable: true
52+
};
5053

5154
componentDidMount() {
5255
KeyboardManager.resignFirstResponder();
@@ -59,14 +62,21 @@ class SampleKeyboardManager extends Component {
5962
})
6063
}
6164

65+
enableDisable(value) {
66+
KeyboardManager.setEnable(value);
67+
this.setState({
68+
enableDisable: value
69+
})
70+
}
71+
6272
render() {
6373
const self = this;
6474

6575
var inputs = [];
6676

6777
const inputStyle = { height: 40, borderColor: "#000000", borderWidth: 1, borderRadius: 2, paddingLeft: 5 };
6878

69-
for (let i = 0; i < 12; i++) {
79+
for (let i = 0; i < 7; i++) {
7080
let ref = "input" + i;
7181
let nextRef = "input" + (i + 1);
7282
let nextFocus = () => { self.refs[nextRef] ? self.refs[nextRef].focus() : null };
@@ -92,13 +102,19 @@ class SampleKeyboardManager extends Component {
92102
}
93103

94104
return (
95-
<ScrollView style={{ flex: 1 }}>
96-
97-
<Text style={{ marginTop: 50, textAlign: "center" }}>React-Native Keyboard Manager</Text>
98-
99-
{inputs}
100-
101-
</ScrollView>
105+
<View style={{ flex: 1 }}>
106+
<View style={{ alignItems: "center", flex: 1 }}>
107+
<Text style={{ marginTop: 50, textAlign: "center" }}>React-Native Keyboard Manager</Text>
108+
<View style={{ marginTop: 10, flexDirection: "row", alignItems: "center" }}>
109+
<Text>Enable/Disable </Text>
110+
<Switch onValueChange={this.enableDisable.bind(this)}
111+
value={this.state.enableDisable} />
112+
</View>
113+
</View>
114+
<View>
115+
{inputs}
116+
</View>
117+
</View>
102118
)
103119
}
104120
}

screenshots/01.png

-28.4 KB
Loading

screenshots/02.png

-3.07 KB
Loading

screenshots/03.png

12.3 KB
Loading

0 commit comments

Comments
 (0)