@react-native-ohos/react-native-context-menu-view 1.19.1-rc.2 → 1.20.0-beta.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.OpenSource CHANGED
@@ -2,10 +2,10 @@
2
2
  {
3
3
  "Name": "react-native-context-menu-view",
4
4
  "License": "MIT License",
5
- "License File": "https://github.com/mpiannucci/react-native-context-menu-view/blob/v1.19.0/LICENSE",
6
- "Version Number": "1.19.0",
5
+ "License File": "https://github.com/mpiannucci/react-native-context-menu-view/blob/v1.21.0/LICENSE",
6
+ "Version Number": "1.21.0",
7
7
  "Owner" : "xiafeng@huawei.com",
8
- "Upstream URL": "https://github.com/mpiannucci/react-native-context-menu-view/tree/v1.19.0",
8
+ "Upstream URL": "https://github.com/mpiannucci/react-native-context-menu-view/tree/v1.21.0",
9
9
  "Description": "Use native context menus in React Native"
10
10
  }
11
11
  ]
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # @react-native-ohos/react-native-context-menu-view
2
2
 
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)
3
+ This project is based on [react-native-context-menu-view@v1.21.0](https://github.com/mpiannucci/react-native-context-menu-view/tree/v1.21.0)
4
4
 
5
5
  ## Documentation
6
6
 
7
- - [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-context-menu-view.md)
7
+ - [中文](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/zh-cn/react-native-context-menu-view.md)
8
8
 
9
- - [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-context-menu-view.md)
9
+ - [English](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/en/react-native-context-menu-view.md)
10
10
 
11
11
  ## License
12
12
 
13
- This library is licensed under [The MIT License (MIT)](https://github.com/mpiannucci/react-native-context-menu-view/blob/v1.19.0/LICENSE)
13
+ This library is licensed under [The MIT License (MIT)](https://github.com/mpiannucci/react-native-context-menu-view/blob/v1.21.0/LICENSE)
@@ -1,17 +1,17 @@
1
- /**
2
- * Use these variables when you tailor your ArkTS code. They must be of the const type.
3
- */
4
- export const HAR_VERSION = '1.19.1-rc.1';
5
- export const BUILD_MODE_NAME = 'debug';
6
- export const DEBUG = true;
7
- export const TARGET_NAME = 'default';
8
-
9
- /**
10
- * BuildProfile Class is used only for compatibility purposes.
11
- */
12
- export default class BuildProfile {
13
- static readonly HAR_VERSION = HAR_VERSION;
14
- static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
15
- static readonly DEBUG = DEBUG;
16
- static readonly TARGET_NAME = TARGET_NAME;
1
+ /**
2
+ * Use these variables when you tailor your ArkTS code. They must be of the const type.
3
+ */
4
+ export const HAR_VERSION = '1.20.0-beta.2';
5
+ export const BUILD_MODE_NAME = 'debug';
6
+ export const DEBUG = true;
7
+ export const TARGET_NAME = 'default';
8
+
9
+ /**
10
+ * BuildProfile Class is used only for compatibility purposes.
11
+ */
12
+ export default class BuildProfile {
13
+ static readonly HAR_VERSION = HAR_VERSION;
14
+ static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
15
+ static readonly DEBUG = DEBUG;
16
+ static readonly TARGET_NAME = TARGET_NAME;
17
17
  }
@@ -22,5 +22,6 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
+ import {ContextMenuPackage} from './src/main/ets/ContextMenuPackage'
25
26
  export * from './ts'
26
- export * from './src/main/ets/ContextMenuLongPress'
27
+ export default ContextMenuPackage;
@@ -2,7 +2,7 @@
2
2
  license: 'ISC',
3
3
  types: '',
4
4
  name: "@react-native-ohos/react-native-context-menu-view",
5
- version: '1.19.1-rc.2',
5
+ version: '1.20.0-beta.2',
6
6
  description: '',
7
7
  main: 'index.ets',
8
8
  type: 'module',
@@ -228,7 +228,7 @@ export struct ContextMenuLongPress {
228
228
  labelInfo: item.subtitle,
229
229
  })
230
230
  .contentFont({
231
- family : this.menuFontName
231
+ family: this.menuFontName
232
232
  })
233
233
  .selected(item.selected)
234
234
  .selectIcon(new SymbolGlyphModifier($r('sys.symbol.checkmark')).fontSize('24vp'))
@@ -236,6 +236,9 @@ export struct ContextMenuLongPress {
236
236
  .enabled(item.disabled)
237
237
  .contentFontColor(item.titleColor)
238
238
  .onClick(() => {
239
+ // fix 二级菜单不能连续点击
240
+ this.isTouch = false;
241
+ this.isTouchWithNoSelect = false;
239
242
  //当item.inlineChildren默认为false,表示以二级目录展示
240
243
  //true的时候,以同目录展示
241
244
  this.isTouch = true && (!item.inlineChildren) && (item.d_childActions !== undefined);
@@ -268,7 +271,7 @@ export struct ContextMenuLongPress {
268
271
  labelInfo: item.subtitle,
269
272
  })
270
273
  .contentFont({
271
- family : this.menuFontName
274
+ family: this.menuFontName
272
275
  })
273
276
  .selected(item.selected)
274
277
  .selectIcon(new SymbolGlyphModifier($r('sys.symbol.checkmark')).fontSize('24vp'))
@@ -276,6 +279,9 @@ export struct ContextMenuLongPress {
276
279
  .enabled(item.disabled)
277
280
  .contentFontColor(item.titleColor)
278
281
  .onClick(() => {
282
+ // fix 二级菜单不能连续点击
283
+ this.isTouch = false;
284
+ this.isTouchWithNoSelect = false;
279
285
  //当item.inlineChildren默认为false,表示以二级目录展示
280
286
  //true的时候,以同目录展示
281
287
  this.isTouch = true && (!item.inlineChildren) && (item.d_childActions !== undefined);
@@ -310,7 +316,7 @@ export struct ContextMenuLongPress {
310
316
  labelInfo: item.subtitle,
311
317
  })
312
318
  .contentFont({
313
- family : this.menuFontName
319
+ family: this.menuFontName
314
320
  })
315
321
  .selected(item.selected)
316
322
  .selectIcon(new SymbolGlyphModifier($r('sys.symbol.checkmark')).fontSize('24vp'))
@@ -318,6 +324,9 @@ export struct ContextMenuLongPress {
318
324
  .enabled(item.disabled)
319
325
  .contentFontColor(item.titleColor)
320
326
  .onClick(() => {
327
+ // fix 二级菜单不能连续点击
328
+ this.isTouch = false;
329
+ this.isTouchWithNoSelect = false;
321
330
  //当item.inlineChildren默认为false,表示以二级目录展示
322
331
  //true的时候,以同目录展示
323
332
  this.isTouch = true && (!item.inlineChildren) && (item.d_childActions !== undefined);
@@ -349,7 +358,7 @@ export struct ContextMenuLongPress {
349
358
  labelInfo: item.subtitle,
350
359
  })
351
360
  .contentFont({
352
- family : this.menuFontName
361
+ family: this.menuFontName
353
362
  })
354
363
  .selected(item.selected)
355
364
  .selectIcon(new SymbolGlyphModifier($r('sys.symbol.checkmark')).fontSize('24vp'))
@@ -357,6 +366,9 @@ export struct ContextMenuLongPress {
357
366
  .enabled(item.disabled)
358
367
  .contentFontColor(item.titleColor)
359
368
  .onClick(() => {
369
+ // fix 二级菜单不能连续点击
370
+ this.isTouch = false;
371
+ this.isTouchWithNoSelect = false;
360
372
  //当item.inlineChildren默认为false,表示以二级目录展示
361
373
  //true的时候,以同目录展示
362
374
  this.isTouch = true && (!item.inlineChildren) && (item.d_childActions !== undefined);
@@ -387,7 +399,7 @@ export struct ContextMenuLongPress {
387
399
  }.backgroundColor('white')
388
400
  }
389
401
  .onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
390
- writeResult(newValue.width, newValue.height)
402
+ writeResult(newValue)
391
403
  })
392
404
  .onDisAppear(() => {
393
405
  this.menuCtx.rnInstance.postMessageToCpp('contextMenu::onCancel', {
@@ -237,6 +237,9 @@ export struct ContextMenuLongPressWithNoSelect {
237
237
  .enabled(item.disabled)
238
238
  .contentFontColor(item.titleColor)
239
239
  .onClick(() => {
240
+ // fix 二级菜单不能连续点击
241
+ this.isTouch = false;
242
+ this.isTouchWithNoSelect = false;
240
243
  //当item.inlineChildren默认为false,表示以二级目录展示
241
244
  //true的时候,以同目录展示
242
245
  this.isTouch = true && (!item.inlineChildren) && (item.d_childActions !== undefined);
@@ -272,6 +275,9 @@ export struct ContextMenuLongPressWithNoSelect {
272
275
  .enabled(item.disabled)
273
276
  .contentFontColor(item.titleColor)
274
277
  .onClick(() => {
278
+ // fix 二级菜单不能连续点击
279
+ this.isTouch = false;
280
+ this.isTouchWithNoSelect = false;
275
281
  //当item.inlineChildren默认为false,表示以二级目录展示
276
282
  //true的时候,以同目录展示
277
283
  this.isTouch = true && (!item.inlineChildren) && (item.d_childActions !== undefined);
@@ -309,6 +315,9 @@ export struct ContextMenuLongPressWithNoSelect {
309
315
  .enabled(item.disabled)
310
316
  .contentFontColor(item.titleColor)
311
317
  .onClick(() => {
318
+ // fix 二级菜单不能连续点击
319
+ this.isTouch = false;
320
+ this.isTouchWithNoSelect = false;
312
321
  //当item.inlineChildren默认为false,表示以二级目录展示
313
322
  //true的时候,以同目录展示
314
323
  this.isTouch = true && (!item.inlineChildren) && (item.d_childActions !== undefined);
@@ -342,6 +351,9 @@ export struct ContextMenuLongPressWithNoSelect {
342
351
  .enabled(item.disabled)
343
352
  .contentFontColor(item.titleColor)
344
353
  .onClick(() => {
354
+ // fix 二级菜单不能连续点击
355
+ this.isTouch = false;
356
+ this.isTouchWithNoSelect = false;
345
357
  //当item.inlineChildren默认为false,表示以二级目录展示
346
358
  //true的时候,以同目录展示
347
359
  this.isTouch = true && (!item.inlineChildren) && (item.d_childActions !== undefined);
@@ -369,7 +381,7 @@ export struct ContextMenuLongPressWithNoSelect {
369
381
  }.backgroundColor('white')
370
382
  }
371
383
  .onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
372
- writeResult(newValue.width, newValue.height)
384
+ writeResult(newValue)
373
385
  })
374
386
  .onDisAppear(() => {
375
387
  this.menuCtx.rnInstance.postMessageToCpp('contextMenu::onCancel', {
@@ -22,7 +22,8 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import {RNPackage, TurboModulesFactory} from '@rnoh/react-native-openharmony/ts';
25
+ import {TurboModulesFactory} from '@rnoh/react-native-openharmony/ts';
26
+ import { RNOHPackage } from '@rnoh/react-native-openharmony';
26
27
  import type {TurboModule, TurboModuleContext} from '@rnoh/react-native-openharmony/ts';
27
28
  import { ContextMenuTurboModule } from './ContextMenuTurboModule';
28
29
 
@@ -40,7 +41,7 @@ class ContextMenuTurboModulesFactory extends TurboModulesFactory {
40
41
  }
41
42
  }
42
43
 
43
- export class ContextMenuPackage extends RNPackage {
44
+ export class ContextMenuPackage extends RNOHPackage {
44
45
  createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
45
46
  return new ContextMenuTurboModulesFactory(ctx);
46
47
  }
@@ -93,7 +93,7 @@ export struct ContextMenuThreeMenu {
93
93
  this.menuTag = this.menuTag;
94
94
  Logger.info('2024-3menu:' + JSON.stringify(this.longPress))
95
95
  //menu的大标题
96
- this.listDate = this.longPress;
96
+ this.listDate = JSON.parse(JSON.stringify(this.longPress));
97
97
  Logger.info('2024-3menu,this.listDate:' + JSON.stringify(this.listDate))
98
98
  for (let i = 0; i < this.listDate.length; i++) {
99
99
  if (this.listDate[i] !== null && this.listDate[i] !== undefined) {
@@ -93,7 +93,7 @@ export struct ContextMenuThreeMenuWithNoSelect {
93
93
  this.menuTag = this.menuTag;
94
94
  Logger.info('2024-3menu:' + JSON.stringify(this.longPress))
95
95
  //menu的大标题
96
- this.listDate = this.longPress;
96
+ this.listDate = JSON.parse(JSON.stringify(this.longPress));
97
97
  Logger.info('2024-3menu,this.listDate:' + JSON.stringify(this.listDate))
98
98
  for (let i = 0; i < this.listDate.length; i++) {
99
99
  if (this.listDate[i] !== null && this.listDate[i] !== undefined) {
@@ -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,19 +41,20 @@ function buildContextMenuWithNoSelect(realViewPoint: ESObject) {
41
41
  }
42
42
 
43
43
 
44
- let uiContext = null;
45
- let promptAction = null;
46
- let contentNode = null;
44
+ let uiContext: UIContext | null = null;
45
+ let promptAction: PromptAction | null = null;
46
+ let contentNode: ComponentContent<Object> | null = null;
47
47
 
48
48
  let realViewPointX = 0;
49
49
  let realViewPointY = 0;
50
50
  let windowWidth: number = 0;
51
51
  let windowHeight: number = 0;
52
+ let rnOHContext: RNOHContext;
52
53
 
53
- export function writeResult(width: Length, height: Length) {
54
+ export function writeResult(newValue: SizeOptions) {
54
55
  try {
55
- let x = realViewPointX + (width as number);
56
- let y = realViewPointY + (height as number);
56
+ let x = realViewPointX + (newValue.width as number);
57
+ let y = realViewPointY + (newValue.height as number);
57
58
 
58
59
  if (x > windowWidth) {
59
60
  realViewPointX = realViewPointX - (x - windowWidth) - 10;
@@ -69,8 +70,7 @@ export function writeResult(width: Length, height: Length) {
69
70
  dy: realViewPointY,
70
71
  }
71
72
  })
72
- this.menuHeight = 0;
73
- this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::CLOSE_MENU", () => {
73
+ rnOHContext.rnInstance.cppEventEmitter.subscribe("RNGH::CLOSE_MENU", () => {
74
74
  promptAction?.closeCustomDialog(contentNode);
75
75
  })
76
76
  } catch (error) {
@@ -141,12 +141,14 @@ export class ContextMenuTurboModule extends TurboModule {
141
141
 
142
142
  constructor(ctx: TurboModuleContext) {
143
143
  super(ctx)
144
+ rnOHContext = ctx;
144
145
  if (this.ctx.rnInstance.getArchitecture() === "C_API") {
145
146
  //e为C层拦截的ArkUI_UIInputEvent
146
147
  this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::TOUCH_EVENT", (e: ESObject) => {
147
148
  //获取view坐标
148
149
  console.log('ContextMenu:在ArkTs侧获取到了点击事件!TOUCH_EVENT,touchableViews:' +
149
- JSON.stringify(e.touchableViews) + '最后点击的节点为View:' + JSON.stringify(e.touchableViews[e.touchableViews.length-1]));
150
+ JSON.stringify(e.touchableViews) + '最后点击的节点为View:' +
151
+ JSON.stringify(e.touchableViews[e.touchableViews.length-1]));
150
152
  //e.action进行获取点击事件的次数,进行判定
151
153
  switch (e.action) {
152
154
  case 1:
@@ -167,6 +169,10 @@ export class ContextMenuTurboModule extends TurboModule {
167
169
  this.longPressTimestamp = e.timestamp / Math.pow(10, 6);
168
170
  this.longResult = this.longPressTimestamp - this.downTimestamp
169
171
  if (e.touchableViews[e.touchableViews.length-1] && !(e.dropdownMenuMode) && this.longResult >= 500) {
172
+ // fix 外层disabled不生效
173
+ if (e.disabled) {
174
+ return;
175
+ }
170
176
  //2024.12.06 fix:当处于多层嵌套外层情况下,tag值会错误
171
177
  this.realViewPoint.tag = e.rootTag;
172
178
  this.realViewPoint.x = e.touchableViews[e.touchableViews.length-1].x;
@@ -226,6 +232,10 @@ export class ContextMenuTurboModule extends TurboModule {
226
232
  //当点击外部的stack区域时候,获取的view只有两个,主屏幕和contextmenu容器,逻辑上是点击view才会触发menu
227
233
  // dropdownMenuMode-->true---->onTouch(),如果此时点击的事件大于500ms则不触发点击事件,如果小于500ms则触发点击效果
228
234
  if (e.touchableViews[e.touchableViews.length-1] && e.dropdownMenuMode && this.result < 500) {
235
+ // fix 外层disabled不生效
236
+ if (e.disabled) {
237
+ return;
238
+ }
229
239
  this.realViewPoint.tag = e.rootTag;
230
240
  this.realViewPoint.x = e.touchableViews[e.touchableViews.length-1].x;
231
241
  this.realViewPoint.y = e.touchableViews[e.touchableViews.length-1].y;
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.2",
3
+ "version": "1.20.0-beta.2",
4
4
  "description": "Use native context menu views from React Native",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -14,7 +14,8 @@
14
14
  "!ios/build",
15
15
  "!**/__tests__",
16
16
  "!**/__fixtures__",
17
- "!**/__mocks__"
17
+ "!**/__mocks__",
18
+ "!build"
18
19
  ],
19
20
  "keywords": [
20
21
  "react-native",
@@ -34,6 +35,12 @@
34
35
  "react-native": "*"
35
36
  },
36
37
  "harmony": {
37
- "alias": "react-native-context-menu-view"
38
+ "alias": "react-native-context-menu-view",
39
+ "autolinking": {
40
+ "etsPackageClassName":"ContextMenuPackage",
41
+ "cppPackageClassName":"ContextMenuPackage",
42
+ "cmakeLibraryTargetName": "rnoh_context_menu",
43
+ "ohPackageName": "@react-native-ohos/react-native-context-menu-view"
44
+ }
38
45
  }
39
46
  }