File tree 4 files changed +38
-15
lines changed
android/src/main/java/com/reactnativehidekeyboard
4 files changed +38
-15
lines changed Original file line number Diff line number Diff line change 1
1
# react-native-hide-keyboard
2
2
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.
4
4
5
5
## Installation
6
6
@@ -11,11 +11,19 @@ npm install react-native-hide-keyboard
11
11
## Usage
12
12
13
13
``` 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
+ }
19
27
```
20
28
21
29
## Contributing
Original file line number Diff line number Diff line change @@ -42,4 +42,15 @@ public void hideKeyboard(Promise promise){
42
42
promise .resolve (false );
43
43
}
44
44
}
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
+ }
45
56
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"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. " ,
5
5
"main" : " lib/commonjs/index" ,
6
6
"module" : " lib/module/index" ,
7
7
"types" : " lib/typescript/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -9,14 +9,18 @@ const LINKING_ERROR =
9
9
const HideKeyboard = NativeModules . HideKeyboard
10
10
? NativeModules . HideKeyboard
11
11
: 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
+ ) ;
19
19
20
20
export function hideKeyboard ( ) : Promise < boolean > {
21
21
return HideKeyboard . hideKeyboard ( ) ;
22
22
}
23
+
24
+ export function showKeyboard ( ) : Promise < boolean > {
25
+ return HideKeyboard . showKeyboard ( ) ;
26
+ }
You can’t perform that action at this time.
0 commit comments