Skip to content

Commit aac02f6

Browse files
committed
Reverted Back!
1 parent fbfcebe commit aac02f6

File tree

4 files changed

+25
-64
lines changed

4 files changed

+25
-64
lines changed

README.md

+6-14
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 TextInput component.
3+
A React Native hide keyboard module is for hiding and showing the keyboard without blurring the textInput component
44

55
## Installation
66

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

1313
```js
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-
}
14+
import { multiply } from "react-native-hide-keyboard";
15+
16+
// ...
17+
18+
const result = await multiply(3, 7);
2719
```
2820

2921
## Contributing
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.reactnativehidekeyboard;
22

3-
import android.app.Activity;
4-
import android.view.inputmethod.InputMethodManager;
5-
63
import androidx.annotation.NonNull;
74

85
import com.facebook.react.bridge.Promise;
@@ -14,11 +11,9 @@
1411
@ReactModule(name = HideKeyboardModule.NAME)
1512
public class HideKeyboardModule extends ReactContextBaseJavaModule {
1613
public static final String NAME = "HideKeyboard";
17-
ReactApplicationContext contexts;
1814

1915
public HideKeyboardModule(ReactApplicationContext reactContext) {
20-
super(reactContext);
21-
contexts = reactContext;
16+
super(reactContext);
2217
}
2318

2419
@Override
@@ -27,30 +22,13 @@ public String getName() {
2722
return NAME;
2823
}
2924

30-
@ReactMethod
31-
public void hideKeyboard(Promise promise){
32-
try {
33-
InputMethodManager inputMethodManager = (InputMethodManager) contexts.getSystemService(Activity.INPUT_METHOD_SERVICE);
34-
if(inputMethodManager.isAcceptingText()){
35-
inputMethodManager.hideSoftInputFromWindow(
36-
getCurrentActivity().getCurrentFocus().getWindowToken(),
37-
0
38-
);
39-
}
40-
promise.resolve(true);
41-
} catch (Exception e){
42-
promise.resolve(false);
43-
}
44-
}
4525

26+
// Example method
27+
// See https://reactnative.dev/docs/native-modules-android
4628
@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-
}
29+
public void multiply(int a, int b, Promise promise) {
30+
promise.resolve(a * b);
5531
}
32+
33+
public static native int nativeMultiply(int a, int b);
5634
}

package.json

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-hide-keyboard",
3-
"version": "0.1.2",
4-
"description": "A React Native hide keyboard module is for hiding and showing the keyboard without blurring TextInput component.",
3+
"version": "0.1.4",
4+
"description": "A React Native hide keyboard module is for hiding and showing the keyboard without blurring the textInput component",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",
77
"types": "lib/typescript/index.d.ts",
@@ -34,12 +34,7 @@
3434
"keywords": [
3535
"react-native",
3636
"ios",
37-
"android",
38-
"react native hide keyboard",
39-
"react-native-hide-keyboard",
40-
"hide keyboard",
41-
"show keyboard",
42-
"react native keyboard"
37+
"android"
4338
],
4439
"repository": "https://github.com/MuhammadRafeh/react-native-hide-keyboard",
4540
"author": "Muhammad Rafeh <[email protected]> (https://github.com/MuhammadRafeh)",

src/index.tsx

+9-13
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@ 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

20-
export function hideKeyboard(): Promise<boolean> {
21-
return HideKeyboard.hideKeyboard();
22-
}
23-
24-
export function showKeyboard(): Promise<boolean> {
25-
return HideKeyboard.showKeyboard();
20+
export function multiply(a: number, b: number): Promise<number> {
21+
return HideKeyboard.multiply(a, b);
2622
}

0 commit comments

Comments
 (0)