@react-native-ohos/react-native-bindingx 1.0.4-rc.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.md +13 -0
- package/README.OpenSource +11 -0
- package/README.md +14 -0
- package/harmony/bindingx/BuildProfile.ets +5 -0
- package/harmony/bindingx/build-profile.json5 +9 -0
- package/harmony/bindingx/hvigorfile.ts +2 -0
- package/harmony/bindingx/index.ets +25 -0
- package/harmony/bindingx/oh-package.json5 +12 -0
- package/harmony/bindingx/src/main/cpp/CMakeLists.txt +8 -0
- package/harmony/bindingx/src/main/cpp/ExpressHandleEval.cpp +176 -0
- package/harmony/bindingx/src/main/cpp/ExpressHandleEval.h +51 -0
- package/harmony/bindingx/src/main/cpp/ReactBindingXModule.cpp +42 -0
- package/harmony/bindingx/src/main/cpp/ReactBindingXModule.h +38 -0
- package/harmony/bindingx/src/main/cpp/ReactBindingXPackage.cpp +53 -0
- package/harmony/bindingx/src/main/cpp/ReactBindingXPackage.h +37 -0
- package/harmony/bindingx/src/main/cpp/ReactBindingxArkTSMessageHandler.cpp +563 -0
- package/harmony/bindingx/src/main/cpp/ReactBindingxArkTSMessageHandler.h +78 -0
- package/harmony/bindingx/src/main/ets/BindingXCore.ts +477 -0
- package/harmony/bindingx/src/main/ets/BindingXParamBean.ts +37 -0
- package/harmony/bindingx/src/main/ets/IRNViewUpdater.ts +45 -0
- package/harmony/bindingx/src/main/ets/ReactBindingXModule.ts +71 -0
- package/harmony/bindingx/src/main/ets/ReactBindingXPackage.ts +46 -0
- package/harmony/bindingx/src/main/ets/TimingFunctions.ts +281 -0
- package/harmony/bindingx/src/main/ets/TimingFunctionsType.ts +58 -0
- package/harmony/bindingx/src/main/ets/TimingFunctionsTypeHandler.ts +128 -0
- package/harmony/bindingx/src/main/module.json5 +7 -0
- package/harmony/bindingx/src/main/resources/base/element/color.json +8 -0
- package/harmony/bindingx/src/main/resources/base/element/string.json +16 -0
- package/harmony/bindingx/src/main/resources/base/media/icon.png +0 -0
- package/harmony/bindingx/src/main/resources/base/profile/main_pages.json +5 -0
- package/harmony/bindingx/src/main/resources/en_US/element/string.json +16 -0
- package/harmony/bindingx/src/main/resources/zh_CN/element/string.json +16 -0
- package/harmony/bindingx/ts.ts +26 -0
- package/harmony/bindingx.har +0 -0
- package/lib/index.js +3 -0
- package/lib/specs/NativeReactBindingXModule.ts +12 -0
- package/lib/src/bindingx.js +131 -0
- package/package.json +27 -0
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import sensor from "@ohos.sensor"
|
|
26
|
+
import { TimingFunctions } from "./TimingFunctions"
|
|
27
|
+
import { BindingXParamBean } from "./BindingXParamBean"
|
|
28
|
+
import { IRNViewUpdater } from './IRNViewUpdater';
|
|
29
|
+
import { TimingFunctionsType } from './TimingFunctionsType';
|
|
30
|
+
import { TimingFunctionsTypeHandler } from './TimingFunctionsTypeHandler';
|
|
31
|
+
import { TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
32
|
+
import {UIContext} from '@ohos.arkui.UIContext'
|
|
33
|
+
|
|
34
|
+
export class BindingXCore {
|
|
35
|
+
map: Map<string, string> = new Map();
|
|
36
|
+
opacity: number = 1;
|
|
37
|
+
bgcolorExpress: string;
|
|
38
|
+
colorExpress: string;
|
|
39
|
+
ctx: TurboModuleContext;
|
|
40
|
+
stopTask: boolean = false;
|
|
41
|
+
interceptSensor: boolean = false;
|
|
42
|
+
|
|
43
|
+
doPrepare(anchor: string, eventType: string) {
|
|
44
|
+
let token = anchor;
|
|
45
|
+
this.map.set(token, eventType);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
bind(options: object, ctx: TurboModuleContext): string {
|
|
49
|
+
this.ctx = ctx;
|
|
50
|
+
let param = JSON.stringify(options);
|
|
51
|
+
let bindingxBean = JSON.parse(param) as BindingXParamBean;
|
|
52
|
+
let eventType = bindingxBean.eventType;
|
|
53
|
+
let props = bindingxBean.props;
|
|
54
|
+
if (eventType == "orientation") {
|
|
55
|
+
this.interceptSensor = false;
|
|
56
|
+
try {
|
|
57
|
+
sensor.on(sensor.SensorId.ROTATION_VECTOR, (data: sensor.RotationVectorResponse) => {
|
|
58
|
+
if (this.interceptSensor) return;
|
|
59
|
+
this.ctx.rnInstance.postMessageToCpp("bind", { options: options, data: data });
|
|
60
|
+
});
|
|
61
|
+
} catch (error) {
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
else if (eventType == "pan") {
|
|
66
|
+
let uiContext = new UIContext();
|
|
67
|
+
this.ctx.rnInstance.postMessageToCpp("bind", { options: options,px2vp:uiContext.px2vp(1)});
|
|
68
|
+
}
|
|
69
|
+
else if (eventType == "scroll") {
|
|
70
|
+
let that = this;
|
|
71
|
+
props.forEach(e => {
|
|
72
|
+
if (e.property == IRNViewUpdater.background_color) {
|
|
73
|
+
that.bgcolorExpress = e.expression
|
|
74
|
+
}
|
|
75
|
+
if (e.property == IRNViewUpdater.color) {
|
|
76
|
+
that.colorExpress = e.expression
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
let bgcolorExpressAtr = this.bgcolorExpress.substring(this.bgcolorExpress.indexOf("(") + 1, this.bgcolorExpress.lastIndexOf(")")).split(",");
|
|
81
|
+
let colorExpressAtr = this.colorExpress.substring(this.colorExpress.indexOf("(") + 1, this.colorExpress.lastIndexOf(")")).split(",");
|
|
82
|
+
this.ctx.rnInstance.postMessageToCpp("bind", {
|
|
83
|
+
options: options,
|
|
84
|
+
background_color: bgcolorExpressAtr[0].substring(bgcolorExpressAtr[0].indexOf("'") + 1, bgcolorExpressAtr[0].lastIndexOf("'")).replace("#", "0xff") + "," + bgcolorExpressAtr[1].substring(bgcolorExpressAtr[1].indexOf("'") + 1, bgcolorExpressAtr[1].lastIndexOf("'")).replace("#", "0xff"),
|
|
85
|
+
color: colorExpressAtr[0].substring(colorExpressAtr[0].indexOf("'") + 1, colorExpressAtr[0].lastIndexOf("'")).replace("#", "0xff") + "," + colorExpressAtr[1].substring(colorExpressAtr[1].indexOf("'") + 1, colorExpressAtr[1].lastIndexOf("'")).replace("#", "0xff"),
|
|
86
|
+
background_color_eval: bgcolorExpressAtr[2] + "," + bgcolorExpressAtr[3]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
else if (eventType == "timing") {
|
|
91
|
+
let exitExpression = (bindingxBean.exitExpression.substring(bindingxBean.exitExpression.indexOf(">") + 1,
|
|
92
|
+
bindingxBean.exitExpression.length)) as unknown as number;
|
|
93
|
+
this.stopTask = false;
|
|
94
|
+
let timingTypeX;
|
|
95
|
+
let timingTypeY;
|
|
96
|
+
let timingTypeXArr;
|
|
97
|
+
let timingTypeYArr;
|
|
98
|
+
let evalStr;
|
|
99
|
+
props.forEach(e => {
|
|
100
|
+
if (e.property == IRNViewUpdater.transform_translateX) {
|
|
101
|
+
timingTypeX = TimingFunctionsTypeHandler.handlerStringType(e.expression);
|
|
102
|
+
timingTypeXArr = e.expression.substring(e.expression.indexOf("(") + 1, e.expression.indexOf(")")).split(",")
|
|
103
|
+
}
|
|
104
|
+
if (e.property == IRNViewUpdater.transform_translateY) {
|
|
105
|
+
timingTypeY = TimingFunctionsTypeHandler.handlerStringType(e.expression);
|
|
106
|
+
timingTypeYArr = e.expression.substring(e.expression.indexOf("(") + 1, e.expression.indexOf(")")).split(",")
|
|
107
|
+
}
|
|
108
|
+
if (e.property == IRNViewUpdater.opacity) {
|
|
109
|
+
evalStr = e.expression;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
this.handleTiming(options, timingTypeX, exitExpression, timingTypeXArr, timingTypeY, timingTypeYArr, evalStr)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let anchor = bindingxBean.anchor;
|
|
116
|
+
let token = props[0].element;
|
|
117
|
+
if (anchor > 0) {
|
|
118
|
+
token = new String(anchor).valueOf();
|
|
119
|
+
}
|
|
120
|
+
this.doPrepare(token, eventType)
|
|
121
|
+
return token;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public unbind(options: object) {
|
|
125
|
+
let eventType = options["eventType"];
|
|
126
|
+
let token = options["token"];
|
|
127
|
+
this.map.forEach((value, key) => {
|
|
128
|
+
if ((key == token && value == eventType)) {
|
|
129
|
+
if (value == "orientation") {
|
|
130
|
+
this.interceptSensor = true;
|
|
131
|
+
this.map.delete(key);
|
|
132
|
+
try {
|
|
133
|
+
sensor.off(sensor.SensorId.ROTATION_VECTOR);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (value == "pan" || value == "scroll") {
|
|
138
|
+
this.map.delete(key);
|
|
139
|
+
this.ctx.rnInstance.postMessageToCpp("unbind", { options: options });
|
|
140
|
+
}
|
|
141
|
+
else if (value == "timing") {
|
|
142
|
+
this.map.delete(key);
|
|
143
|
+
this.stopTask = true;
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
public unbindAll() {
|
|
152
|
+
this.map.forEach((value, key) => {
|
|
153
|
+
if (value == "orientation") {
|
|
154
|
+
this.map.delete(key);
|
|
155
|
+
try {
|
|
156
|
+
sensor.off(sensor.SensorId.ROTATION_VECTOR);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else if (value == "pan" || value == "scroll") {
|
|
161
|
+
this.map.delete(key);
|
|
162
|
+
this.ctx.rnInstance.postMessageToCpp("unbind", { options: { eventType: value,token:key } });
|
|
163
|
+
}
|
|
164
|
+
else if (value == "timing") {
|
|
165
|
+
this.map.delete(key);
|
|
166
|
+
this.stopTask = true;
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
private handleTiming(options: object, timingTypeX: number, exitExpression: number, timingTypeXArr: Array<number>,
|
|
173
|
+
timingTypeY: number, timingTypeYArr: Array<number>, evalStr: string) {
|
|
174
|
+
let x = 0;
|
|
175
|
+
let deltaT = 16;
|
|
176
|
+
let that = this;
|
|
177
|
+
let taskX = setInterval(() => {
|
|
178
|
+
if (deltaT > exitExpression || this.stopTask) {
|
|
179
|
+
clearInterval(taskX);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
let b = new Number(timingTypeXArr[1]).valueOf();
|
|
183
|
+
let c = new Number(timingTypeXArr[2]).valueOf();
|
|
184
|
+
let d = new Number(timingTypeXArr[3]).valueOf();
|
|
185
|
+
if (timingTypeX == TimingFunctionsType.linear) {
|
|
186
|
+
x = TimingFunctions.linear(deltaT, b, c, d);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (timingTypeX == TimingFunctionsType.easeInQuad) {
|
|
190
|
+
x = TimingFunctions.easeInQuad(deltaT, b, c, d);
|
|
191
|
+
}
|
|
192
|
+
if (timingTypeX == TimingFunctionsType.easeOutQuad) {
|
|
193
|
+
x = TimingFunctions.easeOutQuad(deltaT, b, c, d);
|
|
194
|
+
}
|
|
195
|
+
if (timingTypeX == TimingFunctionsType.easeInOutQuad) {
|
|
196
|
+
x = TimingFunctions.easeInOutQuad(deltaT, b, c, d);
|
|
197
|
+
}
|
|
198
|
+
if (timingTypeX == TimingFunctionsType.easeInCubic) {
|
|
199
|
+
x = TimingFunctions.easeInCubic(deltaT, b, c, d);
|
|
200
|
+
}
|
|
201
|
+
if (timingTypeX == TimingFunctionsType.easeOutCubic) {
|
|
202
|
+
x = TimingFunctions.easeOutCubic(deltaT, b, c, d);
|
|
203
|
+
}
|
|
204
|
+
if (timingTypeX == TimingFunctionsType.easeInOutCubic) {
|
|
205
|
+
x = TimingFunctions.easeInOutCubic(deltaT, b, c, d);
|
|
206
|
+
}
|
|
207
|
+
if (timingTypeX == TimingFunctionsType.easeInQuart) {
|
|
208
|
+
x = TimingFunctions.easeInQuart(deltaT, b, c, d);
|
|
209
|
+
}
|
|
210
|
+
if (timingTypeX == TimingFunctionsType.easeOutQuart) {
|
|
211
|
+
x = TimingFunctions.easeOutQuart(deltaT, b, c, d);
|
|
212
|
+
}
|
|
213
|
+
if (timingTypeX == TimingFunctionsType.easeInOutQuart) {
|
|
214
|
+
x = TimingFunctions.easeInOutQuart(deltaT, b, c, d);
|
|
215
|
+
}
|
|
216
|
+
if (timingTypeX == TimingFunctionsType.easeInQuint) {
|
|
217
|
+
x = TimingFunctions.easeInQuint(deltaT, b, c, d);
|
|
218
|
+
}
|
|
219
|
+
if (timingTypeX == TimingFunctionsType.easeOutQuint) {
|
|
220
|
+
x = TimingFunctions.easeOutQuint(deltaT, b, c, d);
|
|
221
|
+
}
|
|
222
|
+
if (timingTypeX == TimingFunctionsType.easeInOutQuint) {
|
|
223
|
+
x = TimingFunctions.easeInOutQuint(deltaT, b, c, d);
|
|
224
|
+
}
|
|
225
|
+
if (timingTypeX == TimingFunctionsType.easeInSine) {
|
|
226
|
+
x = TimingFunctions.easeInSine(deltaT, b, c, d);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (timingTypeX == TimingFunctionsType.easeOutSine) {
|
|
230
|
+
x = TimingFunctions.easeOutSine(deltaT, b, c, d);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (timingTypeX == TimingFunctionsType.easeInQuad) {
|
|
234
|
+
x = TimingFunctions.easeInQuad(deltaT, b, c, d);
|
|
235
|
+
}
|
|
236
|
+
if (timingTypeX == TimingFunctionsType.easeOutQuad) {
|
|
237
|
+
x = TimingFunctions.easeOutQuad(deltaT, b, c, d);
|
|
238
|
+
}
|
|
239
|
+
if (timingTypeX == TimingFunctionsType.easeInOutQuad) {
|
|
240
|
+
x = TimingFunctions.easeInOutQuad(deltaT, b, c, d);
|
|
241
|
+
}
|
|
242
|
+
if (timingTypeX == TimingFunctionsType.easeInCubic) {
|
|
243
|
+
x = TimingFunctions.easeInCubic(deltaT, b, c, d);
|
|
244
|
+
}
|
|
245
|
+
if (timingTypeX == TimingFunctionsType.easeOutCubic) {
|
|
246
|
+
x = TimingFunctions.easeOutCubic(deltaT, b, c, d);
|
|
247
|
+
}
|
|
248
|
+
if (timingTypeX == TimingFunctionsType.easeInOutCubic) {
|
|
249
|
+
x = TimingFunctions.easeInOutCubic(deltaT, b, c, d);
|
|
250
|
+
}
|
|
251
|
+
if (timingTypeX == TimingFunctionsType.easeInQuart) {
|
|
252
|
+
x = TimingFunctions.easeInQuart(deltaT, b, c, d);
|
|
253
|
+
}
|
|
254
|
+
if (timingTypeX == TimingFunctionsType.easeOutQuart) {
|
|
255
|
+
x = TimingFunctions.easeOutQuart(deltaT, b, c, d);
|
|
256
|
+
}
|
|
257
|
+
if (timingTypeX == TimingFunctionsType.easeInOutQuart) {
|
|
258
|
+
x = TimingFunctions.easeInOutQuart(deltaT, b, c, d);
|
|
259
|
+
}
|
|
260
|
+
if (timingTypeX == TimingFunctionsType.easeInQuint) {
|
|
261
|
+
x = TimingFunctions.easeInQuint(deltaT, b, c, d);
|
|
262
|
+
}
|
|
263
|
+
if (timingTypeX == TimingFunctionsType.easeOutQuint) {
|
|
264
|
+
x = TimingFunctions.easeOutQuint(deltaT, b, c, d);
|
|
265
|
+
}
|
|
266
|
+
if (timingTypeX == TimingFunctionsType.easeInOutQuint) {
|
|
267
|
+
x = TimingFunctions.easeInOutQuint(deltaT, b, c, d);
|
|
268
|
+
}
|
|
269
|
+
if (timingTypeX == TimingFunctionsType.easeInSine) {
|
|
270
|
+
x = TimingFunctions.easeInSine(deltaT, b, c, d);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (timingTypeX == TimingFunctionsType.easeOutSine) {
|
|
274
|
+
x = TimingFunctions.easeOutSine(deltaT, b, c, d);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (timingTypeX == TimingFunctionsType.easeInBack) {
|
|
278
|
+
x = TimingFunctions.easeInBack(deltaT, b, c, d);
|
|
279
|
+
}
|
|
280
|
+
if (timingTypeX == TimingFunctionsType.easeOutBack) {
|
|
281
|
+
x = TimingFunctions.easeOutBack(deltaT, b, c, d);
|
|
282
|
+
}
|
|
283
|
+
if (timingTypeX == TimingFunctionsType.easeInOutBack) {
|
|
284
|
+
x = TimingFunctions.easeInOutBack(deltaT, b, c, d);
|
|
285
|
+
}
|
|
286
|
+
if (timingTypeX == TimingFunctionsType.easeInBounce) {
|
|
287
|
+
x = TimingFunctions.easeInBounce(deltaT, b, c, d);
|
|
288
|
+
}
|
|
289
|
+
if (timingTypeX == TimingFunctionsType.easeOutBounce) {
|
|
290
|
+
x = TimingFunctions.easeOutBounce(deltaT, b, c, d);
|
|
291
|
+
}
|
|
292
|
+
if (timingTypeX == TimingFunctionsType.easeInOutBounce) {
|
|
293
|
+
x = TimingFunctions.easeInOutBounce(deltaT, b, c, d);
|
|
294
|
+
}
|
|
295
|
+
deltaT = deltaT + 16;
|
|
296
|
+
let evalStrTemp = evalStr.replace("t", deltaT + "");
|
|
297
|
+
try {
|
|
298
|
+
that.ctx.rnInstance.postMessageToCpp("eval", { data: evalStrTemp, eventType: "timing" })
|
|
299
|
+
}
|
|
300
|
+
catch (e) {
|
|
301
|
+
}
|
|
302
|
+
}, 16)
|
|
303
|
+
|
|
304
|
+
let t = 0.0034;
|
|
305
|
+
let taskY = setInterval(() => {
|
|
306
|
+
if (deltaT > exitExpression || this.stopTask) {
|
|
307
|
+
clearInterval(taskY);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
let y = 0;
|
|
311
|
+
let b = new Number(timingTypeYArr[1]).valueOf();
|
|
312
|
+
let c = new Number(timingTypeYArr[2]).valueOf();
|
|
313
|
+
let d = new Number(timingTypeYArr[3]).valueOf();
|
|
314
|
+
if (timingTypeY == TimingFunctionsType.linear) {
|
|
315
|
+
y = TimingFunctions.linear(t, b, c, d);
|
|
316
|
+
}
|
|
317
|
+
if (timingTypeY == TimingFunctionsType.easeInQuad) {
|
|
318
|
+
y = TimingFunctions.easeInQuad(t, b, c, d);
|
|
319
|
+
}
|
|
320
|
+
if (timingTypeY == TimingFunctionsType.easeOutQuad) {
|
|
321
|
+
y = TimingFunctions.easeOutQuad(t, b, c, d);
|
|
322
|
+
}
|
|
323
|
+
if (timingTypeY == TimingFunctionsType.easeInOutQuad) {
|
|
324
|
+
y = TimingFunctions.easeInOutQuad(t, b, c, d);
|
|
325
|
+
}
|
|
326
|
+
if (timingTypeY == TimingFunctionsType.easeInCubic) {
|
|
327
|
+
y = TimingFunctions.easeInCubic(t, b, c, d);
|
|
328
|
+
}
|
|
329
|
+
if (timingTypeY == TimingFunctionsType.easeOutCubic) {
|
|
330
|
+
y = TimingFunctions.easeOutCubic(t, b, c, d);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (timingTypeY == TimingFunctionsType.easeInOutCubic) {
|
|
334
|
+
y = TimingFunctions.easeInOutCubic(t, b, c, d);
|
|
335
|
+
}
|
|
336
|
+
if (timingTypeY == TimingFunctionsType.easeInQuart) {
|
|
337
|
+
y = TimingFunctions.easeInQuart(t, b, c, d);
|
|
338
|
+
}
|
|
339
|
+
if (timingTypeY == TimingFunctionsType.easeOutQuart) {
|
|
340
|
+
y = TimingFunctions.easeOutQuart(t, b, c, d);
|
|
341
|
+
}
|
|
342
|
+
if (timingTypeY == TimingFunctionsType.easeInOutQuart) {
|
|
343
|
+
y = TimingFunctions.easeInOutQuart(t, b, c, d);
|
|
344
|
+
}
|
|
345
|
+
if (timingTypeY == TimingFunctionsType.easeInQuint) {
|
|
346
|
+
y = TimingFunctions.easeInQuint(t, b, c, d);
|
|
347
|
+
}
|
|
348
|
+
if (timingTypeY == TimingFunctionsType.easeOutQuint) {
|
|
349
|
+
y = TimingFunctions.easeOutQuint(t, b, c, d);
|
|
350
|
+
}
|
|
351
|
+
if (timingTypeY == TimingFunctionsType.easeInOutQuint) {
|
|
352
|
+
y = TimingFunctions.easeInOutQuint(t, b, c, d);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (timingTypeY == TimingFunctionsType.easeInSine) {
|
|
356
|
+
y = TimingFunctions.easeInSine(t, b, c, d);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (timingTypeY == TimingFunctionsType.easeOutSine) {
|
|
360
|
+
y = TimingFunctions.easeOutSine(t, b, c, d);
|
|
361
|
+
}
|
|
362
|
+
if (timingTypeY == TimingFunctionsType.easeInOutSine) {
|
|
363
|
+
y = TimingFunctions.easeInOutSine(t, b, c, d);
|
|
364
|
+
}
|
|
365
|
+
if (timingTypeY == TimingFunctionsType.easeInExpo) {
|
|
366
|
+
y = TimingFunctions.easeInExpo(t, b, c, d);
|
|
367
|
+
}
|
|
368
|
+
if (timingTypeY == TimingFunctionsType.easeOutExpo) {
|
|
369
|
+
y = TimingFunctions.easeOutExpo(t, b, c, d);
|
|
370
|
+
}
|
|
371
|
+
if (timingTypeY == TimingFunctionsType.easeInOutExpo) {
|
|
372
|
+
y = TimingFunctions.easeInOutExpo(t, b, c, d);
|
|
373
|
+
}
|
|
374
|
+
if (timingTypeY == TimingFunctionsType.easeInCirc) {
|
|
375
|
+
y = TimingFunctions.easeInCirc(t, b, c, d);
|
|
376
|
+
}
|
|
377
|
+
if (timingTypeY == TimingFunctionsType.easeOutCirc) {
|
|
378
|
+
y = TimingFunctions.easeOutCirc(t, b, c, d);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (timingTypeY == TimingFunctionsType.easeInOutCirc) {
|
|
382
|
+
y = TimingFunctions.easeInOutCirc(t, b, c, d);
|
|
383
|
+
}
|
|
384
|
+
if (timingTypeY == TimingFunctionsType.easeInElastic) {
|
|
385
|
+
y = TimingFunctions.easeInElastic(t, b, c, d);
|
|
386
|
+
}
|
|
387
|
+
if (timingTypeY == TimingFunctionsType.easeOutElastic) {
|
|
388
|
+
y = TimingFunctions.easeOutElastic(t, b, c, d);
|
|
389
|
+
}
|
|
390
|
+
if (timingTypeY == TimingFunctionsType.easeInOutElastic) {
|
|
391
|
+
y = TimingFunctions.easeInOutElastic(t, b, c, d);
|
|
392
|
+
}
|
|
393
|
+
if (timingTypeY == TimingFunctionsType.easeInBack) {
|
|
394
|
+
y = TimingFunctions.easeInBack(t, b, c, d);
|
|
395
|
+
}
|
|
396
|
+
if (timingTypeY == TimingFunctionsType.easeOutBack) {
|
|
397
|
+
y = TimingFunctions.easeOutBack(t, b, c, d);
|
|
398
|
+
}
|
|
399
|
+
if (timingTypeY == TimingFunctionsType.easeInOutBack) {
|
|
400
|
+
y = TimingFunctions.easeInOutBack(t, b, c, d);
|
|
401
|
+
}
|
|
402
|
+
if (timingTypeY == TimingFunctionsType.easeInBounce) {
|
|
403
|
+
y = TimingFunctions.easeInBounce(t, b, c, d);
|
|
404
|
+
}
|
|
405
|
+
if (timingTypeY == TimingFunctionsType.easeOutBounce) {
|
|
406
|
+
y = TimingFunctions.easeOutBounce(t, b, c, d);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
if (timingTypeY == TimingFunctionsType.easeInOutBounce) {
|
|
410
|
+
y = TimingFunctions.easeInOutBounce(t, b, c, d);
|
|
411
|
+
}
|
|
412
|
+
t = t + 0.0034;
|
|
413
|
+
try {
|
|
414
|
+
that.ctx.rnInstance.postMessageToCpp("bind", {
|
|
415
|
+
options: options,
|
|
416
|
+
needOriginY: false,
|
|
417
|
+
data: { x: x, y: y },
|
|
418
|
+
opacity: that.opacity
|
|
419
|
+
});
|
|
420
|
+
} catch (e) {
|
|
421
|
+
|
|
422
|
+
}
|
|
423
|
+
}, 16)
|
|
424
|
+
this.handleEvalMsgFromArkTS2Cpp()
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
handleEvalMsgFromArkTS2Cpp() {
|
|
429
|
+
let that = this;
|
|
430
|
+
this.ctx.rnInstance.cppEventEmitter.subscribe("eval", (value) => {
|
|
431
|
+
that.opacity = new Number(value).valueOf();
|
|
432
|
+
})
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
handleReceivedTouchFromCpp() {
|
|
436
|
+
let that = this;
|
|
437
|
+
this.ctx.rnInstance.cppEventEmitter.subscribe("touch", (value) => {
|
|
438
|
+
let json = JSON.stringify(value).split(",")
|
|
439
|
+
that.ctx.rnInstance.emitDeviceEvent("bindingx:statechange",
|
|
440
|
+
{
|
|
441
|
+
deltaX: json[0],
|
|
442
|
+
deltaY: json[1],
|
|
443
|
+
token: this.findToken(),
|
|
444
|
+
state: 'end'
|
|
445
|
+
}
|
|
446
|
+
);
|
|
447
|
+
})
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
handleTouch(anchor: number, eventType: string,ctx: TurboModuleContext){
|
|
451
|
+
this.ctx = ctx;
|
|
452
|
+
if(eventType=="pan"){
|
|
453
|
+
let uiContext = new UIContext();
|
|
454
|
+
let options= {
|
|
455
|
+
eventType: eventType,
|
|
456
|
+
anchor: anchor,
|
|
457
|
+
px2vp:uiContext.px2vp(1)
|
|
458
|
+
};
|
|
459
|
+
this.ctx.rnInstance.postMessageToCpp("prepare", options);
|
|
460
|
+
this.handleReceivedTouchFromCpp();
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
findToken():string{
|
|
465
|
+
let token=""
|
|
466
|
+
this.map.forEach((value,key)=>{
|
|
467
|
+
if(value=="pan"){
|
|
468
|
+
token=key
|
|
469
|
+
}
|
|
470
|
+
})
|
|
471
|
+
return token;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
}
|
|
477
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export class BindingXParamProps {
|
|
26
|
+
element: string = ""
|
|
27
|
+
property: string = ""
|
|
28
|
+
expression: string = ""
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
export class BindingXParamBean {
|
|
33
|
+
eventType: string = ""
|
|
34
|
+
exitExpression: string = ""
|
|
35
|
+
anchor: number = 0
|
|
36
|
+
props: Array<BindingXParamProps> = []
|
|
37
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
export class IRNViewUpdater {
|
|
25
|
+
|
|
26
|
+
public static opacity="opacity";
|
|
27
|
+
public static transform_translate="transform.translate";
|
|
28
|
+
public static transform_translateX="transform.translateX";
|
|
29
|
+
public static transform_translateY="transform.translateY";
|
|
30
|
+
public static transform_scale="transform.scale";
|
|
31
|
+
public static transform_scaleX="transform.scaleX";
|
|
32
|
+
public static transform_scaleY="transform.scaleY";
|
|
33
|
+
public static transform_rotate="transform.rotate";
|
|
34
|
+
public static transform_rotateZ="transform.rotateZ";
|
|
35
|
+
public static transform_rotateX="transform.rotateX";
|
|
36
|
+
public static transform_rotateY="transform.rotateY";
|
|
37
|
+
public static background_color="background-color";
|
|
38
|
+
public static color="color";
|
|
39
|
+
public static scroll_contentOffset="scroll.contentOffset";
|
|
40
|
+
public static scroll_contentOffsetX="scroll.contentOffsetX";
|
|
41
|
+
public static scroll_contentOffsetY="scroll.contentOffsetY";
|
|
42
|
+
public static width="width";
|
|
43
|
+
public static height="height";
|
|
44
|
+
|
|
45
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
26
|
+
import { BindingXCore } from './BindingXCore'
|
|
27
|
+
|
|
28
|
+
export class ReactBindingXModule extends TurboModule {
|
|
29
|
+
static NAME = "ReactBindingXModule"
|
|
30
|
+
|
|
31
|
+
private mBindingXCore: BindingXCore;
|
|
32
|
+
|
|
33
|
+
constructor(ctx: TurboModuleContext) {
|
|
34
|
+
super(ctx)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public prepare(options: object) {
|
|
38
|
+
if (!this.mBindingXCore) {
|
|
39
|
+
this.mBindingXCore = new BindingXCore();
|
|
40
|
+
}
|
|
41
|
+
this.mBindingXCore.handleTouch(options["anchor"],options["eventType"],this.ctx);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
public bind(options: object): string {
|
|
46
|
+
if (!this.mBindingXCore) {
|
|
47
|
+
this.mBindingXCore = new BindingXCore();
|
|
48
|
+
}
|
|
49
|
+
return this.mBindingXCore.bind(options, this.ctx);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
public unbind(options: object) {
|
|
54
|
+
if(!this.mBindingXCore) return;
|
|
55
|
+
this.mBindingXCore.unbind(options);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public unbindAll() {
|
|
59
|
+
if(!this.mBindingXCore) return;
|
|
60
|
+
this.mBindingXCore.unbindAll()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public async getComputedStyle(options: object): Promise<string> {
|
|
64
|
+
this.ctx.rnInstance.postMessageToCpp("getComputedStyle", { element: options });
|
|
65
|
+
return await new Promise( (resolve, reject) => {
|
|
66
|
+
this.ctx.rnInstance.cppEventEmitter.subscribe("style", (value) => {
|
|
67
|
+
resolve(JSON.stringify(value));
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import {RNPackage, TurboModuleContext, TurboModulesFactory} from '@rnoh/react-native-openharmony/ts';
|
|
26
|
+
import type {TurboModule} from '@rnoh/react-native-openharmony/ts';
|
|
27
|
+
import {ReactBindingXModule} from './ReactBindingXModule';
|
|
28
|
+
|
|
29
|
+
class ReactBindingXTurboModulesFactory extends TurboModulesFactory {
|
|
30
|
+
createTurboModule(name: string): TurboModule | null {
|
|
31
|
+
if (name === ReactBindingXModule.NAME) {
|
|
32
|
+
return new ReactBindingXModule(this.ctx);
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
hasTurboModule(name: string): boolean {
|
|
38
|
+
return name === ReactBindingXModule.NAME;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class ReactBindingXPackage extends RNPackage {
|
|
43
|
+
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
|
|
44
|
+
return new ReactBindingXTurboModulesFactory(ctx);
|
|
45
|
+
}
|
|
46
|
+
}
|