Skip to content

Commit dfa89f5

Browse files
committed
fix: changes after self review (actually working code)
1 parent 8eda19e commit dfa89f5

13 files changed

Lines changed: 33 additions & 10 deletions

File tree

android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ class KeyboardControllerModule(
1111

1212
override fun getName(): String = KeyboardControllerModuleImpl.NAME
1313

14-
override fun getConstants(): MutableMap<String, Any> = mutableMapOf("keyboardBorderRadius" to 0)
14+
override fun getTypedExportedConstants(): Map<String, Any> {
15+
return module.getConstants()
16+
}
1517

1618
override fun setInputMode(mode: Double) {
1719
module.setInputMode(mode.toInt())

android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class KeyboardControllerModuleImpl(
2323
private val controller = KeyboardAnimationController()
2424
private val mDefaultMode: Int = getCurrentMode()
2525

26+
// region Module methods
2627
fun setInputMode(mode: Int) {
2728
setSoftInputMode(mode)
2829
}
@@ -102,7 +103,9 @@ class KeyboardControllerModuleImpl(
102103
promise.resolve(map)
103104
}
104105
}
106+
// endregion
105107

108+
// region Helpers
106109
private fun setSoftInputMode(mode: Int) {
107110
UiThreadUtil.runOnUiThread {
108111
if (getCurrentMode() != mode) {
@@ -118,8 +121,13 @@ class KeyboardControllerModuleImpl(
118121
?.attributes
119122
?.softInputMode
120123
?: WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED
124+
// endregion
125+
126+
// region Module constants
127+
fun getConstants(): MutableMap<String, Any> = mutableMapOf("keyboardBorderRadius" to 0)
121128

122129
companion object {
123130
const val NAME = "KeyboardController"
124131
}
132+
// endregion
125133
}

android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class KeyboardControllerModule(
1313

1414
override fun getName(): String = KeyboardControllerModuleImpl.NAME
1515

16-
override fun getConstants(): MutableMap<String, Any> = mutableMapOf("keyboardBorderRadius" to 0)
16+
override fun getConstants(): MutableMap<String, Any> = module.getConstants()
1717

1818
@ReactMethod
1919
fun setInputMode(mode: Int) {
-1.62 KB
Loading
-1.54 KB
Loading
-1.61 KB
Loading

ios/KeyboardControllerModule.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ - (NSDictionary *)constantsToExport
6060
};
6161
}
6262

63+
- (NSDictionary *)getConstants
64+
{
65+
return [self constantsToExport];
66+
}
67+
6368
#ifdef RCT_NEW_ARCH_ENABLED
6469
- (void)setDefaultMode
6570
#else

src/bindings.native.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ export const KeyboardControllerNative = (
3636
)
3737
) as KeyboardControllerNativeModule;
3838

39-
export const keyboardBorderRadius: number =
40-
RCTKeyboardController?.getConstants()?.keyboardBorderRadius ?? 0;
41-
4239
const KEYBOARD_CONTROLLER_NAMESPACE = "KeyboardController::";
4340
const eventEmitter = new NativeEventEmitter(KeyboardControllerNative);
4441

src/bindings.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import type { EmitterSubscription } from "react-native";
1717

1818
const NOOP = () => {};
1919

20-
export const keyboardBorderRadius: number = 0;
21-
2220
export const KeyboardControllerNative: KeyboardControllerNativeModule = {
2321
setDefaultMode: NOOP,
2422
setInputMode: NOOP,
@@ -29,6 +27,9 @@ export const KeyboardControllerNative: KeyboardControllerNativeModule = {
2927
Promise.resolve({ x: 0, y: 0, width: 0, height: 0 }),
3028
addListener: NOOP,
3129
removeListeners: NOOP,
30+
getConstants: () => ({
31+
keyboardBorderRadius: 0,
32+
}),
3233
};
3334
/**
3435
* An event emitter that provides a way to subscribe to next keyboard events:

src/components/KeyboardToolbar/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { keyboardBorderRadius } from "../../bindings";
1+
import { KEYBOARD_BORDER_RADIUS } from "../../constants";
22

33
import type { HEX } from "./types";
44

@@ -10,5 +10,5 @@ export const TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;
1010

1111
export const KEYBOARD_TOOLBAR_HEIGHT = 42;
1212
export const DEFAULT_OPACITY: HEX = "FF";
13-
export const KEYBOARD_HAS_ROUNDED_CORNERS = keyboardBorderRadius > 0;
13+
export const KEYBOARD_HAS_ROUNDED_CORNERS = KEYBOARD_BORDER_RADIUS > 0;
1414
export const OPENED_OFFSET = KEYBOARD_HAS_ROUNDED_CORNERS ? -11 : 0;

0 commit comments

Comments
 (0)