@react-native-ohos/react-native-keyboard-controller 1.12.8-rc.5 → 1.12.8-rc.6
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/harmony/keyboard_controller/BuildProfile.ets +16 -16
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/.ts_checker_cache +5166 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/.tsbuildinfo +1 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/.tsbuildinfo.linter +1 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/compileInfo.json +1 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/compiler.cache/modules/Index.ets-96716712ed80a95f9b3cb8c16433a37c.msgpack +0 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/compiler.cache/modules/Logger.ts-21e5e905df1c99fc6e6ca37bbbfcb51e.msgpack +0 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/compiler.cache/modules/RNKeyboardControllerPackage.ets-c2108552e32e54da4e2ee2cd039239a4.msgpack +0 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/compiler.cache/modules/RNKeyboardControllerTurboModule.ts-7c42679e7e488d1a60c8b4d54f079abb.msgpack +0 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/compiler.cache/modules/RNStatusBarManagerCompatTurboModule.ts-c9b80946df3cc584c8042691aeb9fbb1.msgpack +0 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/compiler.cache/modules/Type.ts-8709f2f912199ff74f40eb894b697a77.msgpack +0 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/compiler.cache/modules/ts.ets-70cab636273e777c0f945b068fe2fec4.msgpack +0 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/compiler.cache/other/pkgName2SourceRoots.msgpack +1 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/compiler.cache/plugins/plugins.msgpack +0 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/dep_info.json +1 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/BuildProfile.ets +17 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/Index.ets +9 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/ResourceTable.txt +1 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/build-profile.json5 +31 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/consumer-rules.txt +0 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/hvigorfile.ts +6 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/obfuscation-rules.txt +18 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/oh-package-lock.json5 +20 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/oh-package.json5 +1 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/CMakeLists.txt +7 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/EventEmitters.cpp +96 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/EventEmitters.h +90 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/KeyboardControllerViewComponentDescriptor.h +77 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/KeyboardControllerViewComponentInstance.cpp +158 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/KeyboardControllerViewComponentInstance.h +74 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/KeyboardControllerViewJSIBinder.h +43 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/KeyboardGestureAreaComponentDescriptor.h +64 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +89 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/KeyboardGestureAreaComponentInstance.h +63 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/KeyboardGestureAreaJSIBinder.h +39 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/RNKeyboardController.cpp +25 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/RNKeyboardController.h +27 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/RNKeyboardControllerPackage.cpp +43 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/RNKeyboardControllerPackage.h +56 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/RNStatusBarManagerCompat.cpp +24 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/RNStatusBarManagerCompat.h +28 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/keyboardControllerPackage.cpp +43 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/cpp/keyboardControllerPackage.h +56 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/ets/Logger.ts +46 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/ets/RNKeyboardControllerPackage.ets +46 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/ets/RNKeyboardControllerTurboModule.ts +210 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/ets/RNStatusBarManagerCompatTurboModule.ts +98 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/ets/Type.ts +41 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/module.json +32 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/resources/base/element/string.json +8 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/keyboard_controller/build/default/cache/default/default@PackageHar/ts.ets +9 -0
- package/harmony/keyboard_controller/build/default/generated/pm/default/oh-package.json5 +1 -0
- package/harmony/keyboard_controller/build/default/generated/r/default/ResourceTable.h +24 -0
- package/harmony/keyboard_controller/build/default/intermediates/loader/default/loader.json +28 -0
- package/harmony/keyboard_controller/build/default/intermediates/merge_profile/default/module.json +29 -0
- package/harmony/keyboard_controller/build/default/intermediates/patch/default/base_native_libs.json +1 -0
- package/harmony/keyboard_controller/build/default/intermediates/process_profile/default/module.json +32 -0
- package/harmony/keyboard_controller/build/default/intermediates/res/default/ResourceTable.txt +1 -0
- package/harmony/keyboard_controller/build/default/intermediates/res/default/ark_module.json +1 -0
- package/harmony/keyboard_controller/build/default/intermediates/res/default/ids_map/id_defined.json +7 -0
- package/harmony/keyboard_controller/build/default/intermediates/res/default/module.json +28 -0
- package/harmony/keyboard_controller/build/default/intermediates/res/default/opt-compression.json +1 -0
- package/harmony/keyboard_controller/build/default/intermediates/res/default/resConfig.json +1 -0
- package/harmony/keyboard_controller/build/default/intermediates/res/default/resources.index +0 -0
- package/harmony/keyboard_controller/build/default/outputs/default/keyboard_controller.har +0 -0
- package/harmony/keyboard_controller/oh-package-lock.json5 +20 -0
- package/harmony/keyboard_controller/oh-package.json5 +2 -2
- package/harmony/keyboard_controller.har +0 -0
- package/lib/commonjs/animated.js +11 -2
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/module/animated.js +12 -3
- package/lib/module/animated.js.map +1 -1
- package/package.json +1 -1
- package/src/animated.tsx +6 -3
- package/harmony/.idea/harmony.iml +0 -8
- package/harmony/.idea/modules.xml +0 -8
- package/harmony/.idea/vcs.xml +0 -6
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {TurboModulesFactory} from '@rnoh/react-native-openharmony/ts';
|
|
8
|
+
import type { TurboModule, TurboModuleContext, } from '@rnoh/react-native-openharmony/ts';
|
|
9
|
+
import {RNKeyboardControllerTurboModule} from './RNKeyboardControllerTurboModule';
|
|
10
|
+
import {RNStatusBarManagerCompatTurboModule} from './RNStatusBarManagerCompatTurboModule';
|
|
11
|
+
import { RNOHPackage } from '@rnoh/react-native-openharmony'
|
|
12
|
+
|
|
13
|
+
class RNKeyboardControllerTurboModuleFactory extends TurboModulesFactory {
|
|
14
|
+
createTurboModule(name: string): TurboModule | null {
|
|
15
|
+
if (this.hasTurboModule(name)) {
|
|
16
|
+
return new RNKeyboardControllerTurboModule(this.ctx);
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
hasTurboModule(name: string): boolean {
|
|
21
|
+
return name === 'KeyboardController';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
class RNStatusBarManagerCompatTurboModuleFactory extends TurboModulesFactory {
|
|
26
|
+
createTurboModule(name: string): TurboModule | null {
|
|
27
|
+
if(this.hasTurboModule(name)){
|
|
28
|
+
return new RNStatusBarManagerCompatTurboModule(this.ctx);
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
hasTurboModule(name: string): boolean {
|
|
33
|
+
return name === 'StatusBarManagerCompat';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class RNKeyboardControllerPackage extends RNOHPackage {
|
|
38
|
+
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
|
|
39
|
+
return new RNKeyboardControllerTurboModuleFactory(ctx);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class RNStatusBarManagerCompatPackage extends RNOHPackage {
|
|
43
|
+
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
|
|
44
|
+
return new RNStatusBarManagerCompatTurboModuleFactory(ctx);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { TurboModule } from "@rnoh/react-native-openharmony/ts";
|
|
8
|
+
import common from '@ohos.app.ability.common';
|
|
9
|
+
import window from '@ohos.window';
|
|
10
|
+
import inputMethod from '@ohos.inputMethod';
|
|
11
|
+
import Logger from './Logger';
|
|
12
|
+
import { KeyboardControllerEventName, KeyboardStatusType } from './Type';
|
|
13
|
+
import { BusinessError } from '@kit.BasicServicesKit';
|
|
14
|
+
import { JSON } from '@kit.ArkTS';
|
|
15
|
+
|
|
16
|
+
declare function px2vp(px: number): number;
|
|
17
|
+
|
|
18
|
+
interface RNKeyboardControllerSpec {
|
|
19
|
+
getConstants(): {};
|
|
20
|
+
|
|
21
|
+
setInputMode(mode: number): void;
|
|
22
|
+
|
|
23
|
+
setDefaultMode(): void;
|
|
24
|
+
|
|
25
|
+
dismiss(): void;
|
|
26
|
+
|
|
27
|
+
setFocusTo(direction: string): void;
|
|
28
|
+
|
|
29
|
+
addListener(eventName: string, listener: (event) => void,): void;
|
|
30
|
+
|
|
31
|
+
removeListeners(count: number): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class RNKeyboardControllerTurboModule extends TurboModule implements RNKeyboardControllerSpec {
|
|
35
|
+
private context: common.UIAbilityContext;
|
|
36
|
+
private keyboardHeight: number;
|
|
37
|
+
private keyboardStatus: KeyboardStatusType;
|
|
38
|
+
private eventListeners: KeyboardControllerEventName[];
|
|
39
|
+
private currentWindow:window.Window;
|
|
40
|
+
private enabled:boolean;
|
|
41
|
+
constructor(ctx) {
|
|
42
|
+
super(ctx);
|
|
43
|
+
this.context = this.ctx.uiAbilityContext;
|
|
44
|
+
this.eventListeners = this.supportListeners();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
readonly getConstants: () => {};
|
|
48
|
+
|
|
49
|
+
// set mode
|
|
50
|
+
setInputMode(mode: number): void {
|
|
51
|
+
Logger.info('harmonyOS not support setInputMode')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
setDefaultMode(): void {
|
|
55
|
+
Logger.info('harmonyOS not support setDefaultMode')
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @description 键盘隐藏
|
|
60
|
+
* */
|
|
61
|
+
dismiss(): void {
|
|
62
|
+
let inputMethodController = inputMethod.getController();
|
|
63
|
+
inputMethodController.stopInputSession()
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @description 键盘隐藏
|
|
68
|
+
* */
|
|
69
|
+
private show(): void {
|
|
70
|
+
let inputMethodController = inputMethod.getController();
|
|
71
|
+
inputMethodController.showSoftKeyboard()
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
setFocusTo(direction: string): void {
|
|
76
|
+
this.ctx.rnInstance.postMessageToCpp('setFocusTo', direction);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @description 添加监听键盘事件
|
|
81
|
+
*/
|
|
82
|
+
addListener(eventName: KeyboardControllerEventName) {
|
|
83
|
+
let supportEvents = this.supportListeners()
|
|
84
|
+
let bo = supportEvents.includes(eventName)
|
|
85
|
+
if (bo && !this.eventListeners.includes(eventName)) {
|
|
86
|
+
this.eventListeners.push(eventName)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @description 删除监听事件
|
|
92
|
+
* */
|
|
93
|
+
removeListeners(count: number): void {
|
|
94
|
+
let num = this.eventListeners.length;
|
|
95
|
+
if (num>0) {
|
|
96
|
+
this.eventListeners = [];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private supportListeners() {
|
|
101
|
+
return [
|
|
102
|
+
KeyboardControllerEventName.KEYBOARD_WILL_SHOW,
|
|
103
|
+
KeyboardControllerEventName.KEYBOARD_DID_SHOW,
|
|
104
|
+
KeyboardControllerEventName.KEYBOARD_WILL_HIDE,
|
|
105
|
+
KeyboardControllerEventName.KEYBOARD_DID_HIDE,
|
|
106
|
+
KeyboardControllerEventName.FOCUS_DID_SET
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private async setWindowSystemBarEnable(statusBarTranslucent: boolean, navigationBarTranslucent: boolean) {
|
|
111
|
+
|
|
112
|
+
let windowInstance: window.Window | undefined = undefined;
|
|
113
|
+
windowInstance = await window.getLastWindow(this.context);
|
|
114
|
+
let systemBarProperty = windowInstance.getWindowSystemBarProperties();
|
|
115
|
+
let newSystemBarProperty: window.SystemBarProperties = {
|
|
116
|
+
...systemBarProperty,
|
|
117
|
+
statusBarColor: statusBarTranslucent ? "#00000000" : systemBarProperty.statusBarColor,
|
|
118
|
+
navigationBarColor: navigationBarTranslucent ? "#00000000" : systemBarProperty.navigationBarColor
|
|
119
|
+
};
|
|
120
|
+
try {
|
|
121
|
+
let promise = windowInstance.setWindowSystemBarProperties(newSystemBarProperty);
|
|
122
|
+
promise.then(() => {
|
|
123
|
+
Logger.info('Succeeded in setting the system bar properties.');
|
|
124
|
+
}).catch((err: BusinessError) => {
|
|
125
|
+
Logger.error(`Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
|
|
126
|
+
});
|
|
127
|
+
} catch (exception) {
|
|
128
|
+
Logger.error(`Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private keyboardControllerEventHandle(keyboardStatus: number, height: number) {
|
|
133
|
+
Logger.info('###turboModule keyboardControllerEventHandle', String(keyboardStatus) + ',' + String(height));
|
|
134
|
+
if(!this.enabled){
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (this.keyboardStatus == KeyboardStatusType.HIDE) {
|
|
139
|
+
// 键盘隐藏
|
|
140
|
+
Logger.info('###turboModule keyboardControllerEventHandle');
|
|
141
|
+
this.eventListeners.includes(KeyboardControllerEventName.KEYBOARD_DID_HIDE) &&
|
|
142
|
+
this.ctx.rnInstance.emitDeviceEvent(KeyboardControllerEventName.KEYBOARD_DID_HIDE, {
|
|
143
|
+
duration: 0,
|
|
144
|
+
timestamp: new Date().getTime(),
|
|
145
|
+
target: 0,
|
|
146
|
+
height: height,
|
|
147
|
+
tag:0
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (this.keyboardStatus == KeyboardStatusType.SHOW) {
|
|
151
|
+
// 键盘显示
|
|
152
|
+
Logger.info('###turboModule keyboardControllerEventHandle');
|
|
153
|
+
this.eventListeners.includes(KeyboardControllerEventName.KEYBOARD_DID_SHOW) &&
|
|
154
|
+
this.ctx.rnInstance.emitDeviceEvent(KeyboardControllerEventName.KEYBOARD_DID_SHOW, {
|
|
155
|
+
duration: 0,
|
|
156
|
+
timestamp: new Date().getTime(),
|
|
157
|
+
target: 0,
|
|
158
|
+
height:height,
|
|
159
|
+
tag:0
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private async startKeyboardObserver(open:boolean) {
|
|
165
|
+
Logger.info("###turboModule startKeyboardObserver",String(open));
|
|
166
|
+
this.enabled=open;
|
|
167
|
+
this.currentWindow = await window.getLastWindow(this.context);
|
|
168
|
+
if (!this.currentWindow) {
|
|
169
|
+
throw ('windowInstance is null')
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
if(!open){
|
|
173
|
+
try {
|
|
174
|
+
Logger.info("###turboModule Close KeyboardObserver");
|
|
175
|
+
this.currentWindow.off('keyboardHeightChange', (data) => {
|
|
176
|
+
this.keyboardStatus = KeyboardStatusType.HIDE;
|
|
177
|
+
this.keyboardHeight = 0;
|
|
178
|
+
Logger.info('### close keyboardHeightChange observer');
|
|
179
|
+
});
|
|
180
|
+
} catch (exception) {
|
|
181
|
+
Logger.error('### Failed to close the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
|
|
182
|
+
}
|
|
183
|
+
}else{
|
|
184
|
+
try {
|
|
185
|
+
this.currentWindow.on('keyboardHeightChange', (data) => {
|
|
186
|
+
const keyboardAvoidArea = this.currentWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD).bottomRect;
|
|
187
|
+
let height = Math.ceil(px2vp(keyboardAvoidArea.height))
|
|
188
|
+
if(open){
|
|
189
|
+
if(this.keyboardHeight == height ){
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
if (height > 0) {
|
|
193
|
+
this.keyboardStatus = KeyboardStatusType.SHOW;
|
|
194
|
+
} else {
|
|
195
|
+
this.keyboardStatus = KeyboardStatusType.HIDE;
|
|
196
|
+
}
|
|
197
|
+
this.keyboardHeight = height;
|
|
198
|
+
this.keyboardControllerEventHandle(this.keyboardStatus, height);
|
|
199
|
+
this.ctx.rnInstance.postMessageToCpp('keyboardHeightChange', height);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
});
|
|
203
|
+
} catch (exception) {
|
|
204
|
+
Logger.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { TurboModule } from "@rnoh/react-native-openharmony/ts";
|
|
8
|
+
import window from '@ohos.window';
|
|
9
|
+
import common from '@ohos.app.ability.common';
|
|
10
|
+
import { BusinessError } from '@kit.BasicServicesKit';
|
|
11
|
+
import Logger from './Logger';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
interface StatusBarManagerCompatSpec {
|
|
15
|
+
getConstants(): {};
|
|
16
|
+
setHidden(hidden: boolean): void;
|
|
17
|
+
setColor(color: number, animated: boolean): void;
|
|
18
|
+
setTranslucent(translucent: boolean): void;
|
|
19
|
+
setStyle(style: string): void;
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
export class RNStatusBarManagerCompatTurboModule extends TurboModule implements StatusBarManagerCompatSpec{
|
|
23
|
+
private context: common.UIAbilityContext;
|
|
24
|
+
constructor(ctx) {
|
|
25
|
+
super(ctx);
|
|
26
|
+
this.context = this.ctx.uiAbilityContext;
|
|
27
|
+
}
|
|
28
|
+
private async setWindowSystemBarProperties(properties:window.SystemBarProperties){
|
|
29
|
+
let windowInstance: window.Window | undefined = undefined;
|
|
30
|
+
windowInstance = await window.getLastWindow(this.context);
|
|
31
|
+
let systemBarProperty = windowInstance.getWindowSystemBarProperties();
|
|
32
|
+
let newSystemBarProperty: window.SystemBarProperties = {
|
|
33
|
+
...systemBarProperty,
|
|
34
|
+
...properties
|
|
35
|
+
};
|
|
36
|
+
try {
|
|
37
|
+
let promise = windowInstance.setWindowSystemBarProperties(newSystemBarProperty);
|
|
38
|
+
promise.then(() => {
|
|
39
|
+
Logger.info('Succeeded in setting the system bar properties.');
|
|
40
|
+
}).catch((err: BusinessError) => {
|
|
41
|
+
Logger.error(`Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
|
|
42
|
+
});
|
|
43
|
+
} catch (exception) {
|
|
44
|
+
Logger.error(`Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
readonly getConstants:()=>{};
|
|
48
|
+
// set mode
|
|
49
|
+
async setHidden(hidden: boolean): Promise<void> {
|
|
50
|
+
Logger.info("###turboModule setHidden");
|
|
51
|
+
let windowInstance: window.Window | undefined = undefined;
|
|
52
|
+
windowInstance = await window.getLastWindow(this.context);
|
|
53
|
+
let names: Array<'status' | 'navigation'> = ['navigation'];
|
|
54
|
+
hidden && names.push('status');
|
|
55
|
+
try {
|
|
56
|
+
let promise = windowInstance.setWindowSystemBarEnable(names);
|
|
57
|
+
promise.then(() => {
|
|
58
|
+
Logger.info('Succeeded in setting the system bar to be invisible.');
|
|
59
|
+
}).catch((err: BusinessError) => {
|
|
60
|
+
Logger.error(`Failed to set the system bar to be invisible. Cause code: ${err.code}, message: ${err.message}`);
|
|
61
|
+
});
|
|
62
|
+
} catch (exception) {
|
|
63
|
+
Logger.error(`Failed to set the system bar to be invisible. Cause code: ${exception.code}, message: ${exception.message}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async setColor(color: number, animated: boolean): Promise<void> {
|
|
68
|
+
Logger.info("###turboModule setColor");
|
|
69
|
+
let newSystemBarProperty: window.SystemBarProperties = {
|
|
70
|
+
statusBarColor: color.toString(),
|
|
71
|
+
enableStatusBarAnimation:animated
|
|
72
|
+
};
|
|
73
|
+
this.setWindowSystemBarProperties(newSystemBarProperty)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async setTranslucent(translucent: boolean): Promise<void> {
|
|
77
|
+
Logger.info("###turboModule setTranslucent");
|
|
78
|
+
let windowInstance: window.Window | undefined = undefined;
|
|
79
|
+
windowInstance = await window.getLastWindow(this.context);
|
|
80
|
+
let systemBarProperty = windowInstance.getWindowSystemBarProperties();
|
|
81
|
+
let newSystemBarProperty: window.SystemBarProperties = {
|
|
82
|
+
statusBarColor:translucent?'#00000000':systemBarProperty.statusBarColor,
|
|
83
|
+
};
|
|
84
|
+
this.setWindowSystemBarProperties(newSystemBarProperty)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
setStyle(style: 'dark-content'|'light-content'): void {
|
|
88
|
+
Logger.info("###turboModule setStyle");
|
|
89
|
+
let themeFlag= style == "dark-content"
|
|
90
|
+
let newSystemBarProperty: window.SystemBarProperties = {
|
|
91
|
+
statusBarContentColor:themeFlag?"#000000":"#ffffff",
|
|
92
|
+
};
|
|
93
|
+
this.setWindowSystemBarProperties(newSystemBarProperty)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export enum KeyboardControllerEventName {
|
|
8
|
+
KEYBOARD_WILL_SHOW="KeyboardController::keyboardWillShow",
|
|
9
|
+
KEYBOARD_DID_SHOW="KeyboardController::keyboardDidShow",
|
|
10
|
+
KEYBOARD_WILL_HIDE="KeyboardController::keyboardWillHide",
|
|
11
|
+
KEYBOARD_DID_HIDE="KeyboardController::keyboardDidHide",
|
|
12
|
+
FOCUS_DID_SET="KeyboardController::focusDidSet"
|
|
13
|
+
}
|
|
14
|
+
export type KeyboardChangeResult = {
|
|
15
|
+
code:number;
|
|
16
|
+
message:string;
|
|
17
|
+
data:number | undefined
|
|
18
|
+
}
|
|
19
|
+
export type KeyboardEvent ={
|
|
20
|
+
height:number;
|
|
21
|
+
duration:number;
|
|
22
|
+
timestamp:number;
|
|
23
|
+
target:number;
|
|
24
|
+
}
|
|
25
|
+
export enum KeyboardStatusType {
|
|
26
|
+
HIDE = 0,
|
|
27
|
+
SHOW = 1
|
|
28
|
+
};
|
|
29
|
+
export type RawTouchPoint={
|
|
30
|
+
pointerId: number;
|
|
31
|
+
windowX: number;
|
|
32
|
+
windowY: number;
|
|
33
|
+
}
|
|
34
|
+
export type RawTouchEvent = {
|
|
35
|
+
action: number;
|
|
36
|
+
actionTouch: RawTouchPoint;
|
|
37
|
+
touchPoints: RawTouchPoint[];
|
|
38
|
+
sourceType: number;
|
|
39
|
+
timestamp: number;
|
|
40
|
+
rootTag:number;
|
|
41
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": {
|
|
3
|
+
"bundleName": "com.rnoh.reanimated",
|
|
4
|
+
"debug": true,
|
|
5
|
+
"versionCode": 1000000,
|
|
6
|
+
"versionName": "1.0.0",
|
|
7
|
+
"minAPIVersion": 50000012,
|
|
8
|
+
"targetAPIVersion": 50101019,
|
|
9
|
+
"apiReleaseType": "Release",
|
|
10
|
+
"targetMinorAPIVersion": 0,
|
|
11
|
+
"targetPatchAPIVersion": 0,
|
|
12
|
+
"compileSdkVersion": "6.0.0.47",
|
|
13
|
+
"compileSdkType": "HarmonyOS",
|
|
14
|
+
"appEnvironments": [],
|
|
15
|
+
"bundleType": "app",
|
|
16
|
+
"buildMode": "debug"
|
|
17
|
+
},
|
|
18
|
+
"module": {
|
|
19
|
+
"name": "keyboard_controller",
|
|
20
|
+
"type": "har",
|
|
21
|
+
"deviceTypes": [
|
|
22
|
+
"default",
|
|
23
|
+
"tablet",
|
|
24
|
+
"2in1"
|
|
25
|
+
],
|
|
26
|
+
"packageName": "@react-native-ohos/react-native-keyboard-controller",
|
|
27
|
+
"installationFree": false,
|
|
28
|
+
"virtualMachine": "ark12.0.2.0",
|
|
29
|
+
"compileMode": "esmodule",
|
|
30
|
+
"dependencies": []
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export * from './src/main/ets/RNKeyboardControllerPackage';
|
|
8
|
+
export * from './src/main/ets/RNKeyboardControllerTurboModule';
|
|
9
|
+
export * from './src/main/ets/RNStatusBarManagerCompatTurboModule';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@react-native-ohos/react-native-keyboard-controller","version":"1.12.8-rc.6","description":" control keyboard show or hide","main":"Index.ets","author":"","license":"MIT License","dependencies":{"@rnoh/react-native-openharmony":"file:../react_native_openharmony"}}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
#ifndef RESOURCE_TABLE_H
|
|
17
|
+
#define RESOURCE_TABLE_H
|
|
18
|
+
|
|
19
|
+
#include<stdint.h>
|
|
20
|
+
|
|
21
|
+
namespace OHOS {
|
|
22
|
+
const int32_t STRING_PAGE_SHOW = 0x02000000;
|
|
23
|
+
}
|
|
24
|
+
#endif
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"modulePathMap": {
|
|
3
|
+
"entry": "E:\\code\\reanimated\\tester\\harmony\\entry",
|
|
4
|
+
"keyboard_controller": "E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller",
|
|
5
|
+
"reanimated": "E:\\gitcode\\rntpc_react-native-reanimated\\tester\\harmony\\reanimated"
|
|
6
|
+
},
|
|
7
|
+
"compileMode": "esmodule",
|
|
8
|
+
"projectRootPath": "E:\\github\\react-native-keyboard-controller\\harmony",
|
|
9
|
+
"nodeModulesPath": "E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\build\\default\\intermediates\\loader_out\\default\\node_modules",
|
|
10
|
+
"byteCodeHarInfo": {},
|
|
11
|
+
"declarationEntry": [],
|
|
12
|
+
"moduleName": "keyboard_controller",
|
|
13
|
+
"hspNameOhmMap": {},
|
|
14
|
+
"harNameOhmMap": {},
|
|
15
|
+
"packageManagerType": "ohpm",
|
|
16
|
+
"compileEntry": [
|
|
17
|
+
"E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\src\\main\\ets\\Logger.ts",
|
|
18
|
+
"E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\src\\main\\ets\\RNKeyboardControllerPackage.ets",
|
|
19
|
+
"E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\src\\main\\ets\\RNKeyboardControllerTurboModule.ts",
|
|
20
|
+
"E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\src\\main\\ets\\RNStatusBarManagerCompatTurboModule.ts",
|
|
21
|
+
"E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\src\\main\\ets\\Type.ts"
|
|
22
|
+
],
|
|
23
|
+
"otherCompileFiles": [],
|
|
24
|
+
"dynamicImportLibInfo": {},
|
|
25
|
+
"routerMap": [],
|
|
26
|
+
"hspResourcesMap": {},
|
|
27
|
+
"updateVersionInfo": {}
|
|
28
|
+
}
|
package/harmony/keyboard_controller/build/default/intermediates/merge_profile/default/module.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": {
|
|
3
|
+
"bundleName": "com.rnoh.reanimated",
|
|
4
|
+
"debug": true,
|
|
5
|
+
"versionCode": 1000000,
|
|
6
|
+
"versionName": "1.0.0",
|
|
7
|
+
"minAPIVersion": 50000012,
|
|
8
|
+
"targetAPIVersion": 50101019,
|
|
9
|
+
"apiReleaseType": "Release",
|
|
10
|
+
"targetMinorAPIVersion": 0,
|
|
11
|
+
"targetPatchAPIVersion": 0,
|
|
12
|
+
"compileSdkVersion": "6.0.0.47",
|
|
13
|
+
"compileSdkType": "HarmonyOS",
|
|
14
|
+
"appEnvironments": [],
|
|
15
|
+
"bundleType": "app",
|
|
16
|
+
"buildMode": "debug"
|
|
17
|
+
},
|
|
18
|
+
"module": {
|
|
19
|
+
"name": "keyboard_controller",
|
|
20
|
+
"type": "har",
|
|
21
|
+
"deviceTypes": [
|
|
22
|
+
"default",
|
|
23
|
+
"tablet",
|
|
24
|
+
"2in1"
|
|
25
|
+
],
|
|
26
|
+
"packageName": "@react-native-ohos/react-native-keyboard-controller",
|
|
27
|
+
"installationFree": false
|
|
28
|
+
}
|
|
29
|
+
}
|
package/harmony/keyboard_controller/build/default/intermediates/patch/default/base_native_libs.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"libs":{},"stripped":{}}
|
package/harmony/keyboard_controller/build/default/intermediates/process_profile/default/module.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": {
|
|
3
|
+
"bundleName": "com.rnoh.reanimated",
|
|
4
|
+
"debug": true,
|
|
5
|
+
"versionCode": 1000000,
|
|
6
|
+
"versionName": "1.0.0",
|
|
7
|
+
"minAPIVersion": 50000012,
|
|
8
|
+
"targetAPIVersion": 50101019,
|
|
9
|
+
"apiReleaseType": "Release",
|
|
10
|
+
"targetMinorAPIVersion": 0,
|
|
11
|
+
"targetPatchAPIVersion": 0,
|
|
12
|
+
"compileSdkVersion": "6.0.0.47",
|
|
13
|
+
"compileSdkType": "HarmonyOS",
|
|
14
|
+
"appEnvironments": [],
|
|
15
|
+
"bundleType": "app",
|
|
16
|
+
"buildMode": "debug"
|
|
17
|
+
},
|
|
18
|
+
"module": {
|
|
19
|
+
"name": "keyboard_controller",
|
|
20
|
+
"type": "har",
|
|
21
|
+
"deviceTypes": [
|
|
22
|
+
"default",
|
|
23
|
+
"tablet",
|
|
24
|
+
"2in1"
|
|
25
|
+
],
|
|
26
|
+
"packageName": "@react-native-ohos/react-native-keyboard-controller",
|
|
27
|
+
"installationFree": false,
|
|
28
|
+
"virtualMachine": "ark12.0.2.0",
|
|
29
|
+
"compileMode": "esmodule",
|
|
30
|
+
"dependencies": []
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
string page_show 0x02000000
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"app":{"bundleName":"com.rnoh.reanimated","debug":true,"versionCode":1000000,"versionName":"1.0.0","minAPIVersion":50000012,"targetAPIVersion":50101019,"apiReleaseType":"Release","targetMinorAPIVersion":0,"targetPatchAPIVersion":0,"compileSdkVersion":"6.0.0.47","compileSdkType":"HarmonyOS","appEnvironments":[],"bundleType":"app","buildMode":"debug"},"module":{"name":"keyboard_controller","type":"har","deviceTypes":["default","tablet","2in1"],"packageName":"@react-native-ohos/react-native-keyboard-controller","installationFree":false,"virtualMachine":"ark12.0.2.0","compileMode":"esmodule","dependencies":[]}}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": {
|
|
3
|
+
"bundleName": "com.rnoh.reanimated",
|
|
4
|
+
"debug": true,
|
|
5
|
+
"versionCode": 1000000,
|
|
6
|
+
"versionName": "1.0.0",
|
|
7
|
+
"minAPIVersion": 50000012,
|
|
8
|
+
"targetAPIVersion": 50101019,
|
|
9
|
+
"apiReleaseType": "Release",
|
|
10
|
+
"targetMinorAPIVersion": 0,
|
|
11
|
+
"targetPatchAPIVersion": 0,
|
|
12
|
+
"compileSdkVersion": "6.0.0.47",
|
|
13
|
+
"compileSdkType": "HarmonyOS",
|
|
14
|
+
"appEnvironments": [],
|
|
15
|
+
"bundleType": "app",
|
|
16
|
+
"buildMode": "debug"
|
|
17
|
+
},
|
|
18
|
+
"module": {
|
|
19
|
+
"name": "keyboard_controller",
|
|
20
|
+
"type": "har",
|
|
21
|
+
"deviceTypes": ["default", "tablet", "2in1"],
|
|
22
|
+
"packageName": "@react-native-ohos/react-native-keyboard-controller",
|
|
23
|
+
"installationFree": false,
|
|
24
|
+
"virtualMachine": "ark12.0.2.0",
|
|
25
|
+
"compileMode": "esmodule",
|
|
26
|
+
"dependencies": []
|
|
27
|
+
}
|
|
28
|
+
}
|
package/harmony/keyboard_controller/build/default/intermediates/res/default/opt-compression.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"context":{"extensionPath":"C:\\Program Files\\Huawei\\DevEco Studio\\sdk\\default\\hms\\toolchains\\lib\\libimage_transcoder_shared.dll"},"compression":{"media":{"enable":false},"filters":[]}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"configPath":"E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\build\\default\\intermediates\\process_profile\\default\\module.json","packageName":"com.rnoh.reanimated","output":"E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\build\\default\\intermediates\\res\\default","moduleNames":"keyboard_controller,entry,reanimated","ResourceTable":["E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\build\\default\\generated\\r\\default\\ResourceTable.h"],"moduleResources":["E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\src\\main\\resources"],"dependencies":["E:\\code\\reanimated\\tester\\harmony\\oh_modules\\.ohpm\\@rnoh+react-native-openharmony@vxxmhmr1t+pcc5jbusidnjj9nnrdumn1pfcgh2cazim=\\oh_modules\\@rnoh\\react-native-openharmony\\src\\main\\resources"],"iconCheck":false,"compression":"E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\build\\default\\intermediates\\res\\default\\opt-compression.json","ids":"E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\build\\default\\intermediates\\res\\default\\ids_map","definedIds":"E:\\github\\react-native-keyboard-controller\\harmony\\keyboard_controller\\build\\default\\intermediates\\res\\default\\ids_map\\id_defined.json","definedSysIds":"C:\\Program Files\\Huawei\\DevEco Studio\\sdk\\default\\hms\\toolchains\\id_defined.json"}
|
|
Binary file
|