jsbox-cview 1.5.21 → 1.5.23
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/alert/input-alert.ts +5 -7
- package/components/alert/login-alert.ts +7 -7
- package/components/alert/plain-alert.ts +3 -3
- package/components/alert/uialert.ts +14 -6
- package/components/base.ts +12 -8
- package/components/custom-navigation-bar.ts +106 -88
- package/components/dialogs/dialog-sheet.ts +12 -8
- package/components/dialogs/form-dialog.ts +29 -16
- package/components/dialogs/list-dialog.ts +26 -20
- package/components/dialogs/text-dialog.ts +13 -8
- package/components/dynamic-contextmenu-view.ts +57 -25
- package/components/dynamic-itemsize-matrix.ts +45 -40
- package/components/dynamic-preference-listview.ts +135 -117
- package/components/dynamic-rowheight-list.ts +32 -20
- package/components/enhanced-imageview.ts +37 -28
- package/components/flowlayout.ts +61 -42
- package/components/image-pager.ts +33 -29
- package/components/page-control.ts +15 -11
- package/components/pageviewer-titlebar.ts +29 -22
- package/components/pageviewer.ts +33 -23
- package/components/refresh-button.ts +8 -8
- package/components/rotating-view.ts +24 -20
- package/components/searchbar.ts +113 -65
- package/components/sheet.ts +23 -17
- package/components/single-views.ts +228 -72
- package/components/spinners/loading-dual-ring.ts +21 -15
- package/components/spinners/loading-wedges.ts +24 -18
- package/components/spinners/spinner-androidstyle.ts +58 -47
- package/components/static-preference-listview.ts +197 -151
- package/components/symbol-button.ts +23 -22
- package/components/tabbar.ts +80 -64
- package/controller/base-controller.ts +42 -35
- package/controller/controller-router.ts +4 -4
- package/controller/pageviewer-controller.ts +41 -27
- package/controller/presented-page-controller.ts +27 -15
- package/controller/splitview-controller.ts +77 -44
- package/controller/tabbar-controller.ts +33 -23
- package/dist/components/alert/input-alert.js +3 -3
- package/dist/components/alert/login-alert.js +5 -5
- package/dist/components/alert/plain-alert.js +1 -1
- package/dist/components/alert/uialert.js +4 -4
- package/dist/components/base.js +2 -1
- package/dist/components/custom-navigation-bar.js +61 -59
- package/dist/components/dialogs/dialog-sheet.js +5 -5
- package/dist/components/dialogs/form-dialog.js +2 -2
- package/dist/components/dialogs/list-dialog.js +15 -15
- package/dist/components/dialogs/text-dialog.js +6 -6
- package/dist/components/dynamic-contextmenu-view.js +11 -8
- package/dist/components/dynamic-itemsize-matrix.js +15 -13
- package/dist/components/dynamic-preference-listview.js +95 -90
- package/dist/components/dynamic-rowheight-list.js +7 -6
- package/dist/components/enhanced-imageview.js +18 -16
- package/dist/components/flowlayout.js +15 -14
- package/dist/components/image-pager.js +22 -21
- package/dist/components/page-control.js +2 -2
- package/dist/components/pageviewer-titlebar.js +20 -17
- package/dist/components/pageviewer.js +13 -12
- package/dist/components/refresh-button.js +5 -5
- package/dist/components/rotating-view.js +11 -11
- package/dist/components/searchbar.js +53 -41
- package/dist/components/sheet.js +4 -4
- package/dist/components/single-views.js +68 -68
- package/dist/components/spinners/loading-dual-ring.js +10 -10
- package/dist/components/spinners/loading-wedges.js +15 -15
- package/dist/components/spinners/spinner-androidstyle.js +45 -43
- package/dist/components/static-preference-listview.js +101 -102
- package/dist/components/symbol-button.js +14 -13
- package/dist/components/tabbar.js +54 -50
- package/dist/controller/base-controller.js +17 -14
- package/dist/controller/pageviewer-controller.js +13 -11
- package/dist/controller/presented-page-controller.js +6 -4
- package/dist/controller/splitview-controller.js +48 -31
- package/dist/controller/tabbar-controller.js +13 -12
- package/dist/test/custom-navigation-bar.js +11 -9
- package/dist/test/dynamic-contextmenu-view.js +16 -14
- package/dist/test/dynamic-itemsize-matrix.js +18 -17
- package/dist/test/dynamic-preference-listview.js +29 -29
- package/dist/test/flowlayout.js +33 -27
- package/dist/test/form-dialog.js +15 -13
- package/dist/test/pageviewer-controller.js +10 -7
- package/dist/test/pageviewer-titlebar.js +3 -3
- package/dist/test/pageviewer.js +16 -7
- package/dist/test/refresh-button.js +4 -4
- package/dist/test/searchbar.js +7 -7
- package/dist/test/splitview-controller.js +14 -11
- package/dist/test/static-preference-listview.js +29 -30
- package/dist/test/tabbar-controller.js +15 -12
- package/dist/utils/colors.js +1 -2
- package/dist/utils/l10n.js +28 -28
- package/dist/utils/path.js +2 -2
- package/dist/utils/rect.js +30 -8
- package/dist/utils/uitools.js +29 -19
- package/index.ts +43 -43
- package/package.json +2 -2
- package/test/custom-navigation-bar.ts +28 -28
- package/test/dynamic-contextmenu-view.ts +23 -21
- package/test/dynamic-itemsize-matrix.ts +27 -22
- package/test/dynamic-preference-listview.ts +35 -35
- package/test/flowlayout.ts +43 -33
- package/test/form-dialog.ts +44 -43
- package/test/pageviewer-controller.ts +13 -11
- package/test/pageviewer-titlebar.ts +4 -5
- package/test/pageviewer.ts +17 -8
- package/test/refresh-button.ts +5 -5
- package/test/searchbar.ts +8 -8
- package/test/splitview-controller.ts +31 -30
- package/test/static-preference-listview.ts +35 -34
- package/test/tabbar-controller.ts +32 -29
- package/utils/colors.ts +7 -8
- package/utils/cvid.ts +1 -2
- package/utils/l10n.ts +32 -32
- package/utils/path.ts +9 -9
- package/utils/rect.ts +31 -8
- package/utils/uitools.ts +30 -22
|
@@ -8,7 +8,7 @@ interface SymbolButtonProps {
|
|
|
8
8
|
tintColor: UIColor;
|
|
9
9
|
contentMode: number;
|
|
10
10
|
insets: JBInsets;
|
|
11
|
-
menu?: UiTypes.ContextMenuOptions
|
|
11
|
+
menu?: UiTypes.ContextMenuOptions;
|
|
12
12
|
hidden: boolean;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -26,12 +26,12 @@ interface SymbolButtonProps {
|
|
|
26
26
|
* - tapped
|
|
27
27
|
*/
|
|
28
28
|
export class SymbolButton extends Base<UIButtonView, UiTypes.ButtonOptions> {
|
|
29
|
-
_props: SymbolButtonProps
|
|
29
|
+
_props: SymbolButtonProps;
|
|
30
30
|
_defineView: () => UiTypes.ButtonOptions;
|
|
31
31
|
constructor({
|
|
32
32
|
props,
|
|
33
33
|
layout,
|
|
34
|
-
events = {}
|
|
34
|
+
events = {},
|
|
35
35
|
}: {
|
|
36
36
|
props: Partial<SymbolButtonProps>;
|
|
37
37
|
layout?: (make: MASConstraintMaker, view: UIButtonView) => void;
|
|
@@ -44,25 +44,26 @@ export class SymbolButton extends Base<UIButtonView, UiTypes.ButtonOptions> {
|
|
|
44
44
|
insets: $insets(12.5, 12.5, 12.5, 12.5),
|
|
45
45
|
tintColor: $color("primaryText"),
|
|
46
46
|
hidden: false,
|
|
47
|
-
...props
|
|
47
|
+
...props,
|
|
48
48
|
};
|
|
49
49
|
this._layout = layout;
|
|
50
50
|
this._defineView = () => {
|
|
51
51
|
const props = this._props.menu
|
|
52
52
|
? {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
radius: 0,
|
|
54
|
+
bgcolor: $color("clear"),
|
|
55
|
+
id: this.id,
|
|
56
|
+
menu: this._props.menu,
|
|
57
|
+
enabled: this._props.enabled,
|
|
58
|
+
hidden: this._props.hidden,
|
|
59
|
+
}
|
|
60
|
+
: {
|
|
61
|
+
radius: 0,
|
|
62
|
+
bgcolor: $color("clear"),
|
|
63
|
+
id: this.id,
|
|
64
|
+
enabled: this._props.enabled,
|
|
65
|
+
hidden: this._props.hidden,
|
|
66
|
+
};
|
|
66
67
|
return {
|
|
67
68
|
type: "button",
|
|
68
69
|
props,
|
|
@@ -75,18 +76,18 @@ export class SymbolButton extends Base<UIButtonView, UiTypes.ButtonOptions> {
|
|
|
75
76
|
image: this._props.image,
|
|
76
77
|
src: this._props.src,
|
|
77
78
|
tintColor: this._props.tintColor,
|
|
78
|
-
contentMode: this._props.contentMode
|
|
79
|
+
contentMode: this._props.contentMode,
|
|
79
80
|
},
|
|
80
81
|
layout: (make, view: UIImageView) => {
|
|
81
82
|
make.edges.insets(this._props.insets);
|
|
82
83
|
make.center.equalTo(view.super);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
84
|
+
},
|
|
85
|
+
},
|
|
85
86
|
],
|
|
86
87
|
layout: this._layout,
|
|
87
|
-
events
|
|
88
|
+
events,
|
|
88
89
|
};
|
|
89
|
-
}
|
|
90
|
+
};
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
set tintColor(tintColor: UIColor) {
|
package/components/tabbar.ts
CHANGED
|
@@ -18,7 +18,10 @@ class ImageLabelCell extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
18
18
|
label_loosed: (make: MASConstraintMaker, view: AllUIView) => void;
|
|
19
19
|
};
|
|
20
20
|
_defineView: () => UiTypes.ViewOptions;
|
|
21
|
-
constructor({
|
|
21
|
+
constructor({
|
|
22
|
+
props,
|
|
23
|
+
events = {},
|
|
24
|
+
}: {
|
|
22
25
|
props: {
|
|
23
26
|
symbol?: string;
|
|
24
27
|
image?: UIImage;
|
|
@@ -27,10 +30,10 @@ class ImageLabelCell extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
27
30
|
selectedSegmentTintColor: UIColor;
|
|
28
31
|
defaultSegmentTintColor: UIColor;
|
|
29
32
|
selected?: boolean;
|
|
30
|
-
}
|
|
33
|
+
};
|
|
31
34
|
events: {
|
|
32
35
|
tapped?: (index: number) => void;
|
|
33
|
-
}
|
|
36
|
+
};
|
|
34
37
|
}) {
|
|
35
38
|
super();
|
|
36
39
|
this._props = props;
|
|
@@ -52,14 +55,14 @@ class ImageLabelCell extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
52
55
|
label_loosed: (make, view) => {
|
|
53
56
|
make.left.equalTo(view.prev.right).inset(10);
|
|
54
57
|
make.centerY.equalTo(view.super);
|
|
55
|
-
}
|
|
58
|
+
},
|
|
56
59
|
};
|
|
57
60
|
this._defineView = () => {
|
|
58
61
|
return {
|
|
59
62
|
type: "view",
|
|
60
63
|
props: {
|
|
61
64
|
id: this.id,
|
|
62
|
-
userInteractionEnabled: true
|
|
65
|
+
userInteractionEnabled: true,
|
|
63
66
|
},
|
|
64
67
|
views: [
|
|
65
68
|
{
|
|
@@ -68,26 +71,26 @@ class ImageLabelCell extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
68
71
|
id: "image",
|
|
69
72
|
symbol: this._props.symbol,
|
|
70
73
|
image: this._props.image,
|
|
71
|
-
contentMode: 1
|
|
72
|
-
}
|
|
74
|
+
contentMode: 1,
|
|
75
|
+
},
|
|
73
76
|
},
|
|
74
77
|
{
|
|
75
78
|
type: "label",
|
|
76
79
|
props: {
|
|
77
80
|
id: "label",
|
|
78
81
|
text: this._props.text,
|
|
79
|
-
align: $align.center
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
+
align: $align.center,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
82
85
|
],
|
|
83
86
|
events: {
|
|
84
|
-
tapped: sender => {
|
|
87
|
+
tapped: (sender) => {
|
|
85
88
|
if (events.tapped) events.tapped(this._props.index);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
89
|
+
},
|
|
90
|
+
},
|
|
88
91
|
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
91
94
|
|
|
92
95
|
set selected(selected) {
|
|
93
96
|
this._props.selected = selected;
|
|
@@ -132,7 +135,10 @@ class ImageCell extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
132
135
|
image_loosed: (make: MASConstraintMaker, view: AllUIView) => void;
|
|
133
136
|
};
|
|
134
137
|
_defineView: () => UiTypes.ViewOptions;
|
|
135
|
-
constructor({
|
|
138
|
+
constructor({
|
|
139
|
+
props,
|
|
140
|
+
events = {},
|
|
141
|
+
}: {
|
|
136
142
|
props: {
|
|
137
143
|
symbol?: string;
|
|
138
144
|
image?: UIImage;
|
|
@@ -140,10 +146,10 @@ class ImageCell extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
140
146
|
selectedSegmentTintColor: UIColor;
|
|
141
147
|
defaultSegmentTintColor: UIColor;
|
|
142
148
|
selected?: boolean;
|
|
143
|
-
}
|
|
149
|
+
};
|
|
144
150
|
events: {
|
|
145
151
|
tapped?: (index: number) => void;
|
|
146
|
-
}
|
|
152
|
+
};
|
|
147
153
|
}) {
|
|
148
154
|
super();
|
|
149
155
|
this._props = props;
|
|
@@ -155,14 +161,14 @@ class ImageCell extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
155
161
|
image_loosed: (make, view) => {
|
|
156
162
|
make.center.equalTo(view.super);
|
|
157
163
|
make.size.equalTo($size(30, 30));
|
|
158
|
-
}
|
|
164
|
+
},
|
|
159
165
|
};
|
|
160
166
|
this._defineView = () => {
|
|
161
167
|
return {
|
|
162
168
|
type: "view",
|
|
163
169
|
props: {
|
|
164
170
|
id: this.id,
|
|
165
|
-
userInteractionEnabled: true
|
|
171
|
+
userInteractionEnabled: true,
|
|
166
172
|
},
|
|
167
173
|
views: [
|
|
168
174
|
{
|
|
@@ -171,17 +177,17 @@ class ImageCell extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
171
177
|
id: "image",
|
|
172
178
|
symbol: this._props.symbol,
|
|
173
179
|
image: this._props.image,
|
|
174
|
-
contentMode: 1
|
|
175
|
-
}
|
|
176
|
-
}
|
|
180
|
+
contentMode: 1,
|
|
181
|
+
},
|
|
182
|
+
},
|
|
177
183
|
],
|
|
178
184
|
events: {
|
|
179
|
-
tapped: sender => {
|
|
185
|
+
tapped: (sender) => {
|
|
180
186
|
if (events.tapped) events.tapped(this._props.index);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
187
|
+
},
|
|
188
|
+
},
|
|
183
189
|
};
|
|
184
|
-
}
|
|
190
|
+
};
|
|
185
191
|
}
|
|
186
192
|
|
|
187
193
|
set selected(selected) {
|
|
@@ -206,8 +212,8 @@ class ImageCell extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
206
212
|
}
|
|
207
213
|
|
|
208
214
|
/**
|
|
209
|
-
* 本组件是为了仿制 UITabBar
|
|
210
|
-
* 本组件不能指定布局而是应该指定 height(如果需要的话)
|
|
215
|
+
* 本组件是为了仿制 UITabBar
|
|
216
|
+
* 本组件不能指定布局而是应该指定 height(如果需要的话)
|
|
211
217
|
* 典型的使用方式是添加在布局为$layout.fill的视图中,并指定 items
|
|
212
218
|
*
|
|
213
219
|
* props:
|
|
@@ -229,7 +235,10 @@ class ImageCell extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
229
235
|
* - hide(animated=true) 隐藏
|
|
230
236
|
* - show(animated=true) 显示
|
|
231
237
|
*/
|
|
232
|
-
export class TabBar extends Base<
|
|
238
|
+
export class TabBar extends Base<
|
|
239
|
+
UIView | UIBlurView,
|
|
240
|
+
UiTypes.ViewOptions | UiTypes.BlurOptions
|
|
241
|
+
> {
|
|
233
242
|
_props: {
|
|
234
243
|
height: number;
|
|
235
244
|
items: { symbol?: string; image?: UIImage; title?: string }[];
|
|
@@ -245,7 +254,10 @@ export class TabBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTy
|
|
|
245
254
|
doubleTapped?: (cview: TabBar, index: number) => void;
|
|
246
255
|
};
|
|
247
256
|
_defineView: () => UiTypes.ViewOptions | UiTypes.BlurOptions;
|
|
248
|
-
constructor({
|
|
257
|
+
constructor({
|
|
258
|
+
props,
|
|
259
|
+
events = {},
|
|
260
|
+
}: {
|
|
249
261
|
props: {
|
|
250
262
|
height?: number;
|
|
251
263
|
items: { symbol?: string; image?: UIImage; title?: string }[];
|
|
@@ -253,11 +265,11 @@ export class TabBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTy
|
|
|
253
265
|
selectedSegmentTintColor?: UIColor;
|
|
254
266
|
defaultSegmentTintColor?: UIColor;
|
|
255
267
|
bgcolor?: UIColor;
|
|
256
|
-
}
|
|
268
|
+
};
|
|
257
269
|
events: {
|
|
258
270
|
changed?: (cview: TabBar, index: number) => void;
|
|
259
271
|
doubleTapped?: (cview: TabBar, index: number) => void;
|
|
260
|
-
}
|
|
272
|
+
};
|
|
261
273
|
}) {
|
|
262
274
|
super();
|
|
263
275
|
this._props = {
|
|
@@ -266,7 +278,7 @@ export class TabBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTy
|
|
|
266
278
|
selectedSegmentTintColor: $color("systemLink"),
|
|
267
279
|
defaultSegmentTintColor: footBarDefaultSegmentColor,
|
|
268
280
|
//bgcolor: $color("secondarySurface"),
|
|
269
|
-
...props
|
|
281
|
+
...props,
|
|
270
282
|
};
|
|
271
283
|
this._index = this._props.index;
|
|
272
284
|
this._events = events;
|
|
@@ -279,75 +291,79 @@ export class TabBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTy
|
|
|
279
291
|
distribution: $stackViewDistribution.fillEqually,
|
|
280
292
|
spacing: 0,
|
|
281
293
|
stack: {
|
|
282
|
-
views: this._cells.map(n => n.definition)
|
|
283
|
-
}
|
|
294
|
+
views: this._cells.map((n) => n.definition),
|
|
295
|
+
},
|
|
284
296
|
},
|
|
285
297
|
layout: (make, view) => {
|
|
286
298
|
make.height.equalTo(this._props.height - 0.5);
|
|
287
299
|
make.left.right.equalTo(view.super.safeArea);
|
|
288
300
|
make.top.equalTo(view.prev.bottom);
|
|
289
|
-
}
|
|
301
|
+
},
|
|
290
302
|
};
|
|
291
303
|
const line: UiTypes.ViewOptions = {
|
|
292
304
|
type: "view",
|
|
293
305
|
props: {
|
|
294
|
-
bgcolor: $color("separatorColor")
|
|
306
|
+
bgcolor: $color("separatorColor"),
|
|
295
307
|
},
|
|
296
308
|
layout: (make, view) => {
|
|
297
309
|
make.top.left.right.inset(0);
|
|
298
310
|
make.height.equalTo(0.5);
|
|
299
|
-
}
|
|
311
|
+
},
|
|
300
312
|
};
|
|
301
313
|
if (this._props.bgcolor) {
|
|
302
314
|
return {
|
|
303
315
|
type: "view",
|
|
304
316
|
props: {
|
|
305
317
|
id: this.id,
|
|
306
|
-
bgcolor: this._props.bgcolor
|
|
318
|
+
bgcolor: this._props.bgcolor,
|
|
307
319
|
},
|
|
308
320
|
layout: (make, view) => {
|
|
309
321
|
make.left.right.bottom.inset(0);
|
|
310
|
-
make.top
|
|
322
|
+
make.top
|
|
323
|
+
.equalTo(view.super.safeAreaBottom)
|
|
324
|
+
.inset(-this._props.height);
|
|
311
325
|
},
|
|
312
326
|
views: [line, stack],
|
|
313
327
|
events: {
|
|
314
|
-
ready: sender => (this.index = this._index),
|
|
315
|
-
layoutSubviews: sender => {
|
|
328
|
+
ready: (sender) => (this.index = this._index),
|
|
329
|
+
layoutSubviews: (sender) => {
|
|
316
330
|
const windowWidth = sender.frame.width;
|
|
317
331
|
if (windowWidth > 600) {
|
|
318
332
|
this._useLoosedLayout();
|
|
319
333
|
} else {
|
|
320
334
|
this._useTightenedLayout();
|
|
321
335
|
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
336
|
+
},
|
|
337
|
+
},
|
|
324
338
|
};
|
|
325
339
|
} else {
|
|
326
340
|
return {
|
|
327
341
|
type: "blur",
|
|
328
342
|
props: {
|
|
329
343
|
id: this.id,
|
|
330
|
-
style: 10
|
|
344
|
+
style: 10,
|
|
331
345
|
},
|
|
332
346
|
layout: (make, view) => {
|
|
333
347
|
make.left.right.bottom.inset(0);
|
|
334
|
-
make.top
|
|
348
|
+
make.top
|
|
349
|
+
.equalTo(view.super.safeAreaBottom)
|
|
350
|
+
.inset(-this._props.height);
|
|
335
351
|
},
|
|
336
352
|
views: [line, stack],
|
|
337
353
|
events: {
|
|
338
|
-
ready: sender => (this.index = this._index),
|
|
339
|
-
layoutSubviews: sender => {
|
|
354
|
+
ready: (sender) => (this.index = this._index),
|
|
355
|
+
layoutSubviews: (sender) => {
|
|
340
356
|
const windowWidth = sender.frame.width;
|
|
341
357
|
if (windowWidth > 600) {
|
|
342
358
|
this._useLoosedLayout();
|
|
343
359
|
} else {
|
|
344
360
|
this._useTightenedLayout();
|
|
345
361
|
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
362
|
+
},
|
|
363
|
+
},
|
|
348
364
|
};
|
|
349
365
|
}
|
|
350
|
-
}
|
|
366
|
+
};
|
|
351
367
|
}
|
|
352
368
|
|
|
353
369
|
_defineCells() {
|
|
@@ -360,10 +376,10 @@ export class TabBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTy
|
|
|
360
376
|
text: n.title,
|
|
361
377
|
index: i,
|
|
362
378
|
selectedSegmentTintColor: this._props.selectedSegmentTintColor,
|
|
363
|
-
defaultSegmentTintColor: this._props.defaultSegmentTintColor
|
|
379
|
+
defaultSegmentTintColor: this._props.defaultSegmentTintColor,
|
|
364
380
|
},
|
|
365
381
|
events: {
|
|
366
|
-
tapped: index => {
|
|
382
|
+
tapped: (index) => {
|
|
367
383
|
if (index !== this.index) {
|
|
368
384
|
this.index = index;
|
|
369
385
|
if (this._events.changed) this._events.changed(this, index);
|
|
@@ -371,8 +387,8 @@ export class TabBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTy
|
|
|
371
387
|
if (this._events.doubleTapped)
|
|
372
388
|
this._events.doubleTapped(this, index);
|
|
373
389
|
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
390
|
+
},
|
|
391
|
+
},
|
|
376
392
|
});
|
|
377
393
|
} else {
|
|
378
394
|
return new ImageCell({
|
|
@@ -381,10 +397,10 @@ export class TabBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTy
|
|
|
381
397
|
image: n.image ? n.image.alwaysTemplate : undefined,
|
|
382
398
|
index: i,
|
|
383
399
|
selectedSegmentTintColor: this._props.selectedSegmentTintColor,
|
|
384
|
-
defaultSegmentTintColor: this._props.defaultSegmentTintColor
|
|
400
|
+
defaultSegmentTintColor: this._props.defaultSegmentTintColor,
|
|
385
401
|
},
|
|
386
402
|
events: {
|
|
387
|
-
tapped: index => {
|
|
403
|
+
tapped: (index) => {
|
|
388
404
|
if (index !== this.index) {
|
|
389
405
|
this.index = index;
|
|
390
406
|
if (this._events.changed) this._events.changed(this, index);
|
|
@@ -392,8 +408,8 @@ export class TabBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTy
|
|
|
392
408
|
if (this._events.doubleTapped)
|
|
393
409
|
this._events.doubleTapped(this, index);
|
|
394
410
|
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
411
|
+
},
|
|
412
|
+
},
|
|
397
413
|
});
|
|
398
414
|
}
|
|
399
415
|
});
|
|
@@ -418,7 +434,7 @@ export class TabBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTy
|
|
|
418
434
|
if (animated) {
|
|
419
435
|
$ui.animate({
|
|
420
436
|
duration: 0.3,
|
|
421
|
-
animation: () => this.view.relayout()
|
|
437
|
+
animation: () => this.view.relayout(),
|
|
422
438
|
});
|
|
423
439
|
}
|
|
424
440
|
}
|
|
@@ -431,19 +447,19 @@ export class TabBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTy
|
|
|
431
447
|
if (animated) {
|
|
432
448
|
$ui.animate({
|
|
433
449
|
duration: 0.3,
|
|
434
|
-
animation: () => this.view.relayout()
|
|
450
|
+
animation: () => this.view.relayout(),
|
|
435
451
|
});
|
|
436
452
|
}
|
|
437
453
|
}
|
|
438
454
|
|
|
439
455
|
_useTightenedLayout() {
|
|
440
|
-
this._cells.forEach(n => {
|
|
456
|
+
this._cells.forEach((n) => {
|
|
441
457
|
n._useTightenedLayout();
|
|
442
458
|
});
|
|
443
459
|
}
|
|
444
460
|
|
|
445
461
|
_useLoosedLayout() {
|
|
446
|
-
this._cells.forEach(n => {
|
|
462
|
+
this._cells.forEach((n) => {
|
|
447
463
|
n._useLoosedLayout();
|
|
448
464
|
});
|
|
449
465
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Base } from
|
|
2
|
-
import { ContentView } from
|
|
1
|
+
import { Base } from "../components/base";
|
|
2
|
+
import { ContentView } from "../components/single-views";
|
|
3
3
|
import { cvid } from "../utils/cvid";
|
|
4
4
|
import { router } from "./controller-router";
|
|
5
5
|
|
|
@@ -17,14 +17,14 @@ const controllerStatus = {
|
|
|
17
17
|
loaded: 1,
|
|
18
18
|
appeared: 2,
|
|
19
19
|
disappeared: 3,
|
|
20
|
-
removed: 4
|
|
20
|
+
removed: 4,
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export class ControllerRootView extends ContentView {
|
|
24
24
|
constructor({
|
|
25
25
|
props,
|
|
26
26
|
layout,
|
|
27
|
-
events
|
|
27
|
+
events,
|
|
28
28
|
}: {
|
|
29
29
|
props: { bgcolor: UIColor };
|
|
30
30
|
layout: (make: MASConstraintMaker, view: UIView) => void;
|
|
@@ -34,10 +34,10 @@ export class ControllerRootView extends ContentView {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
set views(views: UiTypes.AllViewOptions[] | Base<any, any>[]) {
|
|
37
|
-
const _views: UiTypes.AllViewOptions[] = views.map(v => {
|
|
37
|
+
const _views: UiTypes.AllViewOptions[] = views.map((v) => {
|
|
38
38
|
if (v instanceof Base) return v.definition;
|
|
39
39
|
return v;
|
|
40
|
-
})
|
|
40
|
+
});
|
|
41
41
|
this._views = _views;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -55,14 +55,14 @@ export interface BaseControllerEvents {
|
|
|
55
55
|
didRemove?: (controller: BaseController) => void;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
/**
|
|
58
|
+
/**
|
|
59
59
|
* # CView Base Controller
|
|
60
|
-
*
|
|
60
|
+
*
|
|
61
61
|
* Cview 控件尽量保持非侵入性和功能专注。而控制器负责控件之间的关联和数据更新。
|
|
62
62
|
* 另外,控制器可以实现一些常用的页面构建形式,比如底部Tab分页,左侧滑动分页,弹出式页面等。
|
|
63
|
-
*
|
|
63
|
+
*
|
|
64
64
|
* ## 属性
|
|
65
|
-
*
|
|
65
|
+
*
|
|
66
66
|
* - id?: string 可以指定 id,如不指定,会自动赋值全局唯一 id
|
|
67
67
|
* - 只写 bgcolor?: UIColor = $color("primarySurface") rootView 的 bgcolor
|
|
68
68
|
* - 只读 cviews: {}
|
|
@@ -73,13 +73,14 @@ export interface BaseControllerEvents {
|
|
|
73
73
|
* - appearing = 2 处于可显示状态
|
|
74
74
|
* - disappearing = 3 处于不显示状态
|
|
75
75
|
* - removed = 4 根视图被移除
|
|
76
|
-
*
|
|
76
|
+
*
|
|
77
77
|
* ## 事件
|
|
78
|
-
*
|
|
78
|
+
*
|
|
79
79
|
* 5 个生命周期节点:创建、加载、显示、隐藏、销毁。后面四个具有生命周期事件。
|
|
80
|
-
*
|
|
81
|
-
* 创建阶段没有对应事件,此阶段适合为 rootView 添加子 view
|
|
82
|
-
*
|
|
80
|
+
*
|
|
81
|
+
* 创建阶段没有对应事件,此阶段适合为 rootView 添加子 view,
|
|
82
|
+
* 不能涉及对 UIView 的任何操作,因为此时 rootView 还未加载。
|
|
83
|
+
*
|
|
83
84
|
* 生命周期事件:
|
|
84
85
|
*
|
|
85
86
|
* 1. didLoad: controller => void 在 rootView 被加载之后执行
|
|
@@ -94,25 +95,27 @@ export interface BaseControllerEvents {
|
|
|
94
95
|
* 4. didRemove: controller => void 在 rootView 被移除的时候执行
|
|
95
96
|
* - 应该在此节点释放自定义的 objc
|
|
96
97
|
* - 数据持久化
|
|
97
|
-
*
|
|
98
|
+
*
|
|
98
99
|
* ## 方法
|
|
99
|
-
*
|
|
100
|
+
*
|
|
100
101
|
* 加载方法:
|
|
101
|
-
*
|
|
102
|
+
*
|
|
102
103
|
* 1. uirender(props) 此方法只能使用一次,对应的 Controller 将成为顶级 Controller
|
|
103
104
|
* 2. uipush(props)
|
|
104
105
|
* 3. 直接让 rootView.definition 包含在其他 View 的 views 参数中
|
|
105
|
-
*
|
|
106
|
+
*
|
|
106
107
|
* 生命周期管理:
|
|
107
|
-
*
|
|
108
|
+
*
|
|
108
109
|
* 1. load() 会在 rootView 的 ready 事件中自动调用,也可以手动调用,以加速运行
|
|
109
110
|
* 2. appear()
|
|
110
111
|
* 3. disappear()
|
|
111
|
-
* 4. remove() 用来移除 Router 中的当前 Controller,**请注意此方法和 rootView
|
|
112
|
-
*
|
|
112
|
+
* 4. remove() 用来移除 Router 中的当前 Controller,**请注意此方法和 rootView 的移除无关**,
|
|
113
|
+
* 如果通过 uirender 和 uipush,可以在销毁时自动执行 remove()
|
|
114
|
+
*
|
|
113
115
|
* ## 其他
|
|
114
|
-
*
|
|
115
|
-
* - rootView 可以直接通过 rootView.views 设置其_views
|
|
116
|
+
*
|
|
117
|
+
* - rootView 可以直接通过 rootView.views 设置其_views 属性,
|
|
118
|
+
* 其中元素可以为 view 定义也可以为 cview
|
|
116
119
|
*/
|
|
117
120
|
export class BaseController {
|
|
118
121
|
protected _props: BaseControllerProps;
|
|
@@ -123,7 +126,11 @@ export class BaseController {
|
|
|
123
126
|
[key: string]: Base<any, any>;
|
|
124
127
|
};
|
|
125
128
|
readonly rootView: ControllerRootView;
|
|
126
|
-
constructor({
|
|
129
|
+
constructor({
|
|
130
|
+
props,
|
|
131
|
+
layout = $layout.fill,
|
|
132
|
+
events = {},
|
|
133
|
+
}: {
|
|
127
134
|
props?: BaseControllerProps;
|
|
128
135
|
layout?: (make: MASConstraintMaker, view: UIView) => void;
|
|
129
136
|
events?: BaseControllerEvents;
|
|
@@ -135,13 +142,13 @@ export class BaseController {
|
|
|
135
142
|
this._status = controllerStatus.created; // status使用额外的get来使其只读
|
|
136
143
|
this.rootView = new ControllerRootView({
|
|
137
144
|
props: {
|
|
138
|
-
bgcolor: this._props.bgcolor || $color("primarySurface")
|
|
145
|
+
bgcolor: this._props.bgcolor || $color("primarySurface"),
|
|
139
146
|
},
|
|
140
147
|
layout,
|
|
141
148
|
events: {
|
|
142
|
-
ready: sender => this.load()
|
|
143
|
-
}
|
|
144
|
-
})
|
|
149
|
+
ready: (sender) => this.load(),
|
|
150
|
+
},
|
|
151
|
+
});
|
|
145
152
|
this.cviews = {};
|
|
146
153
|
}
|
|
147
154
|
|
|
@@ -150,7 +157,7 @@ export class BaseController {
|
|
|
150
157
|
if (this._status !== controllerStatus.created) return;
|
|
151
158
|
this._status = controllerStatus.loaded;
|
|
152
159
|
if (this._events.didLoad) this._events.didLoad(this);
|
|
153
|
-
router.add(this)
|
|
160
|
+
router.add(this);
|
|
154
161
|
}
|
|
155
162
|
|
|
156
163
|
appear() {
|
|
@@ -180,7 +187,7 @@ export class BaseController {
|
|
|
180
187
|
// 如果已经移除,不可以再次运行
|
|
181
188
|
if (this._status === controllerStatus.removed) return;
|
|
182
189
|
if (this._events.didRemove) this._events.didRemove(this);
|
|
183
|
-
router.delete(this)
|
|
190
|
+
router.delete(this);
|
|
184
191
|
this._status = controllerStatus.removed;
|
|
185
192
|
}
|
|
186
193
|
|
|
@@ -192,8 +199,8 @@ export class BaseController {
|
|
|
192
199
|
events: {
|
|
193
200
|
appeared: () => this.appear(),
|
|
194
201
|
disappeared: () => this.disappear(),
|
|
195
|
-
dealloc: () => this.remove()
|
|
196
|
-
}
|
|
202
|
+
dealloc: () => this.remove(),
|
|
203
|
+
},
|
|
197
204
|
});
|
|
198
205
|
}
|
|
199
206
|
|
|
@@ -204,8 +211,8 @@ export class BaseController {
|
|
|
204
211
|
events: {
|
|
205
212
|
appeared: () => this.appear(),
|
|
206
213
|
disappeared: () => this.disappear(),
|
|
207
|
-
dealloc: () => this.remove()
|
|
208
|
-
}
|
|
214
|
+
dealloc: () => this.remove(),
|
|
215
|
+
},
|
|
209
216
|
});
|
|
210
217
|
}
|
|
211
218
|
|
|
@@ -2,17 +2,17 @@ import { BaseController } from "./base-controller";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 控制器的路由器,用于管理控制器的集合和操作。
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* ## 属性
|
|
7
7
|
* - `root`:根控制器。
|
|
8
8
|
* - `appeared`:状态为appeared的控制器列表。
|
|
9
9
|
* - `controllerSet`:控制器集合。
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
11
|
* ## 方法
|
|
12
12
|
* - `add(controller: BaseController)`:添加控制器到路由器中。
|
|
13
13
|
* - `delete(controller: BaseController)`:从路由器中删除控制器。
|
|
14
14
|
* - `get(id: string)`:根据控制器的ID获取控制器。
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
16
|
*/
|
|
17
17
|
class Router {
|
|
18
18
|
private _set: Set<BaseController>;
|
|
@@ -70,4 +70,4 @@ class Router {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export const router = new Router();
|
|
73
|
+
export const router = new Router();
|