jsbox-cview 1.5.24 → 1.5.26
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/components/dynamic-contextmenu-view.ts +6 -6
- package/controller/tabbar-controller.ts +5 -0
- package/dist/components/dynamic-contextmenu-view.js +2 -2
- package/dist/controller/tabbar-controller.js +6 -0
- package/dist/test/dynamic-contextmenu-view.js +0 -3
- package/package.json +1 -1
- package/test/dynamic-contextmenu-view.ts +0 -3
|
@@ -3,7 +3,7 @@ import { cvid } from "../utils/cvid";
|
|
|
3
3
|
|
|
4
4
|
type MenuItem = {
|
|
5
5
|
title: string;
|
|
6
|
-
symbol
|
|
6
|
+
symbol?: string;
|
|
7
7
|
handler: () => void;
|
|
8
8
|
destructive?: boolean;
|
|
9
9
|
};
|
|
@@ -28,7 +28,7 @@ export class DynamicContextMenuView extends Base<
|
|
|
28
28
|
UiTypes.RuntimeOptions
|
|
29
29
|
> {
|
|
30
30
|
private generateContextMenu: (sender: UIView) => {
|
|
31
|
-
title
|
|
31
|
+
title?: string;
|
|
32
32
|
items: MenuItem[];
|
|
33
33
|
};
|
|
34
34
|
private _ocClassName: string;
|
|
@@ -44,7 +44,7 @@ export class DynamicContextMenuView extends Base<
|
|
|
44
44
|
}: {
|
|
45
45
|
classname?: string;
|
|
46
46
|
generateContextMenu: (sender: UIView) => {
|
|
47
|
-
title
|
|
47
|
+
title?: string;
|
|
48
48
|
items: MenuItem[];
|
|
49
49
|
};
|
|
50
50
|
props: UiTypes.BaseViewProps;
|
|
@@ -93,7 +93,7 @@ export class DynamicContextMenuView extends Base<
|
|
|
93
93
|
title,
|
|
94
94
|
items,
|
|
95
95
|
}: {
|
|
96
|
-
title
|
|
96
|
+
title?: string;
|
|
97
97
|
items: MenuItem[];
|
|
98
98
|
}) {
|
|
99
99
|
return $objc(
|
|
@@ -107,14 +107,14 @@ export class DynamicContextMenuView extends Base<
|
|
|
107
107
|
"UIAction"
|
|
108
108
|
).$actionWithTitle_image_identifier_handler(
|
|
109
109
|
item.title,
|
|
110
|
-
item.symbol,
|
|
110
|
+
item.symbol || null,
|
|
111
111
|
null,
|
|
112
112
|
$block("void, UIAction *", () => item.handler())
|
|
113
113
|
);
|
|
114
114
|
if (item.destructive) action.$setAttributes(1 << 1);
|
|
115
115
|
return action;
|
|
116
116
|
});
|
|
117
|
-
return $objc("UIMenu").$menuWithTitle_children(title, actions);
|
|
117
|
+
return title ? $objc("UIMenu").$menuWithTitle_children(title, actions) : $objc("UIMenu").$menuWithChildren(actions);
|
|
118
118
|
})
|
|
119
119
|
);
|
|
120
120
|
}
|
|
@@ -121,11 +121,16 @@ export class TabBarController extends BaseController {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
set index(num) {
|
|
124
|
+
if (this._props.index === num) return;
|
|
124
125
|
this.cviews.tabbar.index = num;
|
|
125
126
|
this.pages.forEach((n, i) => {
|
|
126
127
|
n.view.hidden = i !== num;
|
|
127
128
|
});
|
|
128
129
|
this._props.index = num;
|
|
130
|
+
this._props.items
|
|
131
|
+
.find((item) => item.controller.status === 2)
|
|
132
|
+
?.controller.disappear();
|
|
133
|
+
this._props.items[num].controller.appear();
|
|
129
134
|
}
|
|
130
135
|
|
|
131
136
|
get index() {
|
|
@@ -51,12 +51,12 @@ class DynamicContextMenuView extends base_1.Base {
|
|
|
51
51
|
createContextMenuConfiguration({ title, items, }) {
|
|
52
52
|
return $objc("UIContextMenuConfiguration").$configurationWithIdentifier_previewProvider_actionProvider(null, null, $block("UIMenu *, NSArray *", () => {
|
|
53
53
|
const actions = items.map((item) => {
|
|
54
|
-
const action = $objc("UIAction").$actionWithTitle_image_identifier_handler(item.title, item.symbol, null, $block("void, UIAction *", () => item.handler()));
|
|
54
|
+
const action = $objc("UIAction").$actionWithTitle_image_identifier_handler(item.title, item.symbol || null, null, $block("void, UIAction *", () => item.handler()));
|
|
55
55
|
if (item.destructive)
|
|
56
56
|
action.$setAttributes(1 << 1);
|
|
57
57
|
return action;
|
|
58
58
|
});
|
|
59
|
-
return $objc("UIMenu").$menuWithTitle_children(title, actions);
|
|
59
|
+
return title ? $objc("UIMenu").$menuWithTitle_children(title, actions) : $objc("UIMenu").$menuWithChildren(actions);
|
|
60
60
|
}));
|
|
61
61
|
}
|
|
62
62
|
createRuntimeView() {
|
|
@@ -82,11 +82,17 @@ class TabBarController extends base_controller_1.BaseController {
|
|
|
82
82
|
this.rootView.views = [this.cviews.pageContentView, this.cviews.tabbar];
|
|
83
83
|
}
|
|
84
84
|
set index(num) {
|
|
85
|
+
var _a;
|
|
86
|
+
if (this._props.index === num)
|
|
87
|
+
return;
|
|
85
88
|
this.cviews.tabbar.index = num;
|
|
86
89
|
this.pages.forEach((n, i) => {
|
|
87
90
|
n.view.hidden = i !== num;
|
|
88
91
|
});
|
|
89
92
|
this._props.index = num;
|
|
93
|
+
(_a = this._props.items
|
|
94
|
+
.find((item) => item.controller.status === 2)) === null || _a === void 0 ? void 0 : _a.controller.disappear();
|
|
95
|
+
this._props.items[num].controller.appear();
|
|
90
96
|
}
|
|
91
97
|
get index() {
|
|
92
98
|
return this._props.index || 0;
|
|
@@ -24,18 +24,15 @@ const menuList = [
|
|
|
24
24
|
],
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
title: "菜单2",
|
|
28
27
|
items: [
|
|
29
28
|
{
|
|
30
29
|
title: "变成菜单1",
|
|
31
|
-
symbol: "plus",
|
|
32
30
|
handler: () => {
|
|
33
31
|
menuIndex = 0;
|
|
34
32
|
},
|
|
35
33
|
},
|
|
36
34
|
{
|
|
37
35
|
title: "变成菜单2",
|
|
38
|
-
symbol: "plus",
|
|
39
36
|
handler: () => {
|
|
40
37
|
menuIndex = 1;
|
|
41
38
|
},
|
package/package.json
CHANGED
|
@@ -23,18 +23,15 @@ const menuList = [
|
|
|
23
23
|
],
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
title: "菜单2",
|
|
27
26
|
items: [
|
|
28
27
|
{
|
|
29
28
|
title: "变成菜单1",
|
|
30
|
-
symbol: "plus",
|
|
31
29
|
handler: () => {
|
|
32
30
|
menuIndex = 0;
|
|
33
31
|
},
|
|
34
32
|
},
|
|
35
33
|
{
|
|
36
34
|
title: "变成菜单2",
|
|
37
|
-
symbol: "plus",
|
|
38
35
|
handler: () => {
|
|
39
36
|
menuIndex = 1;
|
|
40
37
|
},
|