@react-native-ohos/react-native-context-menu-view 1.19.1-rc.1 → 1.19.1-rc.2
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/README.md +1 -1
- package/harmony/context_menu/oh-package.json5 +1 -1
- package/harmony/context_menu/src/main/ets/ContextMenuLongPress.ets +6 -1
- package/harmony/context_menu/src/main/ets/ContextMenuLongPressWithNoSelect.ets +6 -1
- package/harmony/context_menu/src/main/ets/ContextMenuTurboModule.ets +53 -42
- package/harmony/context_menu.har +0 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @react-native-ohos/react-native-context-menu-view
|
|
2
2
|
|
|
3
|
-
This project is based on [react-native-context-menu-view](https://github.com/mpiannucci/react-native-context-menu-view/tree/v1.19.0)
|
|
3
|
+
This project is based on [react-native-context-menu-view@v1.19.0](https://github.com/mpiannucci/react-native-context-menu-view/tree/v1.19.0)
|
|
4
4
|
|
|
5
5
|
## Documentation
|
|
6
6
|
|
|
@@ -27,6 +27,7 @@ import Logger from './Logger';
|
|
|
27
27
|
import { SymbolGlyphModifier } from '@kit.ArkUI';
|
|
28
28
|
import { ContextMenuTwoMenu } from './ContextMenuTwoMenu';
|
|
29
29
|
import { ContextMenuTwoMenuWithNoSelect } from './ContextMenuTwoMenuWithNoSelect';
|
|
30
|
+
import { writeResult } from './ContextMenuTurboModule';
|
|
30
31
|
|
|
31
32
|
//这里的属性类型要和ContextMenuTurboModule.ets下的ContextMenuProps一致
|
|
32
33
|
interface ContextMenuProps {
|
|
@@ -384,7 +385,11 @@ export struct ContextMenuLongPress {
|
|
|
384
385
|
}
|
|
385
386
|
})
|
|
386
387
|
}.backgroundColor('white')
|
|
387
|
-
}
|
|
388
|
+
}
|
|
389
|
+
.onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
|
|
390
|
+
writeResult(newValue.width, newValue.height)
|
|
391
|
+
})
|
|
392
|
+
.onDisAppear(() => {
|
|
388
393
|
this.menuCtx.rnInstance.postMessageToCpp('contextMenu::onCancel', {
|
|
389
394
|
itemTag: this.menuTag,
|
|
390
395
|
});
|
|
@@ -27,6 +27,7 @@ import Logger from './Logger';
|
|
|
27
27
|
import { SymbolGlyphModifier } from '@kit.ArkUI';
|
|
28
28
|
import { ContextMenuTwoMenu } from './ContextMenuTwoMenu';
|
|
29
29
|
import { ContextMenuTwoMenuWithNoSelect } from './ContextMenuTwoMenuWithNoSelect';
|
|
30
|
+
import { writeResult } from './ContextMenuTurboModule';
|
|
30
31
|
|
|
31
32
|
//这里的属性类型要和ContextMenuTurboModule.ets下的ContextMenuProps一致
|
|
32
33
|
interface ContextMenuProps {
|
|
@@ -366,7 +367,11 @@ export struct ContextMenuLongPressWithNoSelect {
|
|
|
366
367
|
}
|
|
367
368
|
})
|
|
368
369
|
}.backgroundColor('white')
|
|
369
|
-
}
|
|
370
|
+
}
|
|
371
|
+
.onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
|
|
372
|
+
writeResult(newValue.width, newValue.height)
|
|
373
|
+
})
|
|
374
|
+
.onDisAppear(() => {
|
|
370
375
|
this.menuCtx.rnInstance.postMessageToCpp('contextMenu::onCancel', {
|
|
371
376
|
itemTag: this.menuTag,
|
|
372
377
|
});
|
|
@@ -41,6 +41,43 @@ function buildContextMenuWithNoSelect(realViewPoint: ESObject) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
|
|
44
|
+
let uiContext = null;
|
|
45
|
+
let promptAction = null;
|
|
46
|
+
let contentNode = null;
|
|
47
|
+
|
|
48
|
+
let realViewPointX = 0;
|
|
49
|
+
let realViewPointY = 0;
|
|
50
|
+
let windowWidth: number = 0;
|
|
51
|
+
let windowHeight: number = 0;
|
|
52
|
+
|
|
53
|
+
export function writeResult(width: Length, height: Length) {
|
|
54
|
+
try {
|
|
55
|
+
let x = realViewPointX + (width as number);
|
|
56
|
+
let y = realViewPointY + (height as number);
|
|
57
|
+
|
|
58
|
+
if (x > windowWidth) {
|
|
59
|
+
realViewPointX = realViewPointX - (x - windowWidth) - 10;
|
|
60
|
+
}
|
|
61
|
+
if (y > windowHeight) {
|
|
62
|
+
realViewPointY = realViewPointY - (y - windowHeight) - 10;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
promptAction?.openCustomDialog(contentNode, {
|
|
66
|
+
alignment: DialogAlignment.TopStart,
|
|
67
|
+
offset: {
|
|
68
|
+
dx: realViewPointX,
|
|
69
|
+
dy: realViewPointY,
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
this.menuHeight = 0;
|
|
73
|
+
this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::CLOSE_MENU", () => {
|
|
74
|
+
promptAction?.closeCustomDialog(contentNode);
|
|
75
|
+
})
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error(`eroor`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
44
81
|
export interface ContextMenuProps {
|
|
45
82
|
tag?: number;
|
|
46
83
|
width?: number;
|
|
@@ -120,6 +157,9 @@ export class ContextMenuTurboModule extends TurboModule {
|
|
|
120
157
|
this.romWidth = e.touchableViews[0].width;
|
|
121
158
|
this.realViewPoint.romHeight = e.touchableViews[0].height;
|
|
122
159
|
this.romHeight = e.touchableViews[0].height;
|
|
160
|
+
|
|
161
|
+
windowWidth = this.romWidth;
|
|
162
|
+
windowHeight = this.romHeight;
|
|
123
163
|
break;
|
|
124
164
|
case 2:
|
|
125
165
|
//isCancel = true; move x1-x > 150 移动判断 y1-y >200
|
|
@@ -142,6 +182,9 @@ export class ContextMenuTurboModule extends TurboModule {
|
|
|
142
182
|
this.windowX = e.touchPoints[0].windowX;
|
|
143
183
|
this.realViewPoint.windowY = e.touchPoints[0].windowY;
|
|
144
184
|
this.windowY = e.touchPoints[0].windowY;
|
|
185
|
+
|
|
186
|
+
realViewPointX = this.windowX;
|
|
187
|
+
realViewPointY = this.windowY;
|
|
145
188
|
this.realViewPoint.touchViewActions = e.touchViewActions;
|
|
146
189
|
let selectedActions: ESObject = e.touchViewActions;
|
|
147
190
|
if (!this.longPressLock) {
|
|
@@ -197,6 +240,10 @@ export class ContextMenuTurboModule extends TurboModule {
|
|
|
197
240
|
this.windowX = e.touchPoints[0].windowX;
|
|
198
241
|
this.realViewPoint.windowY = e.touchPoints[0].windowY;
|
|
199
242
|
this.windowY = e.touchPoints[0].windowY;
|
|
243
|
+
|
|
244
|
+
realViewPointX = this.windowX;
|
|
245
|
+
realViewPointY = this.windowY;
|
|
246
|
+
|
|
200
247
|
//此处获取actions值
|
|
201
248
|
this.realViewPoint.touchViewActions = e.touchViewActions;
|
|
202
249
|
//当获取到了view视图,并且dropdownMenuMode为true的时候,进入单点效果.
|
|
@@ -244,54 +291,18 @@ export class ContextMenuTurboModule extends TurboModule {
|
|
|
244
291
|
onTouch(realViewPoint: Object) {
|
|
245
292
|
window.getLastWindow(this.ctx.uiAbilityContext)
|
|
246
293
|
.then((value) => {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
let offDx = -this.romWidth / 2 + this.windowX + this.width / 2;
|
|
251
|
-
let OffDy = -this.romHeight / 2 + this.windowY + this.height * 0.4 + 48 * this.menuHeight;
|
|
252
|
-
try {
|
|
253
|
-
promptAction?.openCustomDialog(contentNode, {
|
|
254
|
-
offset: {
|
|
255
|
-
dx: offDx,
|
|
256
|
-
dy: OffDy,
|
|
257
|
-
}
|
|
258
|
-
})
|
|
259
|
-
this.menuHeight = 0;
|
|
260
|
-
this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::CLOSE_MENU", () => {
|
|
261
|
-
promptAction?.closeCustomDialog(contentNode);
|
|
262
|
-
offDx = 0;
|
|
263
|
-
OffDy = 0;
|
|
264
|
-
})
|
|
265
|
-
} catch (error) {
|
|
266
|
-
console.error(`eroor`);
|
|
267
|
-
}
|
|
294
|
+
uiContext = value.getUIContext()
|
|
295
|
+
promptAction = uiContext?.getPromptAction();
|
|
296
|
+
contentNode = new ComponentContent(uiContext!, wrapBuilder(buildContextMenu), realViewPoint);
|
|
268
297
|
})
|
|
269
298
|
}
|
|
270
299
|
|
|
271
300
|
onTouchWithNoSelect(realViewPoint: Object) {
|
|
272
301
|
window.getLastWindow(this.ctx.uiAbilityContext)
|
|
273
302
|
.then((value) => {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
let offDx = -this.romWidth / 2 + this.windowX + this.width / 2;
|
|
278
|
-
let OffDy = -this.romHeight / 2 + this.windowY + this.height * 0.4 + 48 * this.menuHeight;
|
|
279
|
-
try {
|
|
280
|
-
promptAction?.openCustomDialog(contentNode, {
|
|
281
|
-
offset: {
|
|
282
|
-
dx: offDx,
|
|
283
|
-
dy: OffDy,
|
|
284
|
-
}
|
|
285
|
-
})
|
|
286
|
-
this.menuHeight = 0;
|
|
287
|
-
this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::CLOSE_MENU", () => {
|
|
288
|
-
promptAction?.closeCustomDialog(contentNode);
|
|
289
|
-
offDx = 0;
|
|
290
|
-
OffDy = 0;
|
|
291
|
-
})
|
|
292
|
-
} catch (error) {
|
|
293
|
-
console.error(`eroor`);
|
|
294
|
-
}
|
|
303
|
+
uiContext = value.getUIContext()
|
|
304
|
+
promptAction = uiContext?.getPromptAction();
|
|
305
|
+
contentNode = new ComponentContent(uiContext!, wrapBuilder(buildContextMenuWithNoSelect), realViewPoint);
|
|
295
306
|
})
|
|
296
307
|
}
|
|
297
308
|
}
|
package/harmony/context_menu.har
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-ohos/react-native-context-menu-view",
|
|
3
|
-
"version": "1.19.1-rc.
|
|
3
|
+
"version": "1.19.1-rc.2",
|
|
4
4
|
"description": "Use native context menu views from React Native",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"android",
|
|
23
23
|
"harmony"
|
|
24
24
|
],
|
|
25
|
-
"repository": "https://github.com
|
|
25
|
+
"repository": "https://github.com/react-native-oh-library/react-native-context-menu-view",
|
|
26
26
|
"author": "<Your Name> <your_email@your_provider.com> (https://github.com/<your_github_handle>)",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"bugs": {
|
|
29
|
-
"url": "https://github.com
|
|
29
|
+
"url": "https://github.com/react-native-oh-library/react-native-context-menu-view/issues"
|
|
30
30
|
},
|
|
31
|
-
"homepage": "https://github.com
|
|
31
|
+
"homepage": "https://github.com/react-native-oh-library/react-native-context-menu-view/tree/br_rnoh0.77#readme",
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "*",
|
|
34
34
|
"react-native": "*"
|