Skip to content

Commit 421f17f

Browse files
committed
Managed documentation and add native code for Android!
1 parent b5d7aab commit 421f17f

File tree

4 files changed

+38
-15
lines changed

4 files changed

+38
-15
lines changed

README.md

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# react-native-hide-keyboard
22

3-
A React Native hide keyboard module is for hiding and showing the keyboard without blurring the textInput component.
3+
A React Native hide keyboard module is for hiding and showing the keyboard without blurring TextInput component.
44

55
## Installation
66

@@ -11,11 +11,19 @@ npm install react-native-hide-keyboard
1111
## Usage
1212

1313
```js
14-
import { multiply } from "react-native-hide-keyboard";
15-
16-
// ...
17-
18-
const result = await multiply(3, 7);
14+
import { hideKeyboard, showKeyboard } from "react-native-hide-keyboard";
15+
16+
// For hiding Keyboard
17+
const isItHide = await hideKeyboard();
18+
if (isItHide) {
19+
// Here Keyboard is hide without blurring textInput
20+
}
21+
22+
// For showing keyboard
23+
const isItShow = await showKeyboard();
24+
if (isItShow) {
25+
// Here keyboard is active/displayed
26+
}
1927
```
2028

2129
## Contributing

android/src/main/java/com/reactnativehidekeyboard/HideKeyboardModule.java

+11
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,15 @@ public void hideKeyboard(Promise promise){
4242
promise.resolve(false);
4343
}
4444
}
45+
46+
@ReactMethod
47+
public void showKeyboard(Promise promise){
48+
try {
49+
InputMethodManager show = (InputMethodManager) contexts.getSystemService(Activity.INPUT_METHOD_SERVICE);
50+
show.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
51+
promise.resolve(true);
52+
} catch(Exception e){
53+
promise.resolve(false);
54+
}
55+
}
4556
}

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-hide-keyboard",
3-
"version": "0.1.0",
4-
"description": "A React Native hide keyboard module is for hiding and showing the keyboard without blurring the textInput component",
3+
"version": "0.1.1",
4+
"description": "A React Native hide keyboard module is for hiding and showing the keyboard without blurring TextInput component.",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",
77
"types": "lib/typescript/index.d.ts",

src/index.tsx

+11-7
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ const LINKING_ERROR =
99
const HideKeyboard = NativeModules.HideKeyboard
1010
? NativeModules.HideKeyboard
1111
: new Proxy(
12-
{},
13-
{
14-
get() {
15-
throw new Error(LINKING_ERROR);
16-
},
17-
}
18-
);
12+
{},
13+
{
14+
get() {
15+
throw new Error(LINKING_ERROR);
16+
},
17+
}
18+
);
1919

2020
export function hideKeyboard(): Promise<boolean> {
2121
return HideKeyboard.hideKeyboard();
2222
}
23+
24+
export function showKeyboard(): Promise<boolean> {
25+
return HideKeyboard.showKeyboard();
26+
}

0 commit comments

Comments
 (0)