@react-native-ohos/react-native-context-menu-view 1.16.1-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 +21 -0
- package/README.OpenSource +11 -0
- package/README.md +13 -0
- package/harmony/context_menu/BuildProfile.ets +17 -0
- package/harmony/context_menu/build-profile.json5 +12 -0
- package/harmony/context_menu/hvigorfile.ts +2 -0
- package/harmony/context_menu/index.ets +28 -0
- package/harmony/context_menu/oh-package.json5 +12 -0
- package/harmony/context_menu/src/main/cpp/CMakeLists.txt +8 -0
- package/harmony/context_menu/src/main/cpp/ComponentDescriptors.h +18 -0
- package/harmony/context_menu/src/main/cpp/ContextMenuJSIBinder.h +58 -0
- package/harmony/context_menu/src/main/cpp/ContextMenuPackage.h +140 -0
- package/harmony/context_menu/src/main/cpp/ContextMenuTurboModule.cpp +36 -0
- package/harmony/context_menu/src/main/cpp/ContextMenuTurboModule.h +38 -0
- package/harmony/context_menu/src/main/cpp/EventEmitters.cpp +49 -0
- package/harmony/context_menu/src/main/cpp/EventEmitters.h +41 -0
- package/harmony/context_menu/src/main/cpp/Props.cpp +33 -0
- package/harmony/context_menu/src/main/cpp/Props.h +115 -0
- package/harmony/context_menu/src/main/cpp/RTNContextMenuComponentInstance.cpp +286 -0
- package/harmony/context_menu/src/main/cpp/RTNContextMenuComponentInstance.h +165 -0
- package/harmony/context_menu/src/main/cpp/ShadowNodes.cpp +15 -0
- package/harmony/context_menu/src/main/cpp/ShadowNodes.h +30 -0
- package/harmony/context_menu/src/main/cpp/States.cpp +15 -0
- package/harmony/context_menu/src/main/cpp/States.h +34 -0
- package/harmony/context_menu/src/main/ets/ContextMenuLongPress.ets +374 -0
- package/harmony/context_menu/src/main/ets/ContextMenuLongPressWithNoSelect.ets +356 -0
- package/harmony/context_menu/src/main/ets/ContextMenuPackage.ets +48 -0
- package/harmony/context_menu/src/main/ets/ContextMenuThreeMenu.ets +224 -0
- package/harmony/context_menu/src/main/ets/ContextMenuThreeMenuWithNoSelect.ets +221 -0
- package/harmony/context_menu/src/main/ets/ContextMenuTurboModule.ets +293 -0
- package/harmony/context_menu/src/main/ets/ContextMenuTwoMenu.ets +209 -0
- package/harmony/context_menu/src/main/ets/ContextMenuTwoMenuWithNoSelect.ets +207 -0
- package/harmony/context_menu/src/main/ets/Logger.ets +64 -0
- package/harmony/context_menu/src/main/module.json5 +7 -0
- package/harmony/context_menu/src/main/resources/base/element/string.json +8 -0
- package/harmony/context_menu/src/main/resources/base/media/airplane_fill.png +0 -0
- package/harmony/context_menu/src/main/resources/base/media/background.png +0 -0
- package/harmony/context_menu/src/main/resources/base/media/foreground.png +0 -0
- package/harmony/context_menu/src/main/resources/base/media/layered_image.json +7 -0
- package/harmony/context_menu/src/main/resources/base/media/startIcon.png +0 -0
- package/harmony/context_menu/src/main/resources/base/profile/backup_config.json +3 -0
- package/harmony/context_menu/src/main/resources/base/profile/main_pages.json +5 -0
- package/harmony/context_menu/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/context_menu/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/context_menu/ts.ets +26 -0
- package/harmony/context_menu.har +0 -0
- package/index.js +44 -0
- package/package.json +49 -0
- package/react-native-context-menu-view.podspec +26 -0
- package/src/RTNContextMenuNativeComponent.ts +50 -0
|
@@ -0,0 +1,209 @@
|
|
|
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 { RNOHContext, } from '@rnoh/react-native-openharmony'
|
|
26
|
+
import Logger from './Logger';
|
|
27
|
+
import { SymbolGlyphModifier } from '@kit.ArkUI';
|
|
28
|
+
import { ContextMenuThreeMenu } from './ContextMenuThreeMenu';
|
|
29
|
+
import { ContextMenuThreeMenuWithNoSelect } from './ContextMenuThreeMenuWithNoSelect';
|
|
30
|
+
|
|
31
|
+
//这里的属性类型要和ContextMenuTurboModule.ets下的ContextMenuProps一致
|
|
32
|
+
interface ContextMenuProps {
|
|
33
|
+
tag?: number;
|
|
34
|
+
width?: number;
|
|
35
|
+
height?: number;
|
|
36
|
+
x?: number;
|
|
37
|
+
y?: number;
|
|
38
|
+
windowX?: number;
|
|
39
|
+
windowY?: number;
|
|
40
|
+
title?: string;
|
|
41
|
+
action?: string;
|
|
42
|
+
dropdownMenuMode?: boolean;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
subtitle?: string;
|
|
45
|
+
|
|
46
|
+
// disabledArray?: Array<boolean>;
|
|
47
|
+
selected?: boolean;
|
|
48
|
+
previewBackgroundColor?: string;
|
|
49
|
+
actionsTitle?: string;
|
|
50
|
+
touchViewActions?: ContextMenuProps
|
|
51
|
+
ctx: RNOHContext
|
|
52
|
+
romWidth?: number;
|
|
53
|
+
romHeight?: number;
|
|
54
|
+
systemIcon?: string;
|
|
55
|
+
icon?: string;
|
|
56
|
+
destructive?: string
|
|
57
|
+
iconColor?: string;
|
|
58
|
+
|
|
59
|
+
//二级目录
|
|
60
|
+
inlineChildren?: boolean;
|
|
61
|
+
d_childActions?: ContextMenuProps;
|
|
62
|
+
childActionsTag?: number;
|
|
63
|
+
|
|
64
|
+
//2+目录
|
|
65
|
+
childActions?: ContextMenuProps;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Component
|
|
69
|
+
export struct ContextMenuTwoMenu {
|
|
70
|
+
public static readonly NAME = "ContextMenuTwoMenu"
|
|
71
|
+
menuCtx!: RNOHContext;
|
|
72
|
+
menuTag: number = 0;
|
|
73
|
+
longPress: ESObject = []
|
|
74
|
+
@State realViewPoint: Object = [];
|
|
75
|
+
@State listDate: ContextMenuProps[] = [];
|
|
76
|
+
@State menuIndexPath: number[] = [];
|
|
77
|
+
@State menuDestructive: string = '';
|
|
78
|
+
@State childActionsListDate: ESObject[] = [];
|
|
79
|
+
@State isTouchViewNumber: number = 0;
|
|
80
|
+
@State isChildActionsTouchViewNumber: number = 0;
|
|
81
|
+
@State menuChildActions: ContextMenuProps[] = [];
|
|
82
|
+
@State menuChild: ESObject[] = [];
|
|
83
|
+
@State deepChildActions: ESObject[] = [];
|
|
84
|
+
@State nextMenu: ESObject[] = [];
|
|
85
|
+
@State selectedFlag: number = 0;
|
|
86
|
+
|
|
87
|
+
aboutToAppear() {
|
|
88
|
+
//从前一个菜单传递过来的
|
|
89
|
+
this.longPress = this.realViewPoint;
|
|
90
|
+
this.menuCtx = this.menuCtx;
|
|
91
|
+
this.menuTag = this.menuTag;
|
|
92
|
+
this.listDate = this.longPress;
|
|
93
|
+
Logger.info('2024-2menu,this.listDate:' + JSON.stringify(this.listDate))
|
|
94
|
+
//二级目录的enable在一级目录就应该转换过,所以这里不用转换
|
|
95
|
+
//遍历传递回前端的indexPath,indexPath只会计算子节点index
|
|
96
|
+
//第一个节点表示对应的深层目录,从3级起算
|
|
97
|
+
for (let i = 0; i < this.listDate.length; i++) {
|
|
98
|
+
this.menuIndexPath[i+1] = i;
|
|
99
|
+
}
|
|
100
|
+
for (let i = 0; i < this.listDate.length; i++) {
|
|
101
|
+
if (this.longPress[i].selected) {
|
|
102
|
+
this.selectedFlag++;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
//退出组件
|
|
108
|
+
aboutToDisappear() {
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@Builder
|
|
112
|
+
NextMenu() {
|
|
113
|
+
ContextMenuThreeMenu(
|
|
114
|
+
{
|
|
115
|
+
realViewPoint: this.nextMenu,
|
|
116
|
+
menuCtx: this.menuCtx,
|
|
117
|
+
menuTag: this.menuTag
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@Builder
|
|
122
|
+
NextMenuWithNoSelect() {
|
|
123
|
+
ContextMenuThreeMenuWithNoSelect(
|
|
124
|
+
{
|
|
125
|
+
realViewPoint: this.nextMenu,
|
|
126
|
+
menuCtx: this.menuCtx,
|
|
127
|
+
menuTag: this.menuTag
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
build() {
|
|
132
|
+
Menu() {
|
|
133
|
+
ForEach(this.listDate, (childItem: ContextMenuProps, index1) => {
|
|
134
|
+
if (childItem.systemIcon) {
|
|
135
|
+
MenuItem({
|
|
136
|
+
content: childItem.title,
|
|
137
|
+
symbolEndIcon: new SymbolGlyphModifier($r(childItem.systemIcon)).fontSize('24vp')
|
|
138
|
+
.fontColor([childItem.iconColor]),
|
|
139
|
+
labelInfo: childItem.subtitle,
|
|
140
|
+
builder: (): void => {
|
|
141
|
+
if (childItem.childActions !== undefined) {
|
|
142
|
+
this.nextMenu = this.longPress[index1].childActions;
|
|
143
|
+
if (this.selectedFlag !== 0) {
|
|
144
|
+
this.NextMenu();
|
|
145
|
+
} else {
|
|
146
|
+
this.NextMenuWithNoSelect();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
})//selected复选标记,根据传入的selected来判断selected为默认为false,不显示
|
|
151
|
+
.selected(childItem.selected)
|
|
152
|
+
.selectIcon(new SymbolGlyphModifier($r('sys.symbol.checkmark')).fontSize('24vp'))
|
|
153
|
+
.alignSelf(ItemAlign.Start)
|
|
154
|
+
.enabled(childItem.disabled)
|
|
155
|
+
.contentFontColor(childItem.destructive)
|
|
156
|
+
.onClick(() => {
|
|
157
|
+
this.nextMenu = this.longPress[index1].childActions;
|
|
158
|
+
this.isTouchViewNumber = index1;
|
|
159
|
+
if (childItem.inlineChildren || (childItem.childActions == undefined)) {
|
|
160
|
+
this.menuCtx.rnInstance.postMessageToCpp('contextMenu::SET_NATIVE_RESPONDERS_BLOCK', {
|
|
161
|
+
itemTitle: childItem.title,
|
|
162
|
+
itemTag: this.menuTag,
|
|
163
|
+
itemIndex: index1,
|
|
164
|
+
itemIndexPath: this.menuIndexPath,
|
|
165
|
+
itemInlineChildren: childItem.inlineChildren
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
} else {
|
|
171
|
+
MenuItem({
|
|
172
|
+
content: childItem.title,
|
|
173
|
+
endIcon: $r(childItem.icon),
|
|
174
|
+
labelInfo: childItem.subtitle,
|
|
175
|
+
builder: (): void => {
|
|
176
|
+
if (childItem.childActions !== undefined) {
|
|
177
|
+
this.nextMenu = this.longPress[index1].childActions;
|
|
178
|
+
if (this.selectedFlag !== 0) {
|
|
179
|
+
this.NextMenu();
|
|
180
|
+
} else {
|
|
181
|
+
this.NextMenuWithNoSelect();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
})//selected复选标记,根据传入的selected来判断selected为默认为false,不显示
|
|
186
|
+
.selected(childItem.selected)
|
|
187
|
+
.selectIcon(new SymbolGlyphModifier($r('sys.symbol.checkmark')).fontSize('24vp'))
|
|
188
|
+
.alignSelf(ItemAlign.Start)
|
|
189
|
+
.enabled(childItem.disabled)
|
|
190
|
+
.contentFontColor(childItem.destructive)
|
|
191
|
+
.onClick(() => {
|
|
192
|
+
this.nextMenu = this.longPress[index1].childActions;
|
|
193
|
+
this.isTouchViewNumber = index1;
|
|
194
|
+
if (childItem.inlineChildren || (childItem.childActions == undefined)) {
|
|
195
|
+
this.menuCtx.rnInstance.postMessageToCpp('contextMenu::SET_NATIVE_RESPONDERS_BLOCK', {
|
|
196
|
+
itemTitle: childItem.title,
|
|
197
|
+
itemTag: this.menuTag,
|
|
198
|
+
itemIndex: index1,
|
|
199
|
+
itemIndexPath: this.menuIndexPath,
|
|
200
|
+
itemInlineChildren: childItem.inlineChildren
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
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 { RNOHContext, } from '@rnoh/react-native-openharmony'
|
|
26
|
+
import Logger from './Logger';
|
|
27
|
+
import { SymbolGlyphModifier } from '@kit.ArkUI';
|
|
28
|
+
import { ContextMenuThreeMenu } from './ContextMenuThreeMenu';
|
|
29
|
+
import { ContextMenuThreeMenuWithNoSelect } from './ContextMenuThreeMenuWithNoSelect';
|
|
30
|
+
|
|
31
|
+
//这里的属性类型要和ContextMenuTurboModule.ets下的ContextMenuProps一致
|
|
32
|
+
interface ContextMenuProps {
|
|
33
|
+
tag?: number;
|
|
34
|
+
width?: number;
|
|
35
|
+
height?: number;
|
|
36
|
+
x?: number;
|
|
37
|
+
y?: number;
|
|
38
|
+
windowX?: number;
|
|
39
|
+
windowY?: number;
|
|
40
|
+
title?: string;
|
|
41
|
+
action?: string;
|
|
42
|
+
dropdownMenuMode?: boolean;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
subtitle?: string;
|
|
45
|
+
|
|
46
|
+
// disabledArray?: Array<boolean>;
|
|
47
|
+
selected?: boolean;
|
|
48
|
+
previewBackgroundColor?: string;
|
|
49
|
+
actionsTitle?: string;
|
|
50
|
+
touchViewActions?: ContextMenuProps
|
|
51
|
+
ctx: RNOHContext
|
|
52
|
+
romWidth?: number;
|
|
53
|
+
romHeight?: number;
|
|
54
|
+
systemIcon?: string;
|
|
55
|
+
icon?: string;
|
|
56
|
+
destructive?: string
|
|
57
|
+
iconColor?: string;
|
|
58
|
+
|
|
59
|
+
//二级目录
|
|
60
|
+
inlineChildren?: boolean;
|
|
61
|
+
d_childActions?: ContextMenuProps;
|
|
62
|
+
childActionsTag?: number;
|
|
63
|
+
|
|
64
|
+
//2+目录
|
|
65
|
+
childActions?: ContextMenuProps;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Component
|
|
69
|
+
export struct ContextMenuTwoMenuWithNoSelect {
|
|
70
|
+
public static readonly NAME = "ContextMenuTwoMenuWithNoSelect"
|
|
71
|
+
menuCtx!: RNOHContext;
|
|
72
|
+
menuTag: number = 0;
|
|
73
|
+
longPress: ESObject = []
|
|
74
|
+
@State realViewPoint: Object = [];
|
|
75
|
+
@State listDate: ContextMenuProps[] = [];
|
|
76
|
+
@State menuIndexPath: number[] = [];
|
|
77
|
+
@State menuDestructive: string = '';
|
|
78
|
+
@State childActionsListDate: ESObject[] = [];
|
|
79
|
+
@State isTouch: boolean | undefined = false;
|
|
80
|
+
@State isTouchViewNumber: number = 0;
|
|
81
|
+
@State isChildActionsTouchViewNumber: number = 0;
|
|
82
|
+
@State menuChildActions: ContextMenuProps[] = [];
|
|
83
|
+
@State menuChild: ESObject[] = [];
|
|
84
|
+
@State deepChildActions: ESObject[] = [];
|
|
85
|
+
@State nextMenu: ESObject[] = [];
|
|
86
|
+
@State selectedFlag: number = 0;
|
|
87
|
+
|
|
88
|
+
aboutToAppear() {
|
|
89
|
+
//从前一个菜单传递过来的
|
|
90
|
+
this.longPress = this.realViewPoint;
|
|
91
|
+
this.menuCtx = this.menuCtx;
|
|
92
|
+
this.menuTag = this.menuTag;
|
|
93
|
+
this.listDate = this.longPress;
|
|
94
|
+
Logger.info('2024-2menu,this.listDate:' + JSON.stringify(this.listDate))
|
|
95
|
+
//二级目录的enable在一级目录就应该转换过,所以这里不用转换
|
|
96
|
+
//遍历传递回前端的indexPath,indexPath只会计算子节点index
|
|
97
|
+
//第一个节点表示对应的深层目录,从3级起算
|
|
98
|
+
for (let i = 0; i < this.listDate.length; i++) {
|
|
99
|
+
this.menuIndexPath[i+1] = i;
|
|
100
|
+
}
|
|
101
|
+
for (let i = 0; i < this.listDate.length; i++) {
|
|
102
|
+
if (this.longPress[i].selected) {
|
|
103
|
+
this.selectedFlag++;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//退出组件
|
|
109
|
+
aboutToDisappear() {
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@Builder
|
|
113
|
+
NextMenu() {
|
|
114
|
+
ContextMenuThreeMenu(
|
|
115
|
+
{
|
|
116
|
+
realViewPoint: this.nextMenu,
|
|
117
|
+
menuCtx: this.menuCtx,
|
|
118
|
+
menuTag: this.menuTag
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@Builder
|
|
123
|
+
NextMenuWithNoSelect() {
|
|
124
|
+
ContextMenuThreeMenuWithNoSelect(
|
|
125
|
+
{
|
|
126
|
+
realViewPoint: this.nextMenu,
|
|
127
|
+
menuCtx: this.menuCtx,
|
|
128
|
+
menuTag: this.menuTag
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
build() {
|
|
133
|
+
Menu() {
|
|
134
|
+
ForEach(this.listDate, (childItem: ContextMenuProps, index1) => {
|
|
135
|
+
if (childItem.systemIcon) {
|
|
136
|
+
MenuItem({
|
|
137
|
+
content: childItem.title,
|
|
138
|
+
symbolEndIcon: new SymbolGlyphModifier($r(childItem.systemIcon)).fontSize('24vp')
|
|
139
|
+
.fontColor([childItem.iconColor]),
|
|
140
|
+
labelInfo: childItem.subtitle,
|
|
141
|
+
builder: (): void => {
|
|
142
|
+
if (childItem.childActions !== undefined) {
|
|
143
|
+
this.nextMenu = this.longPress[index1].childActions;
|
|
144
|
+
if (this.selectedFlag !== 0) {
|
|
145
|
+
this.NextMenu();
|
|
146
|
+
} else {
|
|
147
|
+
this.NextMenuWithNoSelect();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
})//selected复选标记,根据传入的selected来判断selected为默认为false,不显示
|
|
152
|
+
.alignSelf(ItemAlign.Start)
|
|
153
|
+
.enabled(childItem.disabled)
|
|
154
|
+
.contentFontColor(childItem.destructive)
|
|
155
|
+
.onClick(() => {
|
|
156
|
+
this.nextMenu = this.longPress[index1].childActions;
|
|
157
|
+
this.isTouch = true && (!childItem.inlineChildren) && (childItem.childActions !== undefined);
|
|
158
|
+
this.isTouchViewNumber = index1;
|
|
159
|
+
if (childItem.inlineChildren || (childItem.childActions == undefined)) {
|
|
160
|
+
this.menuCtx.rnInstance.postMessageToCpp('contextMenu::SET_NATIVE_RESPONDERS_BLOCK', {
|
|
161
|
+
itemTitle: childItem.title,
|
|
162
|
+
itemTag: this.menuTag,
|
|
163
|
+
itemIndex: index1,
|
|
164
|
+
itemIndexPath: this.menuIndexPath,
|
|
165
|
+
itemInlineChildren: childItem.inlineChildren
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
} else {
|
|
171
|
+
MenuItem({
|
|
172
|
+
content: childItem.title,
|
|
173
|
+
endIcon: $r(childItem.icon),
|
|
174
|
+
labelInfo: childItem.subtitle,
|
|
175
|
+
builder: (): void => {
|
|
176
|
+
if (childItem.childActions !== undefined) {
|
|
177
|
+
this.nextMenu = this.longPress[index1].childActions;
|
|
178
|
+
if (this.selectedFlag !== 0) {
|
|
179
|
+
this.NextMenu();
|
|
180
|
+
} else {
|
|
181
|
+
this.NextMenuWithNoSelect();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
})//selected复选标记,根据传入的selected来判断selected为默认为false,不显示
|
|
186
|
+
.alignSelf(ItemAlign.Start)
|
|
187
|
+
.enabled(childItem.disabled)
|
|
188
|
+
.contentFontColor(childItem.destructive)
|
|
189
|
+
.onClick(() => {
|
|
190
|
+
this.nextMenu = this.longPress[index1].childActions;
|
|
191
|
+
this.isTouch = true && (!childItem.inlineChildren) && (childItem.childActions !== undefined);
|
|
192
|
+
this.isTouchViewNumber = index1;
|
|
193
|
+
if (childItem.inlineChildren || (childItem.childActions == undefined)) {
|
|
194
|
+
this.menuCtx.rnInstance.postMessageToCpp('contextMenu::SET_NATIVE_RESPONDERS_BLOCK', {
|
|
195
|
+
itemTitle: childItem.title,
|
|
196
|
+
itemTag: this.menuTag,
|
|
197
|
+
itemIndex: index1,
|
|
198
|
+
itemIndexPath: this.menuIndexPath,
|
|
199
|
+
itemInlineChildren: childItem.inlineChildren
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 hilog from '@ohos.hilog';
|
|
26
|
+
|
|
27
|
+
class Logger {
|
|
28
|
+
private domain : number;
|
|
29
|
+
private prefix : string;
|
|
30
|
+
private format : string = '%{public}s';
|
|
31
|
+
private isDebug : boolean;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* constructor.
|
|
35
|
+
*
|
|
36
|
+
* @param Prefix Identifies the log tag.
|
|
37
|
+
* @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
|
|
38
|
+
*/
|
|
39
|
+
constructor(prefix: string = 'MyApp', domain: number = 0xFF00, isDebug = false) {
|
|
40
|
+
this.prefix = prefix;
|
|
41
|
+
this.domain = domain;
|
|
42
|
+
this.isDebug = isDebug;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
debug(...args: string[]): void {
|
|
46
|
+
if (this.isDebug) {
|
|
47
|
+
hilog.debug(this.domain, this.prefix, this.format, args);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
info(...args: string[]): void {
|
|
52
|
+
hilog.info(this.domain, this.prefix, this.format, args);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
warn(...args: string[]) : void {
|
|
56
|
+
hilog.warn(this.domain, this.prefix, this.format, args);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
error(...args: string[]) : void {
|
|
60
|
+
hilog.error(this.domain, this.prefix, this.format, args);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default new Logger('RNViewOverflow', 0xFF00, false)
|
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
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 * from "./src/main/ets/ContextMenuPackage"
|
|
26
|
+
export * from "./src/main/ets/ContextMenuTurboModule"
|
|
Binary file
|
package/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { requireNativeComponent, View, Platform, StyleSheet, processColor } from "react-native";
|
|
3
|
+
import NativeContextMenuHarmony from './src/RTNContextMenuNativeComponent'
|
|
4
|
+
|
|
5
|
+
const NativeContextMenu = requireNativeComponent("ContextMenu", null);
|
|
6
|
+
|
|
7
|
+
const ContextMenu = (props) => {
|
|
8
|
+
const iconColor = props?.iconColor
|
|
9
|
+
? Platform.OS === 'ios'
|
|
10
|
+
? processColor(props.iconColor)
|
|
11
|
+
: props.iconColor
|
|
12
|
+
: undefined;
|
|
13
|
+
|
|
14
|
+
if (Platform.OS === 'harmony') {
|
|
15
|
+
return (
|
|
16
|
+
<NativeContextMenuHarmony {...props} iconColor={iconColor}>
|
|
17
|
+
{props.children}
|
|
18
|
+
{props.preview != null && Platform.OS === 'ios' ? (
|
|
19
|
+
<View style={styles.preview} nativeID="ContextMenuPreview">{props.preview}</View>
|
|
20
|
+
) : null}
|
|
21
|
+
</NativeContextMenuHarmony>
|
|
22
|
+
);
|
|
23
|
+
} else {
|
|
24
|
+
return (
|
|
25
|
+
<NativeContextMenu {...props} iconColor={iconColor}>
|
|
26
|
+
{props.children}
|
|
27
|
+
{props.preview != null && Platform.OS === 'ios' ? (
|
|
28
|
+
<View style={styles.preview} nativeID="ContextMenuPreview">{props.preview}</View>
|
|
29
|
+
) : null}
|
|
30
|
+
</NativeContextMenu>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const styles = StyleSheet.create({
|
|
37
|
+
preview: {
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
overflow: 'visible',
|
|
40
|
+
backgroundColor: 'transparent'
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export default ContextMenu;
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-ohos/react-native-context-menu-view",
|
|
3
|
+
"version": "1.16.1-rc.1",
|
|
4
|
+
"description": "Use native context menu views from React Native",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"src",
|
|
9
|
+
"android",
|
|
10
|
+
"ios",
|
|
11
|
+
"harmony",
|
|
12
|
+
"react-native-context-menu-view.podspec",
|
|
13
|
+
"!android/build",
|
|
14
|
+
"!ios/build",
|
|
15
|
+
"!**/__tests__",
|
|
16
|
+
"!**/__fixtures__",
|
|
17
|
+
"!**/__mocks__"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"react-native",
|
|
21
|
+
"ios",
|
|
22
|
+
"android",
|
|
23
|
+
"harmony"
|
|
24
|
+
],
|
|
25
|
+
"repository": "https://github.com/react-native-oh-library/react-native-context-menu-view",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/react-native-oh-library/react-native-context-menu-view/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/react-native-oh-library/react-native-context-menu-view#readme",
|
|
31
|
+
"devDependencies": {},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": "*",
|
|
34
|
+
"react-native": "*"
|
|
35
|
+
},
|
|
36
|
+
"harmony": {
|
|
37
|
+
"alias": "react-native-context-menu-view",
|
|
38
|
+
"autolinking": {
|
|
39
|
+
"etsPackageClassName":"ContextMenuPackage",
|
|
40
|
+
"cppPackageClassName":"ContextMenuPackage",
|
|
41
|
+
"cmakeLibraryTargetName": "rnoh_context_menu",
|
|
42
|
+
"ohPackageName": "@react-native-ohos/react-native-context-menu-view"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"registry": "https://registry.npmjs.org/",
|
|
47
|
+
"access": "public"
|
|
48
|
+
}
|
|
49
|
+
}
|