react-native-keyboard-controller 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +32 -3
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +25 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +32 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +25 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationCallback.kt +6 -6
- package/android/src/main/java/com/reactnativekeyboardcontroller/{KeyboardControllerModule.kt → KeyboardControllerModuleImpl.kt} +5 -17
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +45 -4
- package/android/src/main/java/com/reactnativekeyboardcontroller/{KeyboardControllerViewManager.kt → KeyboardControllerViewManagerImpl.kt} +8 -9
- package/android/src/main/java/com/reactnativekeyboardcontroller/{StatusBarManagerCompatModule.kt → StatusBarManagerCompatImpl.kt} +10 -14
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +31 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +26 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +34 -0
- package/ios/.clang-format +1 -1
- package/ios/KeyboardController.xcodeproj/project.pbxproj +20 -16
- package/ios/KeyboardControllerModule-Header.h +6 -2
- package/ios/KeyboardControllerModule.mm +105 -0
- package/ios/KeyboardControllerView.h +23 -0
- package/ios/KeyboardControllerView.mm +81 -0
- package/ios/{KeyboardControllerViewManager.m → KeyboardControllerViewManager.mm} +0 -0
- package/ios/KeyboardControllerViewManager.swift +2 -2
- package/ios/KeyboardMoveEvent.h +18 -0
- package/ios/KeyboardMoveEvent.m +74 -0
- package/lib/commonjs/animated.js +14 -59
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/context.js +28 -0
- package/lib/commonjs/context.js.map +1 -0
- package/lib/commonjs/hooks.js +39 -0
- package/lib/commonjs/hooks.js.map +1 -0
- package/lib/commonjs/index.js +39 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +27 -0
- package/lib/commonjs/internal.js.map +1 -0
- package/lib/commonjs/monkey-patch.js +3 -1
- package/lib/commonjs/monkey-patch.js.map +1 -1
- package/lib/commonjs/native.js +24 -19
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/replicas.js +2 -2
- package/lib/commonjs/replicas.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +16 -0
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/NativeKeyboardController.js +13 -0
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -0
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js +13 -0
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/animated.js +12 -50
- package/lib/module/animated.js.map +1 -1
- package/lib/module/context.js +18 -0
- package/lib/module/context.js.map +1 -0
- package/lib/module/hooks.js +20 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +19 -0
- package/lib/module/internal.js.map +1 -0
- package/lib/module/monkey-patch.js +4 -2
- package/lib/module/monkey-patch.js.map +1 -1
- package/lib/module/native.js +23 -16
- package/lib/module/native.js.map +1 -1
- package/lib/module/replicas.js +1 -1
- package/lib/module/replicas.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js +4 -0
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
- package/lib/module/specs/NativeKeyboardController.js +3 -0
- package/lib/module/specs/NativeKeyboardController.js.map +1 -0
- package/lib/module/specs/NativeStatusBarManagerCompat.js +3 -0
- package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/animated.d.ts +1 -17
- package/lib/typescript/context.d.ts +16 -0
- package/lib/typescript/hooks.d.ts +4 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/internal.d.ts +4 -0
- package/lib/typescript/native.d.ts +15 -27
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +13 -0
- package/lib/typescript/specs/NativeKeyboardController.d.ts +10 -0
- package/lib/typescript/specs/NativeStatusBarManagerCompat.d.ts +10 -0
- package/lib/typescript/types.d.ts +23 -0
- package/package.json +20 -8
- package/react-native-keyboard-controller.podspec +21 -1
- package/src/animated.tsx +12 -75
- package/src/context.ts +28 -0
- package/src/hooks.ts +28 -0
- package/src/index.ts +3 -0
- package/src/internal.ts +27 -0
- package/src/{monkey-patch.tsx → monkey-patch.ts} +3 -2
- package/src/native.ts +37 -61
- package/src/replicas.ts +1 -1
- package/src/specs/KeyboardControllerViewNativeComponent.ts +23 -0
- package/src/specs/NativeKeyboardController.ts +16 -0
- package/src/specs/NativeStatusBarManagerCompat.ts +13 -0
- package/src/types.ts +42 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -185
- package/android/gradlew.bat +0 -89
- package/ios/KeyboardControllerModule.m +0 -21
- package/ios/KeyboardControllerModule.swift +0 -53
- package/ios/KeyboardMoveEvent.swift +0 -41
package/android/build.gradle
CHANGED
|
@@ -14,9 +14,6 @@ buildscript {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
apply plugin: 'com.android.library'
|
|
18
|
-
apply plugin: 'kotlin-android'
|
|
19
|
-
|
|
20
17
|
def getExtOrDefault(name) {
|
|
21
18
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['KeyboardController_' + name]
|
|
22
19
|
}
|
|
@@ -25,6 +22,22 @@ def getExtOrIntegerDefault(name) {
|
|
|
25
22
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['KeyboardController_' + name]).toInteger()
|
|
26
23
|
}
|
|
27
24
|
|
|
25
|
+
def isNewArchitectureEnabled() {
|
|
26
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
def reactNativeArchitectures() {
|
|
30
|
+
def value = project.getProperties().get("reactNativeArchitectures")
|
|
31
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
apply plugin: 'com.android.library'
|
|
35
|
+
apply plugin: 'kotlin-android'
|
|
36
|
+
|
|
37
|
+
if (isNewArchitectureEnabled()) {
|
|
38
|
+
apply plugin: 'com.facebook.react'
|
|
39
|
+
}
|
|
40
|
+
|
|
28
41
|
android {
|
|
29
42
|
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
30
43
|
defaultConfig {
|
|
@@ -32,7 +45,23 @@ android {
|
|
|
32
45
|
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
33
46
|
versionCode 1
|
|
34
47
|
versionName "1.0"
|
|
48
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
49
|
+
ndk {
|
|
50
|
+
abiFilters (*reactNativeArchitectures())
|
|
51
|
+
}
|
|
52
|
+
}
|
|
35
53
|
|
|
54
|
+
sourceSets {
|
|
55
|
+
main {
|
|
56
|
+
if (isNewArchitectureEnabled()) {
|
|
57
|
+
java.srcDirs += [
|
|
58
|
+
'src/fabric',
|
|
59
|
+
'build/generated/source/codegen/java'
|
|
60
|
+
]
|
|
61
|
+
} else {
|
|
62
|
+
java.srcDirs += ['src/paper']
|
|
63
|
+
}
|
|
64
|
+
}
|
|
36
65
|
}
|
|
37
66
|
|
|
38
67
|
buildTypes {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package com.reactnativekeyboardcontroller
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
|
|
5
|
+
class KeyboardControllerModule(mReactContext: ReactApplicationContext) : NativeKeyboardControllerSpec(mReactContext) {
|
|
6
|
+
private val module = KeyboardControllerModuleImpl(mReactContext)
|
|
7
|
+
|
|
8
|
+
override fun getName(): String = KeyboardControllerModuleImpl.NAME
|
|
9
|
+
|
|
10
|
+
override fun setInputMode(mode: Double) {
|
|
11
|
+
module.setInputMode(mode.toInt())
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun setDefaultMode() {
|
|
15
|
+
module.setDefaultMode()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override fun addListener(eventName: String?) {
|
|
19
|
+
/* Required for RN built-in Event Emitter Calls. */
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun removeListeners(count: Double) {
|
|
23
|
+
/* Required for RN built-in Event Emitter Calls. */
|
|
24
|
+
}
|
|
25
|
+
}
|
package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package com.reactnativekeyboardcontroller
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
6
|
+
import com.facebook.react.viewmanagers.KeyboardControllerViewManagerDelegate
|
|
7
|
+
import com.facebook.react.viewmanagers.KeyboardControllerViewManagerInterface
|
|
8
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
9
|
+
import com.facebook.react.views.view.ReactViewManager
|
|
10
|
+
|
|
11
|
+
class KeyboardControllerViewManager(mReactContext: ReactApplicationContext) : ReactViewManager(), KeyboardControllerViewManagerInterface<ReactViewGroup> {
|
|
12
|
+
private val manager = KeyboardControllerViewManagerImpl(mReactContext)
|
|
13
|
+
private val mDelegate = KeyboardControllerViewManagerDelegate(this)
|
|
14
|
+
|
|
15
|
+
override fun getDelegate(): ViewManagerDelegate<ReactViewGroup?> {
|
|
16
|
+
return mDelegate
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getName(): String = KeyboardControllerViewManagerImpl.NAME
|
|
20
|
+
|
|
21
|
+
override fun createViewInstance(context: ThemedReactContext): ReactViewGroup {
|
|
22
|
+
return manager.createViewInstance(context)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun setStatusBarTranslucent(view: ReactViewGroup, value: Boolean) {
|
|
26
|
+
return manager.setStatusBarTranslucent(view, value)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> {
|
|
30
|
+
return manager.getExportedCustomDirectEventTypeConstants()
|
|
31
|
+
}
|
|
32
|
+
}
|
package/android/src/fabric/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package com.reactnativekeyboardcontroller
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
|
|
5
|
+
class StatusBarManagerCompatModule(private val mReactContext: ReactApplicationContext) : NativeStatusBarManagerCompatSpec(mReactContext) {
|
|
6
|
+
private val module = StatusBarManagerCompatImpl(mReactContext)
|
|
7
|
+
|
|
8
|
+
override fun getName(): String = StatusBarManagerCompatImpl.NAME
|
|
9
|
+
|
|
10
|
+
override fun setHidden(hidden: Boolean) {
|
|
11
|
+
module.setHidden(hidden)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun setColor(color: Double, animated: Boolean) {
|
|
15
|
+
module.setColor(color.toInt(), animated)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override fun setTranslucent(translucent: Boolean) {
|
|
19
|
+
module.setTranslucent(translucent)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun setStyle(style: String) {
|
|
23
|
+
module.setStyle(style)
|
|
24
|
+
}
|
|
25
|
+
}
|
package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationCallback.kt
CHANGED
|
@@ -15,8 +15,9 @@ import com.facebook.react.bridge.Arguments
|
|
|
15
15
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
16
16
|
import com.facebook.react.bridge.WritableMap
|
|
17
17
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
18
|
-
import com.facebook.react.uimanager.
|
|
18
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
19
19
|
import com.facebook.react.uimanager.events.Event
|
|
20
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
20
21
|
import com.facebook.react.views.view.ReactViewGroup
|
|
21
22
|
import com.reactnativekeyboardcontroller.events.KeyboardTransitionEvent
|
|
22
23
|
|
|
@@ -132,7 +133,7 @@ class KeyboardAnimationCallback(
|
|
|
132
133
|
|
|
133
134
|
var progress = 0.0
|
|
134
135
|
try {
|
|
135
|
-
progress = Math.abs((height.toDouble() / persistentKeyboardHeight))
|
|
136
|
+
progress = Math.abs((height.toDouble() / persistentKeyboardHeight)).let { if (it.isNaN()) 0.0 else it }
|
|
136
137
|
} catch (e: ArithmeticException) {
|
|
137
138
|
// do nothing, send progress as 0
|
|
138
139
|
}
|
|
@@ -167,10 +168,9 @@ class KeyboardAnimationCallback(
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
private fun sendEventToJS(event: Event<*>) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
?.dispatchEvent(event)
|
|
171
|
+
val eventDispatcher: EventDispatcher? =
|
|
172
|
+
UIManagerHelper.getEventDispatcherForReactTag(context, view.id)
|
|
173
|
+
eventDispatcher?.dispatchEvent(event)
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
private fun emitEvent(event: String, params: WritableMap) {
|
|
@@ -2,38 +2,26 @@ package com.reactnativekeyboardcontroller
|
|
|
2
2
|
|
|
3
3
|
import android.view.WindowManager
|
|
4
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
-
import com.facebook.react.bridge.ReactMethod
|
|
7
5
|
import com.facebook.react.bridge.UiThreadUtil
|
|
8
6
|
|
|
9
|
-
class
|
|
7
|
+
class KeyboardControllerModuleImpl(private val mReactContext: ReactApplicationContext) {
|
|
10
8
|
private val mDefaultMode: Int = mReactContext.currentActivity?.window?.attributes?.softInputMode ?: WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED
|
|
11
9
|
|
|
12
|
-
override fun getName(): String = "KeyboardController"
|
|
13
|
-
|
|
14
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
15
10
|
fun setInputMode(mode: Int) {
|
|
16
11
|
setSoftInputMode(mode)
|
|
17
12
|
}
|
|
18
13
|
|
|
19
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
20
14
|
fun setDefaultMode() {
|
|
21
15
|
setSoftInputMode(mDefaultMode)
|
|
22
16
|
}
|
|
23
17
|
|
|
24
|
-
@ReactMethod
|
|
25
|
-
fun addListener(eventName: String?) {
|
|
26
|
-
/* Required for RN built-in Event Emitter Calls. */
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@ReactMethod
|
|
30
|
-
fun removeListeners(count: Int?) {
|
|
31
|
-
/* Required for RN built-in Event Emitter Calls. */
|
|
32
|
-
}
|
|
33
|
-
|
|
34
18
|
private fun setSoftInputMode(mode: Int) {
|
|
35
19
|
UiThreadUtil.runOnUiThread {
|
|
36
20
|
mReactContext.currentActivity?.window?.setSoftInputMode(mode)
|
|
37
21
|
}
|
|
38
22
|
}
|
|
23
|
+
|
|
24
|
+
companion object {
|
|
25
|
+
const val NAME = "KeyboardController"
|
|
26
|
+
}
|
|
39
27
|
}
|
package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt
CHANGED
|
@@ -1,13 +1,54 @@
|
|
|
1
1
|
package com.reactnativekeyboardcontroller
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import androidx.annotation.Nullable
|
|
4
|
+
import com.facebook.react.TurboReactPackage
|
|
4
5
|
import com.facebook.react.bridge.NativeModule
|
|
5
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
6
9
|
import com.facebook.react.uimanager.ViewManager
|
|
7
10
|
|
|
8
|
-
class KeyboardControllerPackage :
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
class KeyboardControllerPackage : TurboReactPackage() {
|
|
12
|
+
@Nullable
|
|
13
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
14
|
+
return when (name) {
|
|
15
|
+
KeyboardControllerModuleImpl.NAME -> {
|
|
16
|
+
KeyboardControllerModule(reactContext)
|
|
17
|
+
}
|
|
18
|
+
StatusBarManagerCompatImpl.NAME -> {
|
|
19
|
+
StatusBarManagerCompatModule(reactContext)
|
|
20
|
+
}
|
|
21
|
+
else -> {
|
|
22
|
+
null
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
28
|
+
return ReactModuleInfoProvider {
|
|
29
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
30
|
+
val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
31
|
+
|
|
32
|
+
moduleInfos[KeyboardControllerModuleImpl.NAME] = ReactModuleInfo(
|
|
33
|
+
KeyboardControllerModuleImpl.NAME,
|
|
34
|
+
KeyboardControllerModuleImpl.NAME,
|
|
35
|
+
false, // canOverrideExistingModule
|
|
36
|
+
false, // needsEagerInit
|
|
37
|
+
true, // hasConstants
|
|
38
|
+
false, // isCxxModule
|
|
39
|
+
isTurboModule // isTurboModule
|
|
40
|
+
)
|
|
41
|
+
moduleInfos[StatusBarManagerCompatImpl.NAME] = ReactModuleInfo(
|
|
42
|
+
StatusBarManagerCompatImpl.NAME,
|
|
43
|
+
StatusBarManagerCompatImpl.NAME,
|
|
44
|
+
false, // canOverrideExistingModule
|
|
45
|
+
false, // needsEagerInit
|
|
46
|
+
true, // hasConstants
|
|
47
|
+
false, // isCxxModule
|
|
48
|
+
isTurboModule // isTurboModule
|
|
49
|
+
)
|
|
50
|
+
moduleInfos
|
|
51
|
+
}
|
|
11
52
|
}
|
|
12
53
|
|
|
13
54
|
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
@@ -8,19 +8,15 @@ import androidx.core.view.WindowInsetsCompat
|
|
|
8
8
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
9
|
import com.facebook.react.common.MapBuilder
|
|
10
10
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
11
|
-
import com.facebook.react.uimanager.annotations.ReactProp
|
|
12
11
|
import com.facebook.react.views.view.ReactViewGroup
|
|
13
|
-
import com.facebook.react.views.view.ReactViewManager
|
|
14
12
|
import com.reactnativekeyboardcontroller.events.KeyboardTransitionEvent
|
|
15
13
|
|
|
16
|
-
class
|
|
17
|
-
private val TAG =
|
|
14
|
+
class KeyboardControllerViewManagerImpl(reactContext: ReactApplicationContext) {
|
|
15
|
+
private val TAG = KeyboardControllerViewManagerImpl::class.qualifiedName
|
|
18
16
|
private var mReactContext = reactContext
|
|
19
17
|
private var isStatusBarTranslucent = false
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
override fun createViewInstance(reactContext: ThemedReactContext): ReactViewGroup {
|
|
19
|
+
fun createViewInstance(reactContext: ThemedReactContext): ReactViewGroup {
|
|
24
20
|
val view = EdgeToEdgeReactViewGroup(reactContext)
|
|
25
21
|
val activity = mReactContext.currentActivity
|
|
26
22
|
|
|
@@ -56,12 +52,11 @@ class KeyboardControllerViewManager(reactContext: ReactApplicationContext) : Rea
|
|
|
56
52
|
return view
|
|
57
53
|
}
|
|
58
54
|
|
|
59
|
-
@ReactProp(name = "statusBarTranslucent")
|
|
60
55
|
fun setStatusBarTranslucent(view: ReactViewGroup, isStatusBarTranslucent: Boolean) {
|
|
61
56
|
this.isStatusBarTranslucent = isStatusBarTranslucent
|
|
62
57
|
}
|
|
63
58
|
|
|
64
|
-
|
|
59
|
+
fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> {
|
|
65
60
|
val map: MutableMap<String, Any> = MapBuilder.of(
|
|
66
61
|
KeyboardTransitionEvent.EVENT_NAME,
|
|
67
62
|
MapBuilder.of("registrationName", "onKeyboardMove")
|
|
@@ -69,4 +64,8 @@ class KeyboardControllerViewManager(reactContext: ReactApplicationContext) : Rea
|
|
|
69
64
|
|
|
70
65
|
return map
|
|
71
66
|
}
|
|
67
|
+
|
|
68
|
+
companion object {
|
|
69
|
+
const val NAME = "KeyboardControllerView"
|
|
70
|
+
}
|
|
72
71
|
}
|
|
@@ -8,18 +8,13 @@ import androidx.annotation.RequiresApi
|
|
|
8
8
|
import androidx.core.view.WindowInsetsCompat
|
|
9
9
|
import androidx.core.view.WindowInsetsControllerCompat
|
|
10
10
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
12
|
-
import com.facebook.react.bridge.ReactMethod
|
|
13
11
|
import com.facebook.react.bridge.UiThreadUtil
|
|
14
12
|
|
|
15
|
-
class
|
|
16
|
-
private val TAG =
|
|
13
|
+
class StatusBarManagerCompatImpl(private val mReactContext: ReactApplicationContext) {
|
|
14
|
+
private val TAG = StatusBarManagerCompatImpl::class.qualifiedName
|
|
17
15
|
private var controller: WindowInsetsControllerCompat? = null
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@ReactMethod
|
|
22
|
-
private fun setHidden(hidden: Boolean) {
|
|
17
|
+
fun setHidden(hidden: Boolean) {
|
|
23
18
|
UiThreadUtil.runOnUiThread {
|
|
24
19
|
if (hidden) {
|
|
25
20
|
getController()?.hide(WindowInsetsCompat.Type.statusBars())
|
|
@@ -30,8 +25,7 @@ class StatusBarManagerCompatModule(private val mReactContext: ReactApplicationCo
|
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
|
|
33
|
-
|
|
34
|
-
private fun setColor(color: Int, animated: Boolean) {
|
|
28
|
+
fun setColor(color: Int, animated: Boolean) {
|
|
35
29
|
val activity = mReactContext.currentActivity
|
|
36
30
|
if (activity == null) {
|
|
37
31
|
Log.w(TAG, "StatusBarManagerCompatModule: Ignored status bar change, current activity is null.")
|
|
@@ -55,8 +49,7 @@ class StatusBarManagerCompatModule(private val mReactContext: ReactApplicationCo
|
|
|
55
49
|
}
|
|
56
50
|
}
|
|
57
51
|
|
|
58
|
-
|
|
59
|
-
private fun setTranslucent(translucent: Boolean) {
|
|
52
|
+
fun setTranslucent(translucent: Boolean) {
|
|
60
53
|
// the status bar is translucent by default (once you wrapped App in Provider,
|
|
61
54
|
// and EdgeToEdgeReactViewGroup has been mounted and called
|
|
62
55
|
// `setDecorFitsSystemWindows(window, false)`. By default this library applies default padding
|
|
@@ -70,8 +63,7 @@ class StatusBarManagerCompatModule(private val mReactContext: ReactApplicationCo
|
|
|
70
63
|
// app requires to dynamically manage it - just shoot an issue and I will try to add a support fot that.
|
|
71
64
|
}
|
|
72
65
|
|
|
73
|
-
|
|
74
|
-
private fun setStyle(style: String) {
|
|
66
|
+
fun setStyle(style: String) {
|
|
75
67
|
UiThreadUtil.runOnUiThread {
|
|
76
68
|
getController()?.isAppearanceLightStatusBars = style == "dark-content"
|
|
77
69
|
}
|
|
@@ -92,4 +84,8 @@ class StatusBarManagerCompatModule(private val mReactContext: ReactApplicationCo
|
|
|
92
84
|
|
|
93
85
|
return this.controller
|
|
94
86
|
}
|
|
87
|
+
|
|
88
|
+
companion object {
|
|
89
|
+
const val NAME = "StatusBarManagerCompat"
|
|
90
|
+
}
|
|
95
91
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package com.reactnativekeyboardcontroller
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
+
import com.facebook.react.bridge.ReactMethod
|
|
6
|
+
|
|
7
|
+
class KeyboardControllerModule(mReactContext: ReactApplicationContext) : ReactContextBaseJavaModule(mReactContext) {
|
|
8
|
+
private val module = KeyboardControllerModuleImpl(mReactContext)
|
|
9
|
+
|
|
10
|
+
override fun getName(): String = KeyboardControllerModuleImpl.NAME
|
|
11
|
+
|
|
12
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
13
|
+
fun setInputMode(mode: Int) {
|
|
14
|
+
module.setInputMode(mode)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
18
|
+
fun setDefaultMode() {
|
|
19
|
+
module.setDefaultMode()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@ReactMethod
|
|
23
|
+
fun addListener(eventName: String?) {
|
|
24
|
+
/* Required for RN built-in Event Emitter Calls. */
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@ReactMethod
|
|
28
|
+
fun removeListeners(count: Int?) {
|
|
29
|
+
/* Required for RN built-in Event Emitter Calls. */
|
|
30
|
+
}
|
|
31
|
+
}
|
package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.reactnativekeyboardcontroller
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
6
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
7
|
+
import com.facebook.react.views.view.ReactViewManager
|
|
8
|
+
|
|
9
|
+
class KeyboardControllerViewManager(mReactContext: ReactApplicationContext) : ReactViewManager() {
|
|
10
|
+
private val manager = KeyboardControllerViewManagerImpl(mReactContext)
|
|
11
|
+
|
|
12
|
+
override fun getName(): String = KeyboardControllerViewManagerImpl.NAME
|
|
13
|
+
|
|
14
|
+
override fun createViewInstance(reactContext: ThemedReactContext): ReactViewGroup {
|
|
15
|
+
return manager.createViewInstance(reactContext)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@ReactProp(name = "statusBarTranslucent")
|
|
19
|
+
fun setStatusBarTranslucent(view: ReactViewGroup, isStatusBarTranslucent: Boolean) {
|
|
20
|
+
manager.setStatusBarTranslucent(view, isStatusBarTranslucent)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> {
|
|
24
|
+
return manager.getExportedCustomDirectEventTypeConstants()
|
|
25
|
+
}
|
|
26
|
+
}
|
package/android/src/paper/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
package com.reactnativekeyboardcontroller
|
|
2
|
+
|
|
3
|
+
import android.os.Build
|
|
4
|
+
import androidx.annotation.RequiresApi
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
7
|
+
import com.facebook.react.bridge.ReactMethod
|
|
8
|
+
|
|
9
|
+
class StatusBarManagerCompatModule(private val mReactContext: ReactApplicationContext) : ReactContextBaseJavaModule(mReactContext) {
|
|
10
|
+
private val module = StatusBarManagerCompatImpl(mReactContext)
|
|
11
|
+
|
|
12
|
+
override fun getName(): String = StatusBarManagerCompatImpl.NAME
|
|
13
|
+
|
|
14
|
+
@ReactMethod
|
|
15
|
+
private fun setHidden(hidden: Boolean) {
|
|
16
|
+
module.setHidden(hidden)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@ReactMethod
|
|
20
|
+
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
|
|
21
|
+
private fun setColor(color: Int, animated: Boolean) {
|
|
22
|
+
module.setColor(color, animated)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@ReactMethod
|
|
26
|
+
private fun setTranslucent(translucent: Boolean) {
|
|
27
|
+
module.setTranslucent(translucent)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@ReactMethod
|
|
31
|
+
private fun setStyle(style: String) {
|
|
32
|
+
module.setStyle(style)
|
|
33
|
+
}
|
|
34
|
+
}
|
package/ios/.clang-format
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
objects = {
|
|
8
8
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
|
-
|
|
11
|
-
F359D34F28133C26000B6AFE /* KeyboardControllerModule.
|
|
10
|
+
F333F8D428996B8D0015B05F /* KeyboardControllerView.mm in Sources */ = {isa = PBXBuildFile; fileRef = F333F8D228996B8D0015B05F /* KeyboardControllerView.mm */; };
|
|
11
|
+
F359D34F28133C26000B6AFE /* KeyboardControllerModule.mm in Sources */ = {isa = PBXBuildFile; fileRef = F359D34E28133C26000B6AFE /* KeyboardControllerModule.mm */; };
|
|
12
12
|
F3626A0728B3FE760021B2D9 /* KeyboardMovementObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3626A0628B3FE760021B2D9 /* KeyboardMovementObserver.swift */; };
|
|
13
|
-
|
|
13
|
+
F3F50669289E653B003091D6 /* KeyboardMoveEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = F3F50668289E653B003091D6 /* KeyboardMoveEvent.m */; };
|
|
14
14
|
F4FF95D7245B92E800C19C63 /* KeyboardControllerViewManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* KeyboardControllerViewManager.swift */; };
|
|
15
15
|
/* End PBXBuildFile section */
|
|
16
16
|
|
|
@@ -28,12 +28,14 @@
|
|
|
28
28
|
|
|
29
29
|
/* Begin PBXFileReference section */
|
|
30
30
|
134814201AA4EA6300B7C361 /* libKeyboardController.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libKeyboardController.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
31
|
-
B3E7B5891CC2AC0600A0062D /* KeyboardControllerViewManager.
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
B3E7B5891CC2AC0600A0062D /* KeyboardControllerViewManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KeyboardControllerViewManager.mm; sourceTree = "<group>"; };
|
|
32
|
+
F333F8D128996B1C0015B05F /* KeyboardControllerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KeyboardControllerView.h; sourceTree = "<group>"; };
|
|
33
|
+
F333F8D228996B8D0015B05F /* KeyboardControllerView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = KeyboardControllerView.mm; sourceTree = "<group>"; };
|
|
34
|
+
F359D34E28133C26000B6AFE /* KeyboardControllerModule.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = KeyboardControllerModule.mm; sourceTree = "<group>"; };
|
|
34
35
|
F359D35028133C6F000B6AFE /* KeyboardControllerModule-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "KeyboardControllerModule-Header.h"; sourceTree = "<group>"; };
|
|
35
36
|
F3626A0628B3FE760021B2D9 /* KeyboardMovementObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardMovementObserver.swift; sourceTree = "<group>"; };
|
|
36
|
-
|
|
37
|
+
F3F50667289E653B003091D6 /* KeyboardMoveEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KeyboardMoveEvent.h; sourceTree = "<group>"; };
|
|
38
|
+
F3F50668289E653B003091D6 /* KeyboardMoveEvent.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KeyboardMoveEvent.m; sourceTree = "<group>"; };
|
|
37
39
|
F4FF95D5245B92E700C19C63 /* KeyboardController-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "KeyboardController-Bridging-Header.h"; sourceTree = "<group>"; };
|
|
38
40
|
F4FF95D6245B92E800C19C63 /* KeyboardControllerViewManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardControllerViewManager.swift; sourceTree = "<group>"; };
|
|
39
41
|
/* End PBXFileReference section */
|
|
@@ -60,13 +62,15 @@
|
|
|
60
62
|
58B511D21A9E6C8500147676 = {
|
|
61
63
|
isa = PBXGroup;
|
|
62
64
|
children = (
|
|
65
|
+
F3F50667289E653B003091D6 /* KeyboardMoveEvent.h */,
|
|
66
|
+
F3F50668289E653B003091D6 /* KeyboardMoveEvent.m */,
|
|
63
67
|
F3626A0628B3FE760021B2D9 /* KeyboardMovementObserver.swift */,
|
|
64
|
-
|
|
68
|
+
F333F8D228996B8D0015B05F /* KeyboardControllerView.mm */,
|
|
69
|
+
F333F8D128996B1C0015B05F /* KeyboardControllerView.h */,
|
|
65
70
|
F359D35028133C6F000B6AFE /* KeyboardControllerModule-Header.h */,
|
|
66
|
-
F359D34E28133C26000B6AFE /* KeyboardControllerModule.
|
|
67
|
-
F359D34C28133BE1000B6AFE /* KeyboardControllerModule.swift */,
|
|
71
|
+
F359D34E28133C26000B6AFE /* KeyboardControllerModule.mm */,
|
|
68
72
|
F4FF95D6245B92E800C19C63 /* KeyboardControllerViewManager.swift */,
|
|
69
|
-
B3E7B5891CC2AC0600A0062D /* KeyboardControllerViewManager.
|
|
73
|
+
B3E7B5891CC2AC0600A0062D /* KeyboardControllerViewManager.mm */,
|
|
70
74
|
F4FF95D5245B92E700C19C63 /* KeyboardController-Bridging-Header.h */,
|
|
71
75
|
134814211AA4EA7D00B7C361 /* Products */,
|
|
72
76
|
);
|
|
@@ -129,11 +133,11 @@
|
|
|
129
133
|
isa = PBXSourcesBuildPhase;
|
|
130
134
|
buildActionMask = 2147483647;
|
|
131
135
|
files = (
|
|
132
|
-
F3FF0915281851CC006831B1 /* KeyboardMoveEvent.swift in Sources */,
|
|
133
136
|
F3626A0728B3FE760021B2D9 /* KeyboardMovementObserver.swift in Sources */,
|
|
134
|
-
F359D34F28133C26000B6AFE /* KeyboardControllerModule.
|
|
135
|
-
F359D34D28133BE1000B6AFE /* KeyboardControllerModule.swift in Sources */,
|
|
137
|
+
F359D34F28133C26000B6AFE /* KeyboardControllerModule.mm in Sources */,
|
|
136
138
|
F4FF95D7245B92E800C19C63 /* KeyboardControllerViewManager.swift in Sources */,
|
|
139
|
+
F333F8D428996B8D0015B05F /* KeyboardControllerView.mm in Sources */,
|
|
140
|
+
F3F50669289E653B003091D6 /* KeyboardMoveEvent.m in Sources */,
|
|
137
141
|
);
|
|
138
142
|
runOnlyForDeploymentPostprocessing = 0;
|
|
139
143
|
};
|
|
@@ -183,7 +187,7 @@
|
|
|
183
187
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
184
188
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
185
189
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
186
|
-
IPHONEOS_DEPLOYMENT_TARGET =
|
|
190
|
+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
|
187
191
|
MTL_ENABLE_DEBUG_INFO = YES;
|
|
188
192
|
ONLY_ACTIVE_ARCH = YES;
|
|
189
193
|
SDKROOT = iphoneos;
|
|
@@ -226,7 +230,7 @@
|
|
|
226
230
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
227
231
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
228
232
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
229
|
-
IPHONEOS_DEPLOYMENT_TARGET =
|
|
233
|
+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
|
230
234
|
MTL_ENABLE_DEBUG_INFO = NO;
|
|
231
235
|
SDKROOT = iphoneos;
|
|
232
236
|
VALIDATE_PRODUCT = YES;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// KeyboardControllerModule-Header.h
|
|
3
3
|
// KeyboardController
|
|
4
4
|
//
|
|
5
5
|
// Created by Kiryl Ziusko on 22.04.22.
|
|
6
6
|
// Copyright © 2022 Facebook. All rights reserved.
|
|
7
7
|
//
|
|
8
8
|
|
|
9
|
-
#import <React/RCTBridgeModule.h>
|
|
10
9
|
#import <React/RCTEventEmitter.h>
|
|
10
|
+
|
|
11
|
+
@interface KeyboardController : RCTEventEmitter
|
|
12
|
+
+ (KeyboardController *)shared;
|
|
13
|
+
- (void)sendEvent:(NSString *)name body:(id)body;
|
|
14
|
+
@end
|