@react-native-ohos/react-native-context-menu-view 1.19.1-rc.1 → 1.19.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/README.md +1 -1
- package/harmony/context_menu/BuildProfile.ets +1 -1
- package/harmony/context_menu/oh-package.json5 +1 -1
- package/harmony/context_menu/src/main/ets/ContextMenuLongPress.ets +10 -5
- package/harmony/context_menu/src/main/ets/ContextMenuLongPressWithNoSelect.ets +6 -1
- package/harmony/context_menu/src/main/ets/ContextMenuTurboModule.ets +57 -44
- package/harmony/context_menu.har +0 -0
- package/package.json +4 -4
- package/react-native-context-menu-view.podspec +0 -26
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
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
|
3
3
|
*/
|
|
4
|
-
export const HAR_VERSION = '1.19.1
|
|
4
|
+
export const HAR_VERSION = '1.19.1';
|
|
5
5
|
export const BUILD_MODE_NAME = 'debug';
|
|
6
6
|
export const DEBUG = true;
|
|
7
7
|
export const TARGET_NAME = 'default';
|
|
@@ -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 {
|
|
@@ -227,7 +228,7 @@ export struct ContextMenuLongPress {
|
|
|
227
228
|
labelInfo: item.subtitle,
|
|
228
229
|
})
|
|
229
230
|
.contentFont({
|
|
230
|
-
family
|
|
231
|
+
family: this.menuFontName
|
|
231
232
|
})
|
|
232
233
|
.selected(item.selected)
|
|
233
234
|
.selectIcon(new SymbolGlyphModifier($r('sys.symbol.checkmark')).fontSize('24vp'))
|
|
@@ -267,7 +268,7 @@ export struct ContextMenuLongPress {
|
|
|
267
268
|
labelInfo: item.subtitle,
|
|
268
269
|
})
|
|
269
270
|
.contentFont({
|
|
270
|
-
family
|
|
271
|
+
family: this.menuFontName
|
|
271
272
|
})
|
|
272
273
|
.selected(item.selected)
|
|
273
274
|
.selectIcon(new SymbolGlyphModifier($r('sys.symbol.checkmark')).fontSize('24vp'))
|
|
@@ -309,7 +310,7 @@ export struct ContextMenuLongPress {
|
|
|
309
310
|
labelInfo: item.subtitle,
|
|
310
311
|
})
|
|
311
312
|
.contentFont({
|
|
312
|
-
family
|
|
313
|
+
family: this.menuFontName
|
|
313
314
|
})
|
|
314
315
|
.selected(item.selected)
|
|
315
316
|
.selectIcon(new SymbolGlyphModifier($r('sys.symbol.checkmark')).fontSize('24vp'))
|
|
@@ -348,7 +349,7 @@ export struct ContextMenuLongPress {
|
|
|
348
349
|
labelInfo: item.subtitle,
|
|
349
350
|
})
|
|
350
351
|
.contentFont({
|
|
351
|
-
family
|
|
352
|
+
family: this.menuFontName
|
|
352
353
|
})
|
|
353
354
|
.selected(item.selected)
|
|
354
355
|
.selectIcon(new SymbolGlyphModifier($r('sys.symbol.checkmark')).fontSize('24vp'))
|
|
@@ -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)
|
|
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)
|
|
373
|
+
})
|
|
374
|
+
.onDisAppear(() => {
|
|
370
375
|
this.menuCtx.rnInstance.postMessageToCpp('contextMenu::onCancel', {
|
|
371
376
|
itemTag: this.menuTag,
|
|
372
377
|
});
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { TurboModule, TurboModuleContext } from "@rnoh/react-native-openharmony/ts";
|
|
26
|
-
import { ComponentContent, window } from '@kit.ArkUI';
|
|
26
|
+
import { ComponentContent, PromptAction, window } from '@kit.ArkUI';
|
|
27
27
|
import { ContextMenuLongPress } from './ContextMenuLongPress';
|
|
28
28
|
import { RNOHContext } from '@rnoh/react-native-openharmony';
|
|
29
29
|
import { ContextMenuLongPressWithNoSelect } from './ContextMenuLongPressWithNoSelect';
|
|
@@ -41,6 +41,43 @@ function buildContextMenuWithNoSelect(realViewPoint: ESObject) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
|
|
44
|
+
let uiContext: UIContext | null = null;
|
|
45
|
+
let promptAction: PromptAction | null = null;
|
|
46
|
+
let contentNode: ComponentContent<Object> | null = null;
|
|
47
|
+
|
|
48
|
+
let realViewPointX = 0;
|
|
49
|
+
let realViewPointY = 0;
|
|
50
|
+
let windowWidth: number = 0;
|
|
51
|
+
let windowHeight: number = 0;
|
|
52
|
+
let rnOHContext: RNOHContext;
|
|
53
|
+
|
|
54
|
+
export function writeResult(newValue: SizeOptions) {
|
|
55
|
+
try {
|
|
56
|
+
let x = realViewPointX + (newValue.width as number);
|
|
57
|
+
let y = realViewPointY + (newValue.height as number);
|
|
58
|
+
|
|
59
|
+
if (x > windowWidth) {
|
|
60
|
+
realViewPointX = realViewPointX - (x - windowWidth) - 10;
|
|
61
|
+
}
|
|
62
|
+
if (y > windowHeight) {
|
|
63
|
+
realViewPointY = realViewPointY - (y - windowHeight) - 10;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
promptAction?.openCustomDialog(contentNode, {
|
|
67
|
+
alignment: DialogAlignment.TopStart,
|
|
68
|
+
offset: {
|
|
69
|
+
dx: realViewPointX,
|
|
70
|
+
dy: realViewPointY,
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
rnOHContext.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;
|
|
@@ -104,12 +141,14 @@ export class ContextMenuTurboModule extends TurboModule {
|
|
|
104
141
|
|
|
105
142
|
constructor(ctx: TurboModuleContext) {
|
|
106
143
|
super(ctx)
|
|
144
|
+
rnOHContext = ctx;
|
|
107
145
|
if (this.ctx.rnInstance.getArchitecture() === "C_API") {
|
|
108
146
|
//e为C层拦截的ArkUI_UIInputEvent
|
|
109
147
|
this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::TOUCH_EVENT", (e: ESObject) => {
|
|
110
148
|
//获取view坐标
|
|
111
149
|
console.log('ContextMenu:在ArkTs侧获取到了点击事件!TOUCH_EVENT,touchableViews:' +
|
|
112
|
-
JSON.stringify(e.touchableViews) + '最后点击的节点为View:' +
|
|
150
|
+
JSON.stringify(e.touchableViews) + '最后点击的节点为View:' +
|
|
151
|
+
JSON.stringify(e.touchableViews[e.touchableViews.length-1]));
|
|
113
152
|
//e.action进行获取点击事件的次数,进行判定
|
|
114
153
|
switch (e.action) {
|
|
115
154
|
case 1:
|
|
@@ -120,6 +159,9 @@ export class ContextMenuTurboModule extends TurboModule {
|
|
|
120
159
|
this.romWidth = e.touchableViews[0].width;
|
|
121
160
|
this.realViewPoint.romHeight = e.touchableViews[0].height;
|
|
122
161
|
this.romHeight = e.touchableViews[0].height;
|
|
162
|
+
|
|
163
|
+
windowWidth = this.romWidth;
|
|
164
|
+
windowHeight = this.romHeight;
|
|
123
165
|
break;
|
|
124
166
|
case 2:
|
|
125
167
|
//isCancel = true; move x1-x > 150 移动判断 y1-y >200
|
|
@@ -142,6 +184,9 @@ export class ContextMenuTurboModule extends TurboModule {
|
|
|
142
184
|
this.windowX = e.touchPoints[0].windowX;
|
|
143
185
|
this.realViewPoint.windowY = e.touchPoints[0].windowY;
|
|
144
186
|
this.windowY = e.touchPoints[0].windowY;
|
|
187
|
+
|
|
188
|
+
realViewPointX = this.windowX;
|
|
189
|
+
realViewPointY = this.windowY;
|
|
145
190
|
this.realViewPoint.touchViewActions = e.touchViewActions;
|
|
146
191
|
let selectedActions: ESObject = e.touchViewActions;
|
|
147
192
|
if (!this.longPressLock) {
|
|
@@ -197,6 +242,10 @@ export class ContextMenuTurboModule extends TurboModule {
|
|
|
197
242
|
this.windowX = e.touchPoints[0].windowX;
|
|
198
243
|
this.realViewPoint.windowY = e.touchPoints[0].windowY;
|
|
199
244
|
this.windowY = e.touchPoints[0].windowY;
|
|
245
|
+
|
|
246
|
+
realViewPointX = this.windowX;
|
|
247
|
+
realViewPointY = this.windowY;
|
|
248
|
+
|
|
200
249
|
//此处获取actions值
|
|
201
250
|
this.realViewPoint.touchViewActions = e.touchViewActions;
|
|
202
251
|
//当获取到了view视图,并且dropdownMenuMode为true的时候,进入单点效果.
|
|
@@ -244,54 +293,18 @@ export class ContextMenuTurboModule extends TurboModule {
|
|
|
244
293
|
onTouch(realViewPoint: Object) {
|
|
245
294
|
window.getLastWindow(this.ctx.uiAbilityContext)
|
|
246
295
|
.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
|
-
}
|
|
296
|
+
uiContext = value.getUIContext()
|
|
297
|
+
promptAction = uiContext?.getPromptAction();
|
|
298
|
+
contentNode = new ComponentContent(uiContext!, wrapBuilder(buildContextMenu), realViewPoint);
|
|
268
299
|
})
|
|
269
300
|
}
|
|
270
301
|
|
|
271
302
|
onTouchWithNoSelect(realViewPoint: Object) {
|
|
272
303
|
window.getLastWindow(this.ctx.uiAbilityContext)
|
|
273
304
|
.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
|
-
}
|
|
305
|
+
uiContext = value.getUIContext()
|
|
306
|
+
promptAction = uiContext?.getPromptAction();
|
|
307
|
+
contentNode = new ComponentContent(uiContext!, wrapBuilder(buildContextMenuWithNoSelect), realViewPoint);
|
|
295
308
|
})
|
|
296
309
|
}
|
|
297
310
|
}
|
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
|
|
3
|
+
"version": "1.19.1",
|
|
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": "*"
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require "json"
|
|
2
|
-
|
|
3
|
-
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
-
|
|
5
|
-
Pod::Spec.new do |s|
|
|
6
|
-
s.name = "react-native-context-menu-view"
|
|
7
|
-
s.version = package["version"]
|
|
8
|
-
s.summary = package["description"]
|
|
9
|
-
s.description = <<-DESC
|
|
10
|
-
react-native-context-menu-view
|
|
11
|
-
DESC
|
|
12
|
-
s.homepage = "https://github.com/mpiannucci/react-native-context-menu-view"
|
|
13
|
-
s.license = "MIT"
|
|
14
|
-
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
|
|
15
|
-
s.authors = { "Matthew Iannucci" => "mpiannucci@gmail.com" }
|
|
16
|
-
s.platforms = { :ios => "9.0" }
|
|
17
|
-
s.source = { :git => "https://github.com/mpiannucci/react-native-context-menu-view.git", :tag => "#{s.version}" }
|
|
18
|
-
|
|
19
|
-
s.source_files = "ios/**/*.{h,m,swift}"
|
|
20
|
-
s.requires_arc = true
|
|
21
|
-
|
|
22
|
-
s.dependency "React"
|
|
23
|
-
# ...
|
|
24
|
-
# s.dependency "..."
|
|
25
|
-
end
|
|
26
|
-
|