@communi/keyboard-area-react-native 2.0.1
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/LICENSE +20 -0
- package/PiScaleKeyboardAreaReactNative.podspec +42 -0
- package/README.md +3 -0
- package/android/build.gradle +70 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/piscale/reactnative/keyboard/KeyboardAreaReactNativeModule.kt +97 -0
- package/android/src/main/java/com/piscale/reactnative/keyboard/KeyboardAreaReactNativePackage.kt +17 -0
- package/android/src/main/java/com/piscale/reactnative/keyboard/KeyboardProvider.kt +102 -0
- package/android/src/main/res/layout/keyboard_popup.xml +5 -0
- package/index.d.ts +25 -0
- package/index.js +1 -0
- package/ios/KeyboardAreaReactNative-Bridging-Header.h +2 -0
- package/ios/KeyboardAreaReactNative.mm +10 -0
- package/ios/KeyboardAreaReactNative.swift +65 -0
- package/package.json +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 PiScale Developer
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = "PiScaleKeyboardAreaReactNative"
|
|
8
|
+
s.version = package["version"]
|
|
9
|
+
s.summary = package["description"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
|
|
14
|
+
s.platforms = { :ios => "11.0" }
|
|
15
|
+
|
|
16
|
+
s.source = { git: 'https://github.com/piscale/keyboard-area-react-native' }
|
|
17
|
+
|
|
18
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
19
|
+
|
|
20
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
21
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
22
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
23
|
+
install_modules_dependencies(s)
|
|
24
|
+
else
|
|
25
|
+
s.dependency "React-Core"
|
|
26
|
+
|
|
27
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
28
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
29
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
30
|
+
s.pod_target_xcconfig = {
|
|
31
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
32
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
33
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
34
|
+
}
|
|
35
|
+
s.dependency "React-Codegen"
|
|
36
|
+
s.dependency "RCT-Folly"
|
|
37
|
+
s.dependency "RCTRequired"
|
|
38
|
+
s.dependency "RCTTypeSafety"
|
|
39
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["KeyboardAreaReactNative_kotlinVersion"]
|
|
4
|
+
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath "com.android.tools.build:gradle:7.3.1"
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def isNewArchitectureEnabled() {
|
|
18
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply plugin: "com.android.library"
|
|
22
|
+
apply plugin: "kotlin-android"
|
|
23
|
+
|
|
24
|
+
if (isNewArchitectureEnabled()) {
|
|
25
|
+
apply plugin: "com.facebook.react"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def getExtOrDefault(name) {
|
|
29
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["KeyboardAreaReactNative_" + name]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def getExtOrIntegerDefault(name) {
|
|
33
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["KeyboardAreaReactNative_" + name]).toInteger()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
android {
|
|
37
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
38
|
+
|
|
39
|
+
defaultConfig {
|
|
40
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
41
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
buildTypes {
|
|
46
|
+
release {
|
|
47
|
+
minifyEnabled false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
lintOptions {
|
|
52
|
+
disable "GradleCompatible"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
repositories {
|
|
57
|
+
mavenCentral()
|
|
58
|
+
google()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
62
|
+
|
|
63
|
+
dependencies {
|
|
64
|
+
// For < 0.71, this will be from the local maven repo
|
|
65
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
66
|
+
//noinspection GradleDynamicVersion
|
|
67
|
+
implementation "com.facebook.react:react-native:+"
|
|
68
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
69
|
+
}
|
|
70
|
+
|
package/android/src/main/java/com/piscale/reactnative/keyboard/KeyboardAreaReactNativeModule.kt
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
package com.piscale.reactnative.keyboard
|
|
2
|
+
|
|
3
|
+
import android.view.WindowManager.LayoutParams
|
|
4
|
+
import com.facebook.react.bridge.*
|
|
5
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
6
|
+
|
|
7
|
+
class KeyboardAreaReactNativeModule(reactContext: ReactApplicationContext) :
|
|
8
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
9
|
+
|
|
10
|
+
companion object {
|
|
11
|
+
const val NAME = "KeyboardAreaReactNative"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private var keyboardProvider: KeyboardProvider? = null
|
|
15
|
+
|
|
16
|
+
override fun getName(): String {
|
|
17
|
+
return NAME
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun invalidate() {
|
|
21
|
+
super.invalidate()
|
|
22
|
+
stopKeyboardListener();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@ReactMethod
|
|
26
|
+
fun setWindowSoftInputMode(mode: Int, promise: Promise) {
|
|
27
|
+
try {
|
|
28
|
+
UiThreadUtil.runOnUiThread {
|
|
29
|
+
currentActivity?.window?.setSoftInputMode(mode)
|
|
30
|
+
promise.resolve("success")
|
|
31
|
+
}
|
|
32
|
+
} catch (e: Exception) {
|
|
33
|
+
promise.reject("error", e.toString())
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@ReactMethod
|
|
38
|
+
fun startKeyboardListener() {
|
|
39
|
+
try {
|
|
40
|
+
UiThreadUtil.runOnUiThread {
|
|
41
|
+
val currentActivity = currentActivity
|
|
42
|
+
if (currentActivity != null) {
|
|
43
|
+
stopKeyboardListener()
|
|
44
|
+
this.keyboardProvider = KeyboardProvider(currentActivity)
|
|
45
|
+
.apply {
|
|
46
|
+
addKeyboardListener(object : KeyboardProvider.KeyboardListener {
|
|
47
|
+
override fun onHeightChanged(height: Int) {
|
|
48
|
+
emit(height)
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} catch (e: Exception) {
|
|
55
|
+
e.printStackTrace()
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@ReactMethod
|
|
60
|
+
fun stopKeyboardListener() {
|
|
61
|
+
try {
|
|
62
|
+
keyboardProvider?.dismiss()
|
|
63
|
+
keyboardProvider = null
|
|
64
|
+
} catch (e: Exception) {
|
|
65
|
+
e.printStackTrace()
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
fun emit(height: Int) {
|
|
70
|
+
try {
|
|
71
|
+
reactApplicationContext
|
|
72
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
73
|
+
.emit("KeyboardSizeChanges", height)
|
|
74
|
+
} catch (e: InterruptedException) {
|
|
75
|
+
e.printStackTrace()
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
override fun getConstants(): Map<String, Int> {
|
|
80
|
+
return mapOf(
|
|
81
|
+
"SOFT_INPUT_ADJUST_NOTHING" to LayoutParams.SOFT_INPUT_ADJUST_NOTHING,
|
|
82
|
+
"SOFT_INPUT_ADJUST_PAN" to LayoutParams.SOFT_INPUT_ADJUST_PAN,
|
|
83
|
+
"SOFT_INPUT_ADJUST_RESIZE" to LayoutParams.SOFT_INPUT_ADJUST_RESIZE,
|
|
84
|
+
"SOFT_INPUT_ADJUST_UNSPECIFIED" to LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED,
|
|
85
|
+
"SOFT_INPUT_IS_FORWARD_NAVIGATION" to LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION,
|
|
86
|
+
"SOFT_INPUT_MASK_ADJUST" to LayoutParams.SOFT_INPUT_MASK_ADJUST,
|
|
87
|
+
"SOFT_INPUT_MASK_STATE" to LayoutParams.SOFT_INPUT_MASK_STATE,
|
|
88
|
+
"SOFT_INPUT_MODE_CHANGED" to LayoutParams.SOFT_INPUT_MODE_CHANGED,
|
|
89
|
+
"SOFT_INPUT_STATE_ALWAYS_HIDDEN" to LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN,
|
|
90
|
+
"SOFT_INPUT_STATE_ALWAYS_VISIBLE" to LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE,
|
|
91
|
+
"SOFT_INPUT_STATE_HIDDEN" to LayoutParams.SOFT_INPUT_STATE_HIDDEN,
|
|
92
|
+
"SOFT_INPUT_STATE_UNCHANGED" to LayoutParams.SOFT_INPUT_STATE_UNCHANGED,
|
|
93
|
+
"SOFT_INPUT_STATE_UNSPECIFIED" to LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED,
|
|
94
|
+
"SOFT_INPUT_STATE_VISIBLE" to LayoutParams.SOFT_INPUT_STATE_VISIBLE,
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
}
|
package/android/src/main/java/com/piscale/reactnative/keyboard/KeyboardAreaReactNativePackage.kt
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.piscale.reactnative.keyboard
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class KeyboardAreaReactNativePackage : ReactPackage {
|
|
10
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
+
return listOf(KeyboardAreaReactNativeModule(reactContext))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
+
return emptyList()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
package com.piscale.reactnative.keyboard
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.graphics.Rect
|
|
5
|
+
import android.view.Gravity
|
|
6
|
+
import android.view.View
|
|
7
|
+
import android.view.ViewTreeObserver
|
|
8
|
+
import android.view.WindowManager
|
|
9
|
+
import android.widget.PopupWindow
|
|
10
|
+
|
|
11
|
+
object KeyboardInfo {
|
|
12
|
+
const val HEIGHT_NOT_COMPUTED = -1
|
|
13
|
+
const val STATE_UNKNOWN = -1
|
|
14
|
+
const val STATE_CLOSED = 0
|
|
15
|
+
const val STATE_OPENED = 1
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Cached keyboard height. This will keep the last keyboard height value and not
|
|
19
|
+
* it's current height
|
|
20
|
+
*/
|
|
21
|
+
var keyboardHeight = HEIGHT_NOT_COMPUTED
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Real time keyboard state
|
|
25
|
+
*/
|
|
26
|
+
var keyboardState = STATE_UNKNOWN
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
class KeyboardProvider(private val activity: Activity) : PopupWindow(activity) {
|
|
30
|
+
|
|
31
|
+
private var heightMax = 0
|
|
32
|
+
private var lastKeyboardHeight = -1
|
|
33
|
+
private val resizableView: View
|
|
34
|
+
private var keyboardListeners = ArrayList<KeyboardListener>()
|
|
35
|
+
private val victim: ViewTreeObserver.OnGlobalLayoutListener =
|
|
36
|
+
ViewTreeObserver.OnGlobalLayoutListener {
|
|
37
|
+
computeKeyboardState()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
init {
|
|
41
|
+
contentView = View.inflate(activity, R.layout.keyboard_popup, null)
|
|
42
|
+
resizableView = contentView.findViewById(R.id.container)
|
|
43
|
+
softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE or
|
|
44
|
+
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
|
|
45
|
+
inputMethodMode = PopupWindow.INPUT_METHOD_NEEDED
|
|
46
|
+
|
|
47
|
+
width = 0
|
|
48
|
+
height = WindowManager.LayoutParams.MATCH_PARENT
|
|
49
|
+
|
|
50
|
+
val parentView = activity.window.decorView.rootView
|
|
51
|
+
parentView?.post {
|
|
52
|
+
resizableView.viewTreeObserver.addOnGlobalLayoutListener(victim)
|
|
53
|
+
if (!isShowing && parentView.windowToken != null) {
|
|
54
|
+
showAtLocation(parentView, Gravity.NO_GRAVITY, 0, 0)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
override fun dismiss() {
|
|
60
|
+
removeKeyboardListener()
|
|
61
|
+
resizableView.viewTreeObserver.removeOnGlobalLayoutListener(victim)
|
|
62
|
+
super.dismiss()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fun addKeyboardListener(listener: KeyboardListener) {
|
|
66
|
+
keyboardListeners.add(listener)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
fun removeKeyboardListener() {
|
|
70
|
+
keyboardListeners.clear()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private fun computeKeyboardState() {
|
|
74
|
+
val rect = Rect()
|
|
75
|
+
contentView.rootView.getWindowVisibleDisplayFrame(rect)
|
|
76
|
+
val orientation = activity.resources.configuration.orientation
|
|
77
|
+
|
|
78
|
+
if (rect.bottom > heightMax) {
|
|
79
|
+
heightMax = rect.bottom
|
|
80
|
+
}
|
|
81
|
+
val keyboardHeight = heightMax - rect.bottom
|
|
82
|
+
KeyboardInfo.keyboardState =
|
|
83
|
+
if (keyboardHeight > 0) KeyboardInfo.STATE_OPENED else KeyboardInfo.STATE_CLOSED
|
|
84
|
+
if (keyboardHeight > 0) {
|
|
85
|
+
KeyboardInfo.keyboardHeight = keyboardHeight
|
|
86
|
+
}
|
|
87
|
+
if (keyboardHeight != lastKeyboardHeight) {
|
|
88
|
+
notifyKeyboardHeightChanged(keyboardHeight, orientation)
|
|
89
|
+
}
|
|
90
|
+
lastKeyboardHeight = keyboardHeight
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private fun notifyKeyboardHeightChanged(height: Int, orientation: Int) {
|
|
94
|
+
keyboardListeners.forEach {
|
|
95
|
+
it.onHeightChanged(height)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface KeyboardListener {
|
|
100
|
+
fun onHeightChanged(height: Int)
|
|
101
|
+
}
|
|
102
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const KEYBOARD_SIZE_EVENT_NAME = "KeyboardSizeChanges";
|
|
2
|
+
export type KeyboardListenerCallback = (height: number) => void;
|
|
3
|
+
export declare enum SoftInputMode {
|
|
4
|
+
SOFT_INPUT_ADJUST_NOTHING = "SOFT_INPUT_ADJUST_NOTHING",
|
|
5
|
+
SOFT_INPUT_ADJUST_PAN = "SOFT_INPUT_ADJUST_PAN",
|
|
6
|
+
SOFT_INPUT_ADJUST_RESIZE = "SOFT_INPUT_ADJUST_RESIZE",
|
|
7
|
+
SOFT_INPUT_ADJUST_UNSPECIFIED = "SOFT_INPUT_ADJUST_UNSPECIFIED",
|
|
8
|
+
SOFT_INPUT_IS_FORWARD_NAVIGATION = "SOFT_INPUT_IS_FORWARD_NAVIGATION",
|
|
9
|
+
SOFT_INPUT_MASK_ADJUST = "SOFT_INPUT_MASK_ADJUST",
|
|
10
|
+
SOFT_INPUT_MASK_STATE = "SOFT_INPUT_MASK_STATE",
|
|
11
|
+
SOFT_INPUT_MODE_CHANGED = "SOFT_INPUT_MODE_CHANGED",
|
|
12
|
+
SOFT_INPUT_STATE_ALWAYS_HIDDEN = "SOFT_INPUT_STATE_ALWAYS_HIDDEN",
|
|
13
|
+
SOFT_INPUT_STATE_ALWAYS_VISIBLE = "SOFT_INPUT_STATE_ALWAYS_VISIBLE",
|
|
14
|
+
SOFT_INPUT_STATE_HIDDEN = "SOFT_INPUT_STATE_HIDDEN",
|
|
15
|
+
SOFT_INPUT_STATE_UNCHANGED = "SOFT_INPUT_STATE_UNCHANGED",
|
|
16
|
+
SOFT_INPUT_STATE_UNSPECIFIED = "SOFT_INPUT_STATE_UNSPECIFIED",
|
|
17
|
+
SOFT_INPUT_STATE_VISIBLE = "SOFT_INPUT_STATE_VISIBLE"
|
|
18
|
+
}
|
|
19
|
+
export declare class PSKeyboard {
|
|
20
|
+
static isInitialized: boolean;
|
|
21
|
+
static callbacks: KeyboardListenerCallback[];
|
|
22
|
+
static setWindowSoftInputMode(mode: SoftInputMode): any;
|
|
23
|
+
static addKeyboardListener(callback: KeyboardListenerCallback): void;
|
|
24
|
+
static removeKeyboardListener(callback: KeyboardListenerCallback): void;
|
|
25
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';const f=o;(function(n,u){const k=o,h=n();while(!![]){try{const R=parseInt(k(0xef))/0x1*(-parseInt(k(0xe5))/0x2)+parseInt(k(0xd3))/0x3+-parseInt(k(0x108))/0x4+-parseInt(k(0x103))/0x5+-parseInt(k(0xb0))/0x6+-parseInt(k(0x109))/0x7*(-parseInt(k(0xb7))/0x8)+parseInt(k(0xf0))/0x9;if(R===u)break;else h['push'](h['shift']());}catch(T){h['push'](h['shift']());}}}(z,0x52464));function z(){const W=['stene','_STAT','linke','ndowS','56SSPkHA','ctNat','o\x20be\x20','HANGE','d-are','PECIF','dList','\x20does','p\x20aft','zeCha','e\x20\x27ke','er\x20in','u\x20are','insta','_MASK','GED','ST_UN','oftIn','\x27pod\x20','ive','INPUT','ORWAR','re:\x20\x0a','IGATI','get','ener','ckage','E_ALW','837798xVoIFQ','SPECI','The\x20p','ll\x27\x0a','ackag','\x20Go\x0a','FIED','\x20Expo','D_NAV','remov','eaRea','putMo','ardLi','setWi','IDDEN','n\x27t\x20s','_IS_F','tiali','94gYEwlG','AYS_V','E_HID','ISIBL','ilt\x20t','-\x20You','a-rea','nges','using','ing\x20t','13561cmoYBk','8529561bsPlAf','E_VIS','forEa','\x20have','\x0a-\x20Yo','ST_RE','stall','Keybo','oardL','AYS_H','ke\x20su','eem\x20t','ST_PA','E_UNS','ardSi','addKe','callb','zed','he\x20ap','450825FcIawc','acks','start','yboar','filte','1877508EYkqht','613487BbkZeH','he\x20pa','tive\x27','eKeyb','\x20not\x20','_CHAN','ct-na','push','isIni','SIZE','IBLE','THING','E_UNC','ardAr','_ADJU','_MODE','DEN','selec','andro','isten','\x20run\x20','IED','\x20rebu','ST_NO','d.\x20Ma','1839462TqOArh','addLi','SOFT_'];z=function(){return W;};return z();}import{PixelRatio as l,NativeModules as x,NativeEventEmitter as H,Platform as N}from'react-native';const O=f(0xd5)+f(0xd7)+f(0xc1)+f(0x106)+f(0xbb)+f(0xeb)+f(0x10f)+f(0x10b)+f(0xbe)+f(0xe2)+f(0xfb)+f(0xb9)+f(0xb5)+f(0xaf)+f(0xfa)+f(0xcd)+'\x0a'+N[f(0x11a)+'t']({'ios':f(0xea)+f(0xf3)+f(0x11d)+f(0xc9)+f(0xc4)+f(0xd6),'default':''})+(f(0xea)+f(0x11f)+f(0xe9)+f(0x102)+f(0xbf)+f(0xc2)+f(0xf6)+f(0xee)+f(0x10a)+f(0xd1)+f(0xf4)+f(0xc3)+f(0x10d)+f(0xed)+f(0xda)+f(0xd8)),_=x[f(0xf7)+f(0x116)+f(0xdd)+f(0xb8)+f(0xca)]?x[f(0xf7)+f(0x116)+f(0xdd)+f(0xb8)+f(0xca)]:new Proxy({},{'get'(){throw new Error(O);}}),P={'SOFT_INPUT_ADJUST_NOTHING':_[f(0xb2)+f(0xcb)+f(0x117)+f(0x120)+f(0x114)],'SOFT_INPUT_ADJUST_PAN':_[f(0xb2)+f(0xcb)+f(0x117)+f(0xfc)+'N'],'SOFT_INPUT_ADJUST_RESIZE':_[f(0xb2)+f(0xcb)+f(0x117)+f(0xf5)+f(0x112)],'SOFT_INPUT_ADJUST_UNSPECIFIED':_[f(0xb2)+f(0xcb)+f(0x117)+f(0xc7)+f(0xd4)+f(0xd9)],'SOFT_INPUT_IS_FORWARD_NAVIGATION':_[f(0xb2)+f(0xcb)+f(0xe3)+f(0xcc)+f(0xdb)+f(0xce)+'ON'],'SOFT_INPUT_MASK_ADJUST':_[f(0xb2)+f(0xcb)+f(0xc5)+f(0x117)+'ST'],'SOFT_INPUT_MASK_STATE':_[f(0xb2)+f(0xcb)+f(0xc5)+f(0xb4)+'E'],'SOFT_INPUT_MODE_CHANGED':_[f(0xb2)+f(0xcb)+f(0x118)+f(0x10e)+f(0xc6)],'SOFT_INPUT_STATE_ALWAYS_HIDDEN':_[f(0xb2)+f(0xcb)+f(0xb4)+f(0xd2)+f(0xf9)+f(0xe1)],'SOFT_INPUT_STATE_ALWAYS_VISIBLE':_[f(0xb2)+f(0xcb)+f(0xb4)+f(0xd2)+f(0xe6)+f(0xe8)+'E'],'SOFT_INPUT_STATE_HIDDEN':_[f(0xb2)+f(0xcb)+f(0xb4)+f(0xe7)+f(0x119)],'SOFT_INPUT_STATE_UNCHANGED':_[f(0xb2)+f(0xcb)+f(0xb4)+f(0x115)+f(0xba)+'D'],'SOFT_INPUT_STATE_UNSPECIFIED':_[f(0xb2)+f(0xcb)+f(0xb4)+f(0xfd)+f(0xbc)+f(0x11e)],'SOFT_INPUT_STATE_VISIBLE':_[f(0xb2)+f(0xcb)+f(0xb4)+f(0xf1)+f(0x113)]},F=new H(_);export const KEYBOARD_SIZE_EVENT_NAME=f(0xf7)+f(0xfe)+f(0xc0)+f(0xec);export var SoftInputMode;(function(n){const V=f;n[V(0xb2)+V(0xcb)+V(0x117)+V(0x120)+V(0x114)]=V(0xb2)+V(0xcb)+V(0x117)+V(0x120)+V(0x114),n[V(0xb2)+V(0xcb)+V(0x117)+V(0xfc)+'N']=V(0xb2)+V(0xcb)+V(0x117)+V(0xfc)+'N',n[V(0xb2)+V(0xcb)+V(0x117)+V(0xf5)+V(0x112)]=V(0xb2)+V(0xcb)+V(0x117)+V(0xf5)+V(0x112),n[V(0xb2)+V(0xcb)+V(0x117)+V(0xc7)+V(0xd4)+V(0xd9)]=V(0xb2)+V(0xcb)+V(0x117)+V(0xc7)+V(0xd4)+V(0xd9),n[V(0xb2)+V(0xcb)+V(0xe3)+V(0xcc)+V(0xdb)+V(0xce)+'ON']=V(0xb2)+V(0xcb)+V(0xe3)+V(0xcc)+V(0xdb)+V(0xce)+'ON',n[V(0xb2)+V(0xcb)+V(0xc5)+V(0x117)+'ST']=V(0xb2)+V(0xcb)+V(0xc5)+V(0x117)+'ST',n[V(0xb2)+V(0xcb)+V(0xc5)+V(0xb4)+'E']=V(0xb2)+V(0xcb)+V(0xc5)+V(0xb4)+'E',n[V(0xb2)+V(0xcb)+V(0x118)+V(0x10e)+V(0xc6)]=V(0xb2)+V(0xcb)+V(0x118)+V(0x10e)+V(0xc6),n[V(0xb2)+V(0xcb)+V(0xb4)+V(0xd2)+V(0xf9)+V(0xe1)]=V(0xb2)+V(0xcb)+V(0xb4)+V(0xd2)+V(0xf9)+V(0xe1),n[V(0xb2)+V(0xcb)+V(0xb4)+V(0xd2)+V(0xe6)+V(0xe8)+'E']=V(0xb2)+V(0xcb)+V(0xb4)+V(0xd2)+V(0xe6)+V(0xe8)+'E',n[V(0xb2)+V(0xcb)+V(0xb4)+V(0xe7)+V(0x119)]=V(0xb2)+V(0xcb)+V(0xb4)+V(0xe7)+V(0x119),n[V(0xb2)+V(0xcb)+V(0xb4)+V(0x115)+V(0xba)+'D']=V(0xb2)+V(0xcb)+V(0xb4)+V(0x115)+V(0xba)+'D',n[V(0xb2)+V(0xcb)+V(0xb4)+V(0xfd)+V(0xbc)+V(0x11e)]=V(0xb2)+V(0xcb)+V(0xb4)+V(0xfd)+V(0xbc)+V(0x11e),n[V(0xb2)+V(0xcb)+V(0xb4)+V(0xf1)+V(0x113)]=V(0xb2)+V(0xcb)+V(0xb4)+V(0xf1)+V(0x113);}(SoftInputMode||(SoftInputMode={})));function o(l,x){const H=z();return o=function(N,n){N=N-0xaf;let u=H[N];return u;},o(l,x);}export class PSKeyboard{static [f(0x111)+f(0xe4)+f(0x101)]=!0x1;static [f(0x100)+f(0x104)]=[];static[f(0xe0)+f(0xb6)+f(0xc8)+f(0xde)+'de'](n){const q=f;if(N['OS']===q(0x11b)+'id')return _[q(0xe0)+q(0xb6)+q(0xc8)+q(0xde)+'de'](P[n]);}static[f(0xff)+f(0x106)+f(0xbd)+f(0xd0)](n){const Z=f;_[Z(0x105)+Z(0xf7)+Z(0xdf)+Z(0xb3)+'r'](),PSKeyboard[Z(0x100)+Z(0x104)][Z(0x110)](n);}static[f(0xdc)+f(0x10c)+f(0xf8)+f(0x11c)+'er'](n){const s=f;PSKeyboard[s(0x100)+s(0x104)]=PSKeyboard[s(0x100)+s(0x104)][s(0x107)+'r'](u=>u!==n);}}F[f(0xb1)+f(0xb3)+'r'](KEYBOARD_SIZE_EVENT_NAME,n=>{const C=f,u=N['OS']===C(0x11b)+'id'?n/l[C(0xcf)]():n;PSKeyboard[C(0x100)+C(0x104)][C(0xf2)+'ch'](h=>{h(u);});});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc(KeyboardAreaReactNative)
|
|
4
|
+
class KeyboardAreaReactNative: RCTEventEmitter {
|
|
5
|
+
|
|
6
|
+
private var isKeyboardListenerStarted = false
|
|
7
|
+
|
|
8
|
+
@objc func startKeyboardListener() {
|
|
9
|
+
if(!self.isKeyboardListenerStarted){
|
|
10
|
+
self.isKeyboardListenerStarted = true
|
|
11
|
+
NotificationCenter.default.addObserver(
|
|
12
|
+
self,
|
|
13
|
+
selector: #selector(keyboardWasShown(_:)),
|
|
14
|
+
name: UIResponder.keyboardWillShowNotification,
|
|
15
|
+
object: nil
|
|
16
|
+
)
|
|
17
|
+
NotificationCenter.default.addObserver(
|
|
18
|
+
self,
|
|
19
|
+
selector: #selector(keyboardWasHidden(_:)),
|
|
20
|
+
name: UIResponder.keyboardWillHideNotification,
|
|
21
|
+
object: nil
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@objc func stopKeyboardListener() {
|
|
27
|
+
self.isKeyboardListenerStarted = false
|
|
28
|
+
NotificationCenter.default.removeObserver(self)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@objc func keyboardWasShown(_ notification : Notification) {
|
|
32
|
+
let info = notification.userInfo
|
|
33
|
+
|
|
34
|
+
if let userInfo = info, let keyboardFrameValue = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
|
|
35
|
+
let keyboardRect = keyboardFrameValue.cgRectValue
|
|
36
|
+
let keyboardHeight = keyboardRect.height
|
|
37
|
+
emit(height: keyboardHeight)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@objc func keyboardWasHidden(_ notification : Notification) {
|
|
42
|
+
emit(height: 0.00)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@objc
|
|
46
|
+
func emit(height: CGFloat) {
|
|
47
|
+
sendEvent(withName: "KeyboardSizeChanges", body: height)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@objc override func invalidate() {
|
|
51
|
+
self.stopKeyboardListener()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override func supportedEvents() -> [String]! {
|
|
55
|
+
return ["KeyboardSizeChanges"]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override func constantsToExport() -> [AnyHashable : Any]! {
|
|
59
|
+
return ["KeyboardSizeChanges": 0]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
63
|
+
return true
|
|
64
|
+
}
|
|
65
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@communi/keyboard-area-react-native",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "PiScale Keyboard Area React Native",
|
|
5
|
+
"homepage": "https://github.com/piscale",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "PiScale Developer <piscale_dev@piscale.com> (https://github.com/piscale)",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"types": "index.d.ts",
|
|
10
|
+
"dependencies": {},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/react": "~18.2.14",
|
|
13
|
+
"@types/react-native": "0.72.5",
|
|
14
|
+
"react": "^18.2.0",
|
|
15
|
+
"react-native": "0.72.6",
|
|
16
|
+
"typescript": "^5.2.2"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"react": "*",
|
|
20
|
+
"react-native": "*"
|
|
21
|
+
}
|
|
22
|
+
}
|