jsbox-cview 1.6.1 → 1.6.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/.prettierignore +6 -0
- package/.prettierrc +3 -0
- package/components/alert/input-alert.ts +4 -17
- package/components/alert/login-alert.ts +4 -17
- package/components/alert/plain-alert.ts +4 -17
- package/components/alert/uialert.ts +6 -16
- package/components/base.ts +1 -4
- package/components/custom-navigation-bar.ts +13 -38
- package/components/dialogs/dialog-sheet.ts +4 -13
- package/components/dialogs/form-dialog.ts +3 -6
- package/components/dialogs/list-dialog.ts +2 -5
- package/components/dynamic-contextmenu-view.ts +11 -27
- package/components/dynamic-itemsize-matrix.ts +8 -12
- package/components/dynamic-preference-listview.ts +14 -35
- package/components/dynamic-rowheight-list.ts +3 -8
- package/components/enhanced-imageview.ts +4 -9
- package/components/flowlayout.ts +6 -14
- package/components/image-pager.ts +1 -2
- package/components/oc-webview.ts +6 -24
- package/components/page-control.ts +2 -7
- package/components/pageviewer-titlebar.ts +5 -15
- package/components/pageviewer.ts +4 -13
- package/components/rotating-view.ts +1 -3
- package/components/searchbar.ts +16 -56
- package/components/sheet.ts +4 -18
- package/components/single-views.ts +6 -36
- package/components/spinners/loading-dual-ring.ts +2 -8
- package/components/spinners/loading-wedges.ts +4 -20
- package/components/spinners/spinner-androidstyle.ts +2 -7
- package/components/static-preference-listview.ts +6 -26
- package/components/tabbar.ts +7 -20
- package/controller/base-controller.ts +2 -10
- package/controller/pageviewer-controller.ts +3 -11
- package/controller/presented-page-controller.ts +2 -8
- package/controller/splitview-controller.ts +7 -26
- package/controller/tabbar-controller.ts +3 -11
- package/package.json +3 -2
- package/test/dynamic-itemsize-matrix.ts +2 -7
- package/test/flowlayout.ts +3 -11
- package/test/static-preference-listview.ts +1 -4
- package/tsconfig.json +1 -2
- package/utils/cvid.ts +1 -2
- package/utils/path.ts +1 -4
- package/utils/uitools.ts +5 -8
package/.prettierignore
ADDED
package/.prettierrc
ADDED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UIAlertActionStyle,
|
|
3
|
-
UIAlertControllerStyle,
|
|
4
|
-
UIAlertAction,
|
|
5
|
-
UIAlertController,
|
|
6
|
-
} from "./uialert";
|
|
1
|
+
import { UIAlertActionStyle, UIAlertControllerStyle, UIAlertAction, UIAlertController } from "./uialert";
|
|
7
2
|
|
|
8
3
|
import { l10n } from "../../utils/l10n";
|
|
9
4
|
|
|
@@ -39,11 +34,7 @@ export function inputAlert({
|
|
|
39
34
|
confirmText?: string;
|
|
40
35
|
}): Promise<string> {
|
|
41
36
|
return new Promise((resolve, reject) => {
|
|
42
|
-
const alertVC = new UIAlertController(
|
|
43
|
-
title,
|
|
44
|
-
message,
|
|
45
|
-
UIAlertControllerStyle.Alert
|
|
46
|
-
);
|
|
37
|
+
const alertVC = new UIAlertController(title, message, UIAlertControllerStyle.Alert);
|
|
47
38
|
alertVC.addTextField({
|
|
48
39
|
placeholder,
|
|
49
40
|
text,
|
|
@@ -58,12 +49,8 @@ export function inputAlert({
|
|
|
58
49
|
},
|
|
59
50
|
});
|
|
60
51
|
|
|
61
|
-
alertVC.addAction(
|
|
62
|
-
|
|
63
|
-
);
|
|
64
|
-
alertVC.addAction(
|
|
65
|
-
new UIAlertAction(confirmText, UIAlertActionStyle.Default, confirmEvent)
|
|
66
|
-
);
|
|
52
|
+
alertVC.addAction(new UIAlertAction(cancelText, UIAlertActionStyle.Destructive, cancelEvent));
|
|
53
|
+
alertVC.addAction(new UIAlertAction(confirmText, UIAlertActionStyle.Default, confirmEvent));
|
|
67
54
|
alertVC.present();
|
|
68
55
|
|
|
69
56
|
function confirmEvent() {
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UIAlertActionStyle,
|
|
3
|
-
UIAlertControllerStyle,
|
|
4
|
-
UIAlertAction,
|
|
5
|
-
UIAlertController,
|
|
6
|
-
} from "./uialert";
|
|
1
|
+
import { UIAlertActionStyle, UIAlertControllerStyle, UIAlertAction, UIAlertController } from "./uialert";
|
|
7
2
|
|
|
8
3
|
import { l10n } from "../../utils/l10n";
|
|
9
4
|
|
|
@@ -33,11 +28,7 @@ export function loginAlert({
|
|
|
33
28
|
confirmText?: string;
|
|
34
29
|
} = {}): Promise<{ username: string; password: string }> {
|
|
35
30
|
return new Promise((resolve, reject) => {
|
|
36
|
-
const alertVC = new UIAlertController(
|
|
37
|
-
title,
|
|
38
|
-
message,
|
|
39
|
-
UIAlertControllerStyle.Alert
|
|
40
|
-
);
|
|
31
|
+
const alertVC = new UIAlertController(title, message, UIAlertControllerStyle.Alert);
|
|
41
32
|
|
|
42
33
|
alertVC.addTextField({
|
|
43
34
|
placeholder: placeholder1,
|
|
@@ -56,12 +47,8 @@ export function loginAlert({
|
|
|
56
47
|
},
|
|
57
48
|
});
|
|
58
49
|
|
|
59
|
-
alertVC.addAction(
|
|
60
|
-
|
|
61
|
-
);
|
|
62
|
-
alertVC.addAction(
|
|
63
|
-
new UIAlertAction(confirmText, UIAlertActionStyle.Default, confirmEvent)
|
|
64
|
-
);
|
|
50
|
+
alertVC.addAction(new UIAlertAction(cancelText, UIAlertActionStyle.Destructive, cancelEvent));
|
|
51
|
+
alertVC.addAction(new UIAlertAction(confirmText, UIAlertActionStyle.Default, confirmEvent));
|
|
65
52
|
alertVC.present();
|
|
66
53
|
|
|
67
54
|
function confirmEvent() {
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UIAlertActionStyle,
|
|
3
|
-
UIAlertControllerStyle,
|
|
4
|
-
UIAlertAction,
|
|
5
|
-
UIAlertController,
|
|
6
|
-
} from "./uialert";
|
|
1
|
+
import { UIAlertActionStyle, UIAlertControllerStyle, UIAlertAction, UIAlertController } from "./uialert";
|
|
7
2
|
|
|
8
3
|
import { l10n } from "../../utils/l10n";
|
|
9
4
|
|
|
@@ -28,18 +23,10 @@ export function plainAlert({
|
|
|
28
23
|
confirmText?: string;
|
|
29
24
|
} = {}): Promise<string> {
|
|
30
25
|
return new Promise((resolve, reject) => {
|
|
31
|
-
const alertVC = new UIAlertController(
|
|
32
|
-
title,
|
|
33
|
-
message,
|
|
34
|
-
UIAlertControllerStyle.Alert
|
|
35
|
-
);
|
|
26
|
+
const alertVC = new UIAlertController(title, message, UIAlertControllerStyle.Alert);
|
|
36
27
|
|
|
37
|
-
alertVC.addAction(
|
|
38
|
-
|
|
39
|
-
);
|
|
40
|
-
alertVC.addAction(
|
|
41
|
-
new UIAlertAction(confirmText, UIAlertActionStyle.Default, confirmEvent)
|
|
42
|
-
);
|
|
28
|
+
alertVC.addAction(new UIAlertAction(cancelText, UIAlertActionStyle.Destructive, cancelEvent));
|
|
29
|
+
alertVC.addAction(new UIAlertAction(confirmText, UIAlertActionStyle.Default, confirmEvent));
|
|
43
30
|
alertVC.present();
|
|
44
31
|
|
|
45
32
|
function confirmEvent() {
|
|
@@ -14,11 +14,7 @@ export class UIAlertAction {
|
|
|
14
14
|
style: number;
|
|
15
15
|
instance: any;
|
|
16
16
|
|
|
17
|
-
constructor(
|
|
18
|
-
title: string,
|
|
19
|
-
style = UIAlertActionStyle.Default,
|
|
20
|
-
handler: Function
|
|
21
|
-
) {
|
|
17
|
+
constructor(title: string, style = UIAlertActionStyle.Default, handler: Function) {
|
|
22
18
|
this.title = title;
|
|
23
19
|
this.style = style;
|
|
24
20
|
this.instance = $objc("UIAlertAction").$actionWithTitle_style_handler(
|
|
@@ -28,7 +24,7 @@ export class UIAlertAction {
|
|
|
28
24
|
if (handler) {
|
|
29
25
|
handler(this);
|
|
30
26
|
}
|
|
31
|
-
})
|
|
27
|
+
}),
|
|
32
28
|
);
|
|
33
29
|
}
|
|
34
30
|
}
|
|
@@ -41,17 +37,11 @@ export class UIAlertController {
|
|
|
41
37
|
message: string;
|
|
42
38
|
style: number;
|
|
43
39
|
instance: any;
|
|
44
|
-
constructor(
|
|
45
|
-
title: string,
|
|
46
|
-
message: string,
|
|
47
|
-
style = UIAlertControllerStyle.ActionSheet
|
|
48
|
-
) {
|
|
40
|
+
constructor(title: string, message: string, style = UIAlertControllerStyle.ActionSheet) {
|
|
49
41
|
this.title = title;
|
|
50
42
|
this.message = message;
|
|
51
43
|
this.style = style;
|
|
52
|
-
this.instance = $objc(
|
|
53
|
-
"UIAlertController"
|
|
54
|
-
).$alertControllerWithTitle_message_preferredStyle(title, message, style);
|
|
44
|
+
this.instance = $objc("UIAlertController").$alertControllerWithTitle_message_preferredStyle(title, message, style);
|
|
55
45
|
}
|
|
56
46
|
|
|
57
47
|
addAction(action: UIAlertAction) {
|
|
@@ -98,10 +88,10 @@ export class UIAlertController {
|
|
|
98
88
|
}
|
|
99
89
|
},
|
|
100
90
|
},
|
|
101
|
-
})
|
|
91
|
+
}),
|
|
102
92
|
);
|
|
103
93
|
}
|
|
104
|
-
})
|
|
94
|
+
}),
|
|
105
95
|
);
|
|
106
96
|
}
|
|
107
97
|
|
package/components/base.ts
CHANGED
|
@@ -18,10 +18,7 @@ import { cvid } from "../utils/cvid";
|
|
|
18
18
|
* - 通过组件化的方式,将JSBox view的定义和实例绑定,使用起来更加方便
|
|
19
19
|
* - 可以便利地创建自定义组件
|
|
20
20
|
*/
|
|
21
|
-
export abstract class Base<
|
|
22
|
-
T extends AllUIView,
|
|
23
|
-
R extends UiTypes.AllViewOptions
|
|
24
|
-
> {
|
|
21
|
+
export abstract class Base<T extends AllUIView, R extends UiTypes.AllViewOptions> {
|
|
25
22
|
readonly id: string;
|
|
26
23
|
private _view?: T;
|
|
27
24
|
abstract _defineView: () => R;
|
|
@@ -127,10 +127,7 @@ interface NavigationBarCViews {
|
|
|
127
127
|
* - restore() 普通布局
|
|
128
128
|
* - expand() 扩展布局
|
|
129
129
|
*/
|
|
130
|
-
export class CustomNavigationBar extends Base<
|
|
131
|
-
UIView | UIBlurView,
|
|
132
|
-
UiTypes.ViewOptions | UiTypes.BlurOptions
|
|
133
|
-
> {
|
|
130
|
+
export class CustomNavigationBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTypes.BlurOptions> {
|
|
134
131
|
_props: NavigationBarProps;
|
|
135
132
|
_events: NavigationBarEvents;
|
|
136
133
|
cviews: Required<NavigationBarCViews>;
|
|
@@ -165,9 +162,7 @@ export class CustomNavigationBar extends Base<
|
|
|
165
162
|
// leftItemView
|
|
166
163
|
let leftInset = 0;
|
|
167
164
|
if (this._props.popButtonEnabled) {
|
|
168
|
-
const titleWidth = this._props.popButtonTitle
|
|
169
|
-
? getTextWidth(this._props.popButtonTitle)
|
|
170
|
-
: 0;
|
|
165
|
+
const titleWidth = this._props.popButtonTitle ? getTextWidth(this._props.popButtonTitle) : 0;
|
|
171
166
|
leftInset = titleWidth + 35;
|
|
172
167
|
const views = [];
|
|
173
168
|
const chevronOptions: UiTypes.ViewOptions = {
|
|
@@ -187,8 +182,7 @@ export class CustomNavigationBar extends Base<
|
|
|
187
182
|
contentMode: 1,
|
|
188
183
|
tintColor: this._props.tintColor,
|
|
189
184
|
},
|
|
190
|
-
layout: (make: MASConstraintMaker) =>
|
|
191
|
-
make.edges.insets($insets(12.5, 10, 12.5, 0)),
|
|
185
|
+
layout: (make: MASConstraintMaker) => make.edges.insets($insets(12.5, 10, 12.5, 0)),
|
|
192
186
|
},
|
|
193
187
|
],
|
|
194
188
|
};
|
|
@@ -226,17 +220,14 @@ export class CustomNavigationBar extends Base<
|
|
|
226
220
|
},
|
|
227
221
|
longPressed: this._props.popToRootEnabled
|
|
228
222
|
? (sender) => {
|
|
229
|
-
if (this._events.popToRootHandler)
|
|
230
|
-
this._events.popToRootHandler(this);
|
|
223
|
+
if (this._events.popToRootHandler) this._events.popToRootHandler(this);
|
|
231
224
|
$ui.popToRoot();
|
|
232
225
|
}
|
|
233
226
|
: undefined,
|
|
234
227
|
},
|
|
235
228
|
});
|
|
236
229
|
} else {
|
|
237
|
-
leftInset = this._calculateItemViewWidth(
|
|
238
|
-
this._props.leftBarButtonItems
|
|
239
|
-
);
|
|
230
|
+
leftInset = this._calculateItemViewWidth(this._props.leftBarButtonItems);
|
|
240
231
|
this.cviews.leftItemView = new ContentView({
|
|
241
232
|
props: {
|
|
242
233
|
bgcolor: undefined,
|
|
@@ -245,16 +236,12 @@ export class CustomNavigationBar extends Base<
|
|
|
245
236
|
make.width.equalTo(leftInset);
|
|
246
237
|
make.left.top.bottom.inset(0);
|
|
247
238
|
},
|
|
248
|
-
views: this._createCviewsOnItemView(
|
|
249
|
-
this._props.leftBarButtonItems
|
|
250
|
-
).map((n) => n.definition),
|
|
239
|
+
views: this._createCviewsOnItemView(this._props.leftBarButtonItems).map((n) => n.definition),
|
|
251
240
|
});
|
|
252
241
|
}
|
|
253
242
|
|
|
254
243
|
// rightItemView
|
|
255
|
-
const rightInset = this._calculateItemViewWidth(
|
|
256
|
-
this._props.rightBarButtonItems
|
|
257
|
-
);
|
|
244
|
+
const rightInset = this._calculateItemViewWidth(this._props.rightBarButtonItems);
|
|
258
245
|
this.cviews.rightItemView = new ContentView({
|
|
259
246
|
props: {
|
|
260
247
|
bgcolor: undefined,
|
|
@@ -263,9 +250,7 @@ export class CustomNavigationBar extends Base<
|
|
|
263
250
|
make.width.equalTo(rightInset);
|
|
264
251
|
make.right.top.bottom.inset(0);
|
|
265
252
|
},
|
|
266
|
-
views: this._createCviewsOnItemView(
|
|
267
|
-
this._props.rightBarButtonItems
|
|
268
|
-
).map((n) => n.definition),
|
|
253
|
+
views: this._createCviewsOnItemView(this._props.rightBarButtonItems).map((n) => n.definition),
|
|
269
254
|
});
|
|
270
255
|
|
|
271
256
|
// titleView
|
|
@@ -369,10 +354,7 @@ export class CustomNavigationBar extends Base<
|
|
|
369
354
|
type: "view",
|
|
370
355
|
props: {},
|
|
371
356
|
layout: $layout.fillSafeArea,
|
|
372
|
-
views: [
|
|
373
|
-
this.cviews.contentView.definition,
|
|
374
|
-
this.cviews.toolViewWrapper.definition,
|
|
375
|
-
],
|
|
357
|
+
views: [this.cviews.contentView.definition, this.cviews.toolViewWrapper.definition],
|
|
376
358
|
},
|
|
377
359
|
this.cviews.separator.definition,
|
|
378
360
|
],
|
|
@@ -448,8 +430,7 @@ export class CustomNavigationBar extends Base<
|
|
|
448
430
|
set title(title: string) {
|
|
449
431
|
if (this._props.title === undefined) return;
|
|
450
432
|
this._props.title = title;
|
|
451
|
-
if ("text" in this.cviews.titleViewWrapper.view)
|
|
452
|
-
this.cviews.titleViewWrapper.view.text = title;
|
|
433
|
+
if ("text" in this.cviews.titleViewWrapper.view) this.cviews.titleViewWrapper.view.text = title;
|
|
453
434
|
}
|
|
454
435
|
|
|
455
436
|
hide(animated = true) {
|
|
@@ -485,9 +466,7 @@ export class CustomNavigationBar extends Base<
|
|
|
485
466
|
this.cviews.toolViewWrapper.view.hidden = true;
|
|
486
467
|
this.cviews.titleViewWrapper.view.hidden = false;
|
|
487
468
|
this.view.remakeLayout(navBarLayouts[navBarStyles.minimized]);
|
|
488
|
-
this.cviews.contentView.view.updateLayout((make) =>
|
|
489
|
-
make.height.equalTo(25)
|
|
490
|
-
);
|
|
469
|
+
this.cviews.contentView.view.updateLayout((make) => make.height.equalTo(25));
|
|
491
470
|
if (animated) {
|
|
492
471
|
$ui.animate({
|
|
493
472
|
duration: 0.3,
|
|
@@ -513,9 +492,7 @@ export class CustomNavigationBar extends Base<
|
|
|
513
492
|
this.cviews.titleViewWrapper.view.hidden = false;
|
|
514
493
|
//this.cviews.toolViewWrapper.view.hidden = true;
|
|
515
494
|
this.view.remakeLayout(navBarLayouts[navBarStyles.normal]);
|
|
516
|
-
this.cviews.contentView.view.updateLayout((make) =>
|
|
517
|
-
make.height.equalTo(50)
|
|
518
|
-
);
|
|
495
|
+
this.cviews.contentView.view.updateLayout((make) => make.height.equalTo(50));
|
|
519
496
|
if (animated) {
|
|
520
497
|
$ui.animate({
|
|
521
498
|
duration: 0.3,
|
|
@@ -545,9 +522,7 @@ export class CustomNavigationBar extends Base<
|
|
|
545
522
|
this.cviews.toolViewWrapper.view.hidden = false;
|
|
546
523
|
this.cviews.titleViewWrapper.view.hidden = false;
|
|
547
524
|
this.view.remakeLayout(navBarLayouts[navBarStyles.expanded]);
|
|
548
|
-
this.cviews.contentView.view.updateLayout((make) =>
|
|
549
|
-
make.height.equalTo(50)
|
|
550
|
-
);
|
|
525
|
+
this.cviews.contentView.view.updateLayout((make) => make.height.equalTo(50));
|
|
551
526
|
if (animated) {
|
|
552
527
|
$ui.animate({
|
|
553
528
|
duration: 0.3,
|
|
@@ -15,11 +15,7 @@ import { Base } from "../base";
|
|
|
15
15
|
* @param bgcolor 背景颜色
|
|
16
16
|
* @param doneButtonHidden 是否隐藏完成按钮, 默认为false,如果隐藏则需要自行实现完成逻辑
|
|
17
17
|
*/
|
|
18
|
-
export class DialogSheet extends Sheet<
|
|
19
|
-
ContentView,
|
|
20
|
-
UIView,
|
|
21
|
-
UiTypes.ViewOptions
|
|
22
|
-
> {
|
|
18
|
+
export class DialogSheet extends Sheet<ContentView, UIView, UiTypes.ViewOptions> {
|
|
23
19
|
_props: {
|
|
24
20
|
title: string;
|
|
25
21
|
cview: Base<any, any>;
|
|
@@ -61,12 +57,8 @@ export class DialogSheet extends Sheet<
|
|
|
61
57
|
this._navbar = new CustomNavigationBar({
|
|
62
58
|
props: {
|
|
63
59
|
title: this._props.title,
|
|
64
|
-
leftBarButtonItems: [
|
|
65
|
-
|
|
66
|
-
],
|
|
67
|
-
rightBarButtonItems: this._props.doneButtonHidden
|
|
68
|
-
? []
|
|
69
|
-
: [{ title: l10n("DONE"), handler: () => this.done() }],
|
|
60
|
+
leftBarButtonItems: [{ symbol: "xmark", handler: () => this.dismiss() }],
|
|
61
|
+
rightBarButtonItems: this._props.doneButtonHidden ? [] : [{ title: l10n("DONE"), handler: () => this.done() }],
|
|
70
62
|
},
|
|
71
63
|
});
|
|
72
64
|
this._props.cview._layout = (make, view) => {
|
|
@@ -82,8 +74,7 @@ export class DialogSheet extends Sheet<
|
|
|
82
74
|
|
|
83
75
|
done() {
|
|
84
76
|
this._done = true;
|
|
85
|
-
if (this.resolve && this._props.doneHandler)
|
|
86
|
-
this.resolve(this._props.doneHandler());
|
|
77
|
+
if (this.resolve && this._props.doneHandler) this.resolve(this._props.doneHandler());
|
|
87
78
|
this.dismiss();
|
|
88
79
|
}
|
|
89
80
|
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Base } from "../base";
|
|
2
|
-
import {
|
|
3
|
-
PreferenceListView,
|
|
4
|
-
PreferenceSection,
|
|
5
|
-
} from "../static-preference-listview";
|
|
2
|
+
import { PreferenceListView, PreferenceSection } from "../static-preference-listview";
|
|
6
3
|
import { DialogSheet } from "./dialog-sheet";
|
|
7
4
|
|
|
8
5
|
class DialogSheetForm extends DialogSheet {
|
|
@@ -16,7 +13,7 @@ class DialogSheetForm extends DialogSheet {
|
|
|
16
13
|
bgcolor?: UIColor;
|
|
17
14
|
doneButtonHidden?: boolean;
|
|
18
15
|
},
|
|
19
|
-
checkHandler: (values: { [key: string]: any }) => boolean
|
|
16
|
+
checkHandler: (values: { [key: string]: any }) => boolean,
|
|
20
17
|
) {
|
|
21
18
|
super(sheetProps);
|
|
22
19
|
this._checkHandler = checkHandler;
|
|
@@ -57,7 +54,7 @@ export function formDialog({
|
|
|
57
54
|
cview: view,
|
|
58
55
|
doneHandler: () => view.values,
|
|
59
56
|
},
|
|
60
|
-
checkHandler || (() => true)
|
|
57
|
+
checkHandler || (() => true),
|
|
61
58
|
);
|
|
62
59
|
return new Promise((resolve, reject) => {
|
|
63
60
|
sheet.promisify(resolve, reject);
|
|
@@ -66,8 +66,7 @@ export function listDialog({
|
|
|
66
66
|
didSelect: (sender, indexPath) => {
|
|
67
67
|
const data = sender.data;
|
|
68
68
|
if (multiSelectEnabled) {
|
|
69
|
-
data[indexPath.item].image.hidden =
|
|
70
|
-
!data[indexPath.item].image.hidden;
|
|
69
|
+
data[indexPath.item].image.hidden = !data[indexPath.item].image.hidden;
|
|
71
70
|
} else {
|
|
72
71
|
data.forEach((n, i) => {
|
|
73
72
|
n.image.hidden = i !== indexPath.item;
|
|
@@ -82,9 +81,7 @@ export function listDialog({
|
|
|
82
81
|
bgcolor: $color("insetGroupedBackground"),
|
|
83
82
|
cview: listView,
|
|
84
83
|
doneHandler: () => {
|
|
85
|
-
const filtered = listView.view.data
|
|
86
|
-
.map((n, i) => (n.image.hidden ? -1 : i))
|
|
87
|
-
.filter((n) => n !== -1);
|
|
84
|
+
const filtered = listView.view.data.map((n, i) => (n.image.hidden ? -1 : i)).filter((n) => n !== -1);
|
|
88
85
|
if (multiSelectEnabled) return filtered;
|
|
89
86
|
else return filtered[0];
|
|
90
87
|
},
|
|
@@ -23,10 +23,7 @@ const RegisteredOCClassName: Set<string> = new Set();
|
|
|
23
23
|
* 生成上下文菜单的回调函数。
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
|
-
export class DynamicContextMenuView extends Base<
|
|
27
|
-
UIView,
|
|
28
|
-
UiTypes.RuntimeOptions
|
|
29
|
-
> {
|
|
26
|
+
export class DynamicContextMenuView extends Base<UIView, UiTypes.RuntimeOptions> {
|
|
30
27
|
private generateContextMenu: (sender: UIView) => {
|
|
31
28
|
title?: string;
|
|
32
29
|
items: MenuItem[];
|
|
@@ -77,10 +74,7 @@ export class DynamicContextMenuView extends Base<
|
|
|
77
74
|
$define({
|
|
78
75
|
type: this._ocClassName + " : UIView <UIContextMenuInteractionDelegate>",
|
|
79
76
|
events: {
|
|
80
|
-
"contextMenuInteraction:configurationForMenuAtLocation:": (
|
|
81
|
-
interacton: any,
|
|
82
|
-
point: JBPoint
|
|
83
|
-
) => {
|
|
77
|
+
"contextMenuInteraction:configurationForMenuAtLocation:": (interacton: any, point: JBPoint) => {
|
|
84
78
|
const view = interacton.$view().jsValue();
|
|
85
79
|
const menu = this.generateContextMenu(view);
|
|
86
80
|
return this.createContextMenuConfiguration(menu);
|
|
@@ -89,42 +83,32 @@ export class DynamicContextMenuView extends Base<
|
|
|
89
83
|
});
|
|
90
84
|
}
|
|
91
85
|
|
|
92
|
-
private createContextMenuConfiguration({
|
|
93
|
-
|
|
94
|
-
items,
|
|
95
|
-
}: {
|
|
96
|
-
title?: string;
|
|
97
|
-
items: MenuItem[];
|
|
98
|
-
}) {
|
|
99
|
-
return $objc(
|
|
100
|
-
"UIContextMenuConfiguration"
|
|
101
|
-
).$configurationWithIdentifier_previewProvider_actionProvider(
|
|
86
|
+
private createContextMenuConfiguration({ title, items }: { title?: string; items: MenuItem[] }) {
|
|
87
|
+
return $objc("UIContextMenuConfiguration").$configurationWithIdentifier_previewProvider_actionProvider(
|
|
102
88
|
null,
|
|
103
89
|
null,
|
|
104
90
|
$block("UIMenu *, NSArray *", () => {
|
|
105
91
|
const actions = items.map((item) => {
|
|
106
|
-
const action = $objc(
|
|
107
|
-
"UIAction"
|
|
108
|
-
).$actionWithTitle_image_identifier_handler(
|
|
92
|
+
const action = $objc("UIAction").$actionWithTitle_image_identifier_handler(
|
|
109
93
|
item.title,
|
|
110
94
|
item.symbol || null,
|
|
111
95
|
null,
|
|
112
|
-
$block("void, UIAction *", () => item.handler())
|
|
96
|
+
$block("void, UIAction *", () => item.handler()),
|
|
113
97
|
);
|
|
114
98
|
if (item.destructive) action.$setAttributes(1 << 1);
|
|
115
99
|
return action;
|
|
116
100
|
});
|
|
117
|
-
return title
|
|
118
|
-
|
|
101
|
+
return title
|
|
102
|
+
? $objc("UIMenu").$menuWithTitle_children(title, actions)
|
|
103
|
+
: $objc("UIMenu").$menuWithChildren(actions);
|
|
104
|
+
}),
|
|
119
105
|
);
|
|
120
106
|
}
|
|
121
107
|
|
|
122
108
|
private createRuntimeView() {
|
|
123
109
|
this.defineOCClass();
|
|
124
110
|
const view = $objc(this._ocClassName).invoke("alloc.init");
|
|
125
|
-
const interaction = $objc("UIContextMenuInteraction")
|
|
126
|
-
.invoke("alloc")
|
|
127
|
-
.invoke("initWithDelegate", view);
|
|
111
|
+
const interaction = $objc("UIContextMenuInteraction").invoke("alloc").invoke("initWithDelegate", view);
|
|
128
112
|
view.$addInteraction(interaction);
|
|
129
113
|
return view;
|
|
130
114
|
}
|
|
@@ -26,7 +26,7 @@ function _getColumnsAndItemSizeWidth(
|
|
|
26
26
|
containerWidth: number,
|
|
27
27
|
minItemWidth: number,
|
|
28
28
|
maxColumns: number,
|
|
29
|
-
spacing: number
|
|
29
|
+
spacing: number,
|
|
30
30
|
) {
|
|
31
31
|
if (minItemWidth > containerWidth - 2 * spacing) {
|
|
32
32
|
return {
|
|
@@ -35,15 +35,12 @@ function _getColumnsAndItemSizeWidth(
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
const columns = Math.max(
|
|
38
|
-
Math.min(
|
|
39
|
-
|
|
40
|
-
maxColumns
|
|
41
|
-
),
|
|
42
|
-
1 // 最少一列
|
|
38
|
+
Math.min(Math.floor((containerWidth - spacing) / (minItemWidth + spacing)), maxColumns),
|
|
39
|
+
1, // 最少一列
|
|
43
40
|
);
|
|
44
41
|
const itemSizeWidth = Math.max(
|
|
45
42
|
Math.floor((containerWidth - spacing * (columns + 1)) / columns),
|
|
46
|
-
minItemWidth // 最小宽度
|
|
43
|
+
minItemWidth, // 最小宽度
|
|
47
44
|
);
|
|
48
45
|
return {
|
|
49
46
|
columns,
|
|
@@ -156,7 +153,7 @@ export class DynamicItemSizeMatrix extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
156
153
|
sender.frame.width,
|
|
157
154
|
this._props.minItemWidth,
|
|
158
155
|
this._props.maxColumns,
|
|
159
|
-
this._props.spacing
|
|
156
|
+
this._props.spacing,
|
|
160
157
|
);
|
|
161
158
|
this._columns = columns;
|
|
162
159
|
this._itemSizeWidth = itemSizeWidth;
|
|
@@ -167,8 +164,7 @@ export class DynamicItemSizeMatrix extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
167
164
|
if (this._props.dynamicHeightEnabled) {
|
|
168
165
|
const height = this.heightToWidth(sender.frame.width);
|
|
169
166
|
sender.updateLayout((make) => make.height.equalTo(height));
|
|
170
|
-
if (this._events.heightChanged)
|
|
171
|
-
this._events.heightChanged(this, height);
|
|
167
|
+
if (this._events.heightChanged) this._events.heightChanged(this, height);
|
|
172
168
|
}
|
|
173
169
|
},
|
|
174
170
|
},
|
|
@@ -182,9 +178,9 @@ export class DynamicItemSizeMatrix extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
182
178
|
width,
|
|
183
179
|
this._props.minItemWidth,
|
|
184
180
|
this._props.maxColumns,
|
|
185
|
-
this._props.spacing
|
|
181
|
+
this._props.spacing,
|
|
186
182
|
);
|
|
187
|
-
const rows = Math.ceil(this._props.data.length / columns);
|
|
183
|
+
const rows = this._props.data ? Math.ceil(this._props.data.length / columns) : 0;
|
|
188
184
|
const itemSizeHeight = this._events.itemHeight
|
|
189
185
|
? this._events.itemHeight(itemSizeWidth)
|
|
190
186
|
: this._props.fixedItemHeight;
|
|
@@ -65,10 +65,7 @@ interface RequiredCunstomProps extends UiTypes.ListProps {
|
|
|
65
65
|
*
|
|
66
66
|
* - cview.sections = sections 可以写入新的 sections
|
|
67
67
|
*/
|
|
68
|
-
export class DynamicPreferenceListView extends Base<
|
|
69
|
-
UIListView,
|
|
70
|
-
UiTypes.ListOptions
|
|
71
|
-
> {
|
|
68
|
+
export class DynamicPreferenceListView extends Base<UIListView, UiTypes.ListOptions> {
|
|
72
69
|
_defineView: () => UiTypes.ListOptions;
|
|
73
70
|
private _sections: PreferenceSection[];
|
|
74
71
|
private _props: RequiredCunstomProps;
|
|
@@ -189,8 +186,7 @@ export class DynamicPreferenceListView extends Base<
|
|
|
189
186
|
events: {
|
|
190
187
|
changed: (sender) => {
|
|
191
188
|
const { section, row } = sender.info;
|
|
192
|
-
this._sections[section].rows[row].value =
|
|
193
|
-
sender.value;
|
|
189
|
+
this._sections[section].rows[row].value = sender.value;
|
|
194
190
|
const label = sender.next as UILabelView;
|
|
195
191
|
label.text = sender.value.toString();
|
|
196
192
|
if (events.changed) events.changed(this.values);
|
|
@@ -233,29 +229,24 @@ export class DynamicPreferenceListView extends Base<
|
|
|
233
229
|
events: {
|
|
234
230
|
changed: (sender) => {
|
|
235
231
|
const { section, row } = sender.info;
|
|
236
|
-
const options = this._sections[section].rows[
|
|
237
|
-
row
|
|
238
|
-
] as PrefsRowSlider;
|
|
232
|
+
const options = this._sections[section].rows[row] as PrefsRowSlider;
|
|
239
233
|
const label = sender.next as UILabelView;
|
|
240
234
|
label.text = this._handleSliderValue(
|
|
241
235
|
sender.value * (options.max ?? 1),
|
|
242
236
|
options.decimal,
|
|
243
237
|
options.min,
|
|
244
|
-
options.max
|
|
238
|
+
options.max,
|
|
245
239
|
).toString();
|
|
246
240
|
},
|
|
247
241
|
touchesEnded: (sender) => {
|
|
248
242
|
const { section, row } = sender.info;
|
|
249
|
-
const options = this._sections[section].rows[
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
options.min,
|
|
257
|
-
options.max
|
|
258
|
-
);
|
|
243
|
+
const options = this._sections[section].rows[row] as PrefsRowSlider;
|
|
244
|
+
this._sections[section].rows[row].value = this._handleSliderValue(
|
|
245
|
+
sender.value * (options.max ?? 1),
|
|
246
|
+
options.decimal,
|
|
247
|
+
options.min,
|
|
248
|
+
options.max,
|
|
249
|
+
);
|
|
259
250
|
if (events.changed) events.changed(this.values);
|
|
260
251
|
},
|
|
261
252
|
},
|
|
@@ -488,12 +479,7 @@ export class DynamicPreferenceListView extends Base<
|
|
|
488
479
|
}
|
|
489
480
|
}
|
|
490
481
|
|
|
491
|
-
_handleSliderValue(
|
|
492
|
-
num?: number,
|
|
493
|
-
decimal?: number,
|
|
494
|
-
min?: number,
|
|
495
|
-
max?: number
|
|
496
|
-
): number {
|
|
482
|
+
_handleSliderValue(num?: number, decimal?: number, min?: number, max?: number): number {
|
|
497
483
|
if (num === undefined) return min || 0;
|
|
498
484
|
if (decimal === undefined) decimal = 1;
|
|
499
485
|
if (isNaN(num)) num = min || 0;
|
|
@@ -577,12 +563,7 @@ export class DynamicPreferenceListView extends Base<
|
|
|
577
563
|
}
|
|
578
564
|
case "slider": {
|
|
579
565
|
data.slider_and_number.hidden = false;
|
|
580
|
-
const adjustedValue = this._handleSliderValue(
|
|
581
|
-
n.value,
|
|
582
|
-
n.decimal,
|
|
583
|
-
n.min,
|
|
584
|
-
n.max
|
|
585
|
-
);
|
|
566
|
+
const adjustedValue = this._handleSliderValue(n.value, n.decimal, n.min, n.max);
|
|
586
567
|
data.label_slider = {
|
|
587
568
|
textColor: $color("primaryText"),
|
|
588
569
|
text: adjustedValue,
|
|
@@ -657,9 +638,7 @@ export class DynamicPreferenceListView extends Base<
|
|
|
657
638
|
break;
|
|
658
639
|
}
|
|
659
640
|
case "action": {
|
|
660
|
-
data.title.textColor = n.destructive
|
|
661
|
-
? $color("red")
|
|
662
|
-
: $color("systemLink");
|
|
641
|
+
data.title.textColor = n.destructive ? $color("red") : $color("systemLink");
|
|
663
642
|
break;
|
|
664
643
|
}
|
|
665
644
|
default:
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Base } from "./base";
|
|
2
2
|
|
|
3
|
-
interface DynamicRowHeightListProps
|
|
4
|
-
|
|
5
|
-
interface DynamicRowHeightListEvents
|
|
6
|
-
extends Omit<UiTypes.ListEvents, "rowHeight"> {}
|
|
3
|
+
interface DynamicRowHeightListProps extends Omit<UiTypes.ListProps, "data" | "template"> {}
|
|
4
|
+
interface DynamicRowHeightListEvents extends Omit<UiTypes.ListEvents, "rowHeight"> {}
|
|
7
5
|
interface DynamicRowHeightListCView extends Base<any, any> {
|
|
8
6
|
heightToWidth: (width: number) => number;
|
|
9
7
|
}
|
|
@@ -24,10 +22,7 @@ interface DynamicRowHeightListCView extends Base<any, any> {
|
|
|
24
22
|
*
|
|
25
23
|
* 除了 props.data, props.template 和 events.rowHeight 不可用,其他均和 list 一致
|
|
26
24
|
*/
|
|
27
|
-
export class DynamicRowHeightList extends Base<
|
|
28
|
-
UIListView,
|
|
29
|
-
UiTypes.ListOptions
|
|
30
|
-
> {
|
|
25
|
+
export class DynamicRowHeightList extends Base<UIListView, UiTypes.ListOptions> {
|
|
31
26
|
_defineView: () => UiTypes.ListOptions;
|
|
32
27
|
constructor({
|
|
33
28
|
sections,
|