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
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BaseController,
|
|
3
|
+
BaseControllerProps,
|
|
4
|
+
BaseControllerEvents,
|
|
5
|
+
} from "./base-controller";
|
|
2
6
|
import { PageViewer } from "../components/pageviewer";
|
|
3
7
|
import { PageViewerTitleBar } from "../components/pageviewer-titlebar";
|
|
4
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
CustomNavigationBar,
|
|
10
|
+
NavigationBarProps,
|
|
11
|
+
} from "../components/custom-navigation-bar";
|
|
5
12
|
|
|
6
13
|
interface PageViewerControllerProps extends BaseControllerProps {
|
|
7
|
-
items: { controller: BaseController
|
|
14
|
+
items: { controller: BaseController; title: string }[];
|
|
8
15
|
navBarProps?: Partial<NavigationBarProps>;
|
|
9
16
|
index?: number;
|
|
10
17
|
}
|
|
11
18
|
|
|
12
|
-
/**
|
|
19
|
+
/**
|
|
13
20
|
* # CView PageViewer Controller
|
|
14
|
-
*
|
|
21
|
+
*
|
|
15
22
|
* 一个可以左右滑动翻页的控制器。
|
|
16
|
-
*
|
|
23
|
+
*
|
|
17
24
|
* Props:
|
|
18
|
-
*
|
|
25
|
+
*
|
|
19
26
|
* - items: { controller: Controller, title: string }[]
|
|
20
27
|
* - navBarProps: {} 可用于 navBar 的其他属性,不包括 title 和 titleView
|
|
21
28
|
*/
|
|
@@ -25,8 +32,12 @@ export class PageViewerController extends BaseController {
|
|
|
25
32
|
pageviewer: PageViewer;
|
|
26
33
|
titlebar: PageViewerTitleBar;
|
|
27
34
|
navbar: CustomNavigationBar;
|
|
28
|
-
}
|
|
29
|
-
constructor({
|
|
35
|
+
};
|
|
36
|
+
constructor({
|
|
37
|
+
props,
|
|
38
|
+
layout,
|
|
39
|
+
events = {},
|
|
40
|
+
}: {
|
|
30
41
|
props: PageViewerControllerProps;
|
|
31
42
|
layout?: (make: MASConstraintMaker, view: UIView) => void;
|
|
32
43
|
events?: BaseControllerEvents;
|
|
@@ -34,8 +45,10 @@ export class PageViewerController extends BaseController {
|
|
|
34
45
|
super({
|
|
35
46
|
props: {
|
|
36
47
|
id: props.id,
|
|
37
|
-
bgcolor: props.bgcolor
|
|
38
|
-
},
|
|
48
|
+
bgcolor: props.bgcolor,
|
|
49
|
+
},
|
|
50
|
+
layout,
|
|
51
|
+
events,
|
|
39
52
|
});
|
|
40
53
|
this._props = props;
|
|
41
54
|
this.cviews = {} as {
|
|
@@ -46,42 +59,43 @@ export class PageViewerController extends BaseController {
|
|
|
46
59
|
this.cviews.pageviewer = new PageViewer({
|
|
47
60
|
props: {
|
|
48
61
|
page: this._props.index || 0,
|
|
49
|
-
cviews: this._props.items.map(n => n.controller.rootView)
|
|
62
|
+
cviews: this._props.items.map((n) => n.controller.rootView),
|
|
50
63
|
},
|
|
51
64
|
layout: (make, view) => {
|
|
52
|
-
make.left.right.bottom.inset(0)
|
|
53
|
-
make.top.equalTo(view.prev.bottom)
|
|
65
|
+
make.left.right.bottom.inset(0);
|
|
66
|
+
make.top.equalTo(view.prev.bottom);
|
|
54
67
|
},
|
|
55
68
|
events: {
|
|
56
|
-
floatPageChanged: (cview, floatPage) =>
|
|
57
|
-
|
|
69
|
+
floatPageChanged: (cview, floatPage) =>
|
|
70
|
+
(this.cviews.titlebar.floatedIndex = floatPage),
|
|
71
|
+
},
|
|
58
72
|
});
|
|
59
73
|
this.cviews.titlebar = new PageViewerTitleBar({
|
|
60
74
|
props: {
|
|
61
|
-
items: this._props.items.map(n => n.title),
|
|
62
|
-
index: this._props.index || 0
|
|
75
|
+
items: this._props.items.map((n) => n.title),
|
|
76
|
+
index: this._props.index || 0,
|
|
63
77
|
},
|
|
64
78
|
layout: $layout.fill,
|
|
65
79
|
events: {
|
|
66
|
-
changed: (cview, index) => this.cviews.pageviewer.scrollToPage(index)
|
|
67
|
-
}
|
|
80
|
+
changed: (cview, index) => this.cviews.pageviewer.scrollToPage(index),
|
|
81
|
+
},
|
|
68
82
|
});
|
|
69
83
|
this.cviews.navbar = new CustomNavigationBar({
|
|
70
84
|
props: {
|
|
71
85
|
...this._props.navBarProps,
|
|
72
|
-
titleView: this.cviews.titlebar
|
|
73
|
-
}
|
|
86
|
+
titleView: this.cviews.titlebar,
|
|
87
|
+
},
|
|
74
88
|
});
|
|
75
|
-
this.rootView.views = [this.cviews.navbar, this.cviews.pageviewer]
|
|
89
|
+
this.rootView.views = [this.cviews.navbar, this.cviews.pageviewer];
|
|
76
90
|
}
|
|
77
91
|
|
|
78
92
|
get index() {
|
|
79
|
-
return this._props.index || 0
|
|
93
|
+
return this._props.index || 0;
|
|
80
94
|
}
|
|
81
95
|
|
|
82
96
|
set index(num) {
|
|
83
|
-
this.cviews.titlebar.index = num
|
|
84
|
-
this.cviews.pageviewer.page = num
|
|
85
|
-
this._props.index = num
|
|
97
|
+
this.cviews.titlebar.index = num;
|
|
98
|
+
this.cviews.pageviewer.page = num;
|
|
99
|
+
this._props.index = num;
|
|
86
100
|
}
|
|
87
101
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BaseController,
|
|
3
|
+
BaseControllerProps,
|
|
4
|
+
BaseControllerEvents,
|
|
5
|
+
ControllerRootView,
|
|
6
|
+
} from "./base-controller";
|
|
2
7
|
import { Sheet } from "../components/sheet";
|
|
3
8
|
|
|
4
9
|
interface PresentedPageControllerProps extends BaseControllerProps {
|
|
@@ -8,25 +13,29 @@ interface PresentedPageControllerProps extends BaseControllerProps {
|
|
|
8
13
|
}
|
|
9
14
|
|
|
10
15
|
/** # CView PresentedPageController
|
|
11
|
-
*
|
|
16
|
+
*
|
|
12
17
|
* ## Props
|
|
13
|
-
*
|
|
18
|
+
*
|
|
14
19
|
* - presentMode?: number = 1
|
|
15
20
|
* - animated?: boolean = true
|
|
16
21
|
* - interactiveDismissalDisabled?: boolean = false
|
|
17
22
|
* - bgcolor?: UIColor = $color("secondarySurface")
|
|
18
|
-
*
|
|
23
|
+
*
|
|
19
24
|
* ## 专用方法
|
|
20
|
-
*
|
|
25
|
+
*
|
|
21
26
|
* - present() 在 `sheet.present()` 之后会先后执行 `load()` 和 `appear()`
|
|
22
27
|
* - dismiss()
|
|
23
|
-
*
|
|
28
|
+
*
|
|
24
29
|
* ## 布局
|
|
25
30
|
* 此控制器的 layout 必定为 `$layout.fill`,无需自行设定
|
|
26
31
|
*/
|
|
27
32
|
export class PresentedPageController extends BaseController {
|
|
28
33
|
private _sheet: Sheet<ControllerRootView, UIView, UiTypes.ViewOptions>;
|
|
29
|
-
constructor({
|
|
34
|
+
constructor({
|
|
35
|
+
props,
|
|
36
|
+
layout,
|
|
37
|
+
events,
|
|
38
|
+
}: {
|
|
30
39
|
props?: Partial<PresentedPageControllerProps>;
|
|
31
40
|
layout?: (make: MASConstraintMaker, view: UIView) => void;
|
|
32
41
|
events?: BaseControllerEvents;
|
|
@@ -34,26 +43,29 @@ export class PresentedPageController extends BaseController {
|
|
|
34
43
|
super({
|
|
35
44
|
props: {
|
|
36
45
|
id: props?.id,
|
|
37
|
-
bgcolor: props?.bgcolor
|
|
38
|
-
},
|
|
46
|
+
bgcolor: props?.bgcolor,
|
|
47
|
+
},
|
|
48
|
+
layout,
|
|
49
|
+
events,
|
|
39
50
|
});
|
|
40
51
|
this._sheet = new Sheet<ControllerRootView, UIView, UiTypes.ViewOptions>({
|
|
41
52
|
presentMode: props?.presentMode ?? 1,
|
|
42
53
|
animated: props?.animated ?? true,
|
|
43
|
-
interactiveDismissalDisabled:
|
|
54
|
+
interactiveDismissalDisabled:
|
|
55
|
+
props?.interactiveDismissalDisabled || false,
|
|
44
56
|
bgcolor: props?.bgcolor || $color("secondarySurface"),
|
|
45
57
|
cview: this.rootView,
|
|
46
|
-
dismissalHandler: () => this.remove()
|
|
58
|
+
dismissalHandler: () => this.remove(),
|
|
47
59
|
});
|
|
48
60
|
}
|
|
49
61
|
|
|
50
62
|
present() {
|
|
51
|
-
if (this._sheet) this._sheet.present()
|
|
52
|
-
this.load()
|
|
53
|
-
this.appear()
|
|
63
|
+
if (this._sheet) this._sheet.present();
|
|
64
|
+
this.load();
|
|
65
|
+
this.appear();
|
|
54
66
|
}
|
|
55
67
|
|
|
56
68
|
dismiss() {
|
|
57
|
-
if (this._sheet) this._sheet.dismiss()
|
|
69
|
+
if (this._sheet) this._sheet.dismiss();
|
|
58
70
|
}
|
|
59
71
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BaseController,
|
|
3
|
+
BaseControllerProps,
|
|
4
|
+
BaseControllerEvents,
|
|
5
|
+
} from "./base-controller";
|
|
2
6
|
import { Base } from "../components/base";
|
|
3
7
|
import { ContentView } from "../components/single-views";
|
|
4
8
|
import { cvid } from "../utils/cvid";
|
|
@@ -8,10 +12,14 @@ class SecondaryView extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
8
12
|
_layouts: {
|
|
9
13
|
hidden: (make: MASConstraintMaker, view: AllUIView) => void;
|
|
10
14
|
shown: (make: MASConstraintMaker, view: AllUIView) => void;
|
|
11
|
-
}
|
|
15
|
+
};
|
|
12
16
|
line: ContentView;
|
|
13
17
|
_defineView: () => UiTypes.ViewOptions;
|
|
14
|
-
constructor({
|
|
18
|
+
constructor({
|
|
19
|
+
props,
|
|
20
|
+
layout,
|
|
21
|
+
views = [],
|
|
22
|
+
}: {
|
|
15
23
|
props?: UiTypes.BaseViewProps;
|
|
16
24
|
layout?: (make: MASConstraintMaker, view: UIView) => void;
|
|
17
25
|
views?: UiTypes.AllViewOptions[];
|
|
@@ -19,7 +27,7 @@ class SecondaryView extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
19
27
|
super();
|
|
20
28
|
this._props = {
|
|
21
29
|
bgcolor: $color("groupedBackground", "secondarySurface"),
|
|
22
|
-
...props
|
|
30
|
+
...props,
|
|
23
31
|
};
|
|
24
32
|
this._layouts = {
|
|
25
33
|
hidden: (make, view) => {
|
|
@@ -35,28 +43,28 @@ class SecondaryView extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
35
43
|
make.width.greaterThanOrEqualTo(250);
|
|
36
44
|
make.width.lessThanOrEqualTo(350);
|
|
37
45
|
make.width.equalTo(view.super).dividedBy(2.5).priority(999);
|
|
38
|
-
}
|
|
46
|
+
},
|
|
39
47
|
};
|
|
40
48
|
this.line = new ContentView({
|
|
41
49
|
props: {
|
|
42
|
-
bgcolor: $color("separatorColor")
|
|
50
|
+
bgcolor: $color("separatorColor"),
|
|
43
51
|
},
|
|
44
52
|
layout: (make, view) => {
|
|
45
53
|
make.top.bottom.right.inset(0);
|
|
46
54
|
make.width.equalTo(0.5);
|
|
47
|
-
}
|
|
55
|
+
},
|
|
48
56
|
});
|
|
49
57
|
this._defineView = () => {
|
|
50
58
|
return {
|
|
51
59
|
type: "view",
|
|
52
60
|
props: {
|
|
53
61
|
...this._props,
|
|
54
|
-
id: this.id
|
|
62
|
+
id: this.id,
|
|
55
63
|
},
|
|
56
64
|
layout,
|
|
57
|
-
views: [...views, this.line.definition]
|
|
65
|
+
views: [...views, this.line.definition],
|
|
58
66
|
};
|
|
59
|
-
}
|
|
67
|
+
};
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
add(view: UiTypes.AllViewOptions | Base<any, any>) {
|
|
@@ -68,7 +76,7 @@ class SecondaryView extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
68
76
|
this.view.remakeLayout(this._layouts.shown);
|
|
69
77
|
$ui.animate({
|
|
70
78
|
duration: 0.3,
|
|
71
|
-
animation: () => this.view.relayout()
|
|
79
|
+
animation: () => this.view.relayout(),
|
|
72
80
|
});
|
|
73
81
|
}
|
|
74
82
|
|
|
@@ -76,7 +84,7 @@ class SecondaryView extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
76
84
|
this.view.remakeLayout(this._layouts.hidden);
|
|
77
85
|
$ui.animate({
|
|
78
86
|
duration: 0.3,
|
|
79
|
-
animation: () => this.view.relayout()
|
|
87
|
+
animation: () => this.view.relayout(),
|
|
80
88
|
});
|
|
81
89
|
}
|
|
82
90
|
}
|
|
@@ -90,7 +98,10 @@ class MaskView extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
90
98
|
_dismissEvent: () => void;
|
|
91
99
|
_gestureObject: any;
|
|
92
100
|
_defineView: () => UiTypes.ViewOptions;
|
|
93
|
-
constructor({
|
|
101
|
+
constructor({
|
|
102
|
+
props,
|
|
103
|
+
layout = $layout.fill,
|
|
104
|
+
}: {
|
|
94
105
|
props: {
|
|
95
106
|
bgcolor?: UIColor;
|
|
96
107
|
dismissHandler?: () => void;
|
|
@@ -110,14 +121,14 @@ class MaskView extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
110
121
|
props: {
|
|
111
122
|
...this._props,
|
|
112
123
|
hidden: true,
|
|
113
|
-
id: this.id
|
|
124
|
+
id: this.id,
|
|
114
125
|
},
|
|
115
126
|
layout,
|
|
116
127
|
events: {
|
|
117
|
-
ready: sender => this._addGesture(sender, this._dismissEvent)
|
|
118
|
-
}
|
|
128
|
+
ready: (sender) => this._addGesture(sender, this._dismissEvent),
|
|
129
|
+
},
|
|
119
130
|
};
|
|
120
|
-
}
|
|
131
|
+
};
|
|
121
132
|
}
|
|
122
133
|
|
|
123
134
|
_addGesture(view: UIView, event: () => void) {
|
|
@@ -126,11 +137,12 @@ class MaskView extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
126
137
|
type: objectId + ": NSObject",
|
|
127
138
|
events: {
|
|
128
139
|
swipeEvent: event,
|
|
129
|
-
tapEvent: event
|
|
130
|
-
}
|
|
140
|
+
tapEvent: event,
|
|
141
|
+
},
|
|
131
142
|
});
|
|
132
143
|
const object = $objc(objectId).$new();
|
|
133
|
-
$objc_retain(object); //
|
|
144
|
+
$objc_retain(object); // 此步骤是必须的,否则将很快被系统释放掉,
|
|
145
|
+
// 但是必须在关闭时手动释放掉,否则再次启动可能会有问题
|
|
134
146
|
this._gestureObject = object;
|
|
135
147
|
const swipeGestureRecognizer = $objc("UISwipeGestureRecognizer")
|
|
136
148
|
.$alloc()
|
|
@@ -160,19 +172,21 @@ class MaskView extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
interface SplitViewControllerProps extends BaseControllerProps {
|
|
163
|
-
items: { controller: BaseController
|
|
175
|
+
items: { controller: BaseController; bgcolor: UIColor }[];
|
|
164
176
|
}
|
|
165
177
|
|
|
166
178
|
/** # CView SplitView Controller
|
|
167
|
-
*
|
|
179
|
+
*
|
|
168
180
|
* 实现左右分栏布局的控制器, 本身不提供除了分割线以外的视觉效果
|
|
169
|
-
*
|
|
181
|
+
*
|
|
170
182
|
* 此控制器加载后,会禁用原本的ScreenEdgePanGesture,此控制器应该作为根控制器使用
|
|
171
|
-
*
|
|
172
|
-
* @param options.props.items: { controller: Controller, bgcolor: UIColor }[]
|
|
173
|
-
*
|
|
183
|
+
*
|
|
184
|
+
* @param options.props.items: { controller: Controller, bgcolor: UIColor }[]
|
|
185
|
+
* 其中第一个放在主视图上, 第二个放在次视图上
|
|
186
|
+
*
|
|
174
187
|
* @property sideBarShown: boolean = false 侧栏是否显示
|
|
175
|
-
* @property canShowSidebar: boolean = true
|
|
188
|
+
* @property canShowSidebar: boolean = true 是否启动显示侧栏的动作
|
|
189
|
+
* (若为false,依然可以用sideBarShown来控制侧栏的显示)
|
|
176
190
|
*/
|
|
177
191
|
export class SplitViewController extends BaseController {
|
|
178
192
|
private _screenEdgePanGestureObject: any;
|
|
@@ -185,7 +199,11 @@ export class SplitViewController extends BaseController {
|
|
|
185
199
|
secondaryView: SecondaryView;
|
|
186
200
|
maskView: MaskView;
|
|
187
201
|
};
|
|
188
|
-
constructor({
|
|
202
|
+
constructor({
|
|
203
|
+
props,
|
|
204
|
+
layout,
|
|
205
|
+
events,
|
|
206
|
+
}: {
|
|
189
207
|
props: SplitViewControllerProps;
|
|
190
208
|
layout?: (make: MASConstraintMaker, view: UIView) => void;
|
|
191
209
|
events?: BaseControllerEvents;
|
|
@@ -193,8 +211,25 @@ export class SplitViewController extends BaseController {
|
|
|
193
211
|
super({
|
|
194
212
|
props: {
|
|
195
213
|
id: props.id,
|
|
196
|
-
bgcolor: props.bgcolor
|
|
197
|
-
},
|
|
214
|
+
bgcolor: props.bgcolor,
|
|
215
|
+
},
|
|
216
|
+
layout,
|
|
217
|
+
events: {
|
|
218
|
+
...events,
|
|
219
|
+
didAppear: (sender) => {
|
|
220
|
+
if (this._sideBarShown) {
|
|
221
|
+
this._secondaryController.appear();
|
|
222
|
+
} else {
|
|
223
|
+
this._primaryController.appear();
|
|
224
|
+
}
|
|
225
|
+
events?.didAppear?.(this);
|
|
226
|
+
},
|
|
227
|
+
didDisappear: () => {
|
|
228
|
+
this._primaryController.disappear();
|
|
229
|
+
this._secondaryController.disappear();
|
|
230
|
+
events?.didDisappear?.(this);
|
|
231
|
+
},
|
|
232
|
+
},
|
|
198
233
|
});
|
|
199
234
|
this._sideBarShown = false;
|
|
200
235
|
this._canShowSidebar = true;
|
|
@@ -207,25 +242,23 @@ export class SplitViewController extends BaseController {
|
|
|
207
242
|
};
|
|
208
243
|
this.cviews.secondaryView = new SecondaryView({
|
|
209
244
|
props: {
|
|
210
|
-
bgcolor: props.items[1].bgcolor || $color("clear")
|
|
245
|
+
bgcolor: props.items[1].bgcolor || $color("clear"),
|
|
211
246
|
},
|
|
212
247
|
layout: (make, view) => {
|
|
213
248
|
make.top.bottom.inset(0);
|
|
214
249
|
make.right.equalTo(view.super.left);
|
|
215
250
|
make.width.equalTo(view.super).dividedBy(3);
|
|
216
251
|
},
|
|
217
|
-
views: [
|
|
218
|
-
props.items[1].controller.rootView.definition
|
|
219
|
-
]
|
|
252
|
+
views: [props.items[1].controller.rootView.definition],
|
|
220
253
|
});
|
|
221
254
|
this.cviews.maskView = new MaskView({
|
|
222
255
|
props: {
|
|
223
|
-
dismissHandler: () => (this.sideBarShown = false)
|
|
224
|
-
}
|
|
256
|
+
dismissHandler: () => (this.sideBarShown = false),
|
|
257
|
+
},
|
|
225
258
|
});
|
|
226
259
|
this.cviews.primaryView = new ContentView({
|
|
227
260
|
props: {
|
|
228
|
-
bgcolor: props.items[0].bgcolor || $color("clear")
|
|
261
|
+
bgcolor: props.items[0].bgcolor || $color("clear"),
|
|
229
262
|
},
|
|
230
263
|
layout: (make, view) => {
|
|
231
264
|
make.top.bottom.inset(0);
|
|
@@ -234,8 +267,8 @@ export class SplitViewController extends BaseController {
|
|
|
234
267
|
},
|
|
235
268
|
views: [
|
|
236
269
|
props.items[0].controller.rootView.definition,
|
|
237
|
-
this.cviews.maskView.definition
|
|
238
|
-
]
|
|
270
|
+
this.cviews.maskView.definition,
|
|
271
|
+
],
|
|
239
272
|
});
|
|
240
273
|
this._screenEdgePanGestureObject = this._defineGestureObject(() => {
|
|
241
274
|
if (!this.sideBarShown && this._canShowSidebar) this.sideBarShown = true;
|
|
@@ -257,7 +290,7 @@ export class SplitViewController extends BaseController {
|
|
|
257
290
|
uirender() {
|
|
258
291
|
const props: UiTypes.RootViewPrefs = {
|
|
259
292
|
navBarHidden: true,
|
|
260
|
-
statusBarStyle: 0
|
|
293
|
+
statusBarStyle: 0,
|
|
261
294
|
};
|
|
262
295
|
super.uirender(props);
|
|
263
296
|
}
|
|
@@ -265,7 +298,7 @@ export class SplitViewController extends BaseController {
|
|
|
265
298
|
uipush() {
|
|
266
299
|
const props: UiTypes.RootViewPrefs = {
|
|
267
300
|
navBarHidden: true,
|
|
268
|
-
statusBarStyle: 0
|
|
301
|
+
statusBarStyle: 0,
|
|
269
302
|
};
|
|
270
303
|
super.uipush(props);
|
|
271
304
|
}
|
|
@@ -275,8 +308,8 @@ export class SplitViewController extends BaseController {
|
|
|
275
308
|
$define({
|
|
276
309
|
type: objectId + ": NSObject",
|
|
277
310
|
events: {
|
|
278
|
-
screenEdgePanEvent: event
|
|
279
|
-
}
|
|
311
|
+
screenEdgePanEvent: event,
|
|
312
|
+
},
|
|
280
313
|
});
|
|
281
314
|
const object = $objc(objectId).$new();
|
|
282
315
|
$objc_retain(object);
|
|
@@ -342,4 +375,4 @@ export class SplitViewController extends BaseController {
|
|
|
342
375
|
set canShowSidebar(bool: boolean) {
|
|
343
376
|
this._canShowSidebar = bool;
|
|
344
377
|
}
|
|
345
|
-
}
|
|
378
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BaseController,
|
|
3
|
+
BaseControllerProps,
|
|
4
|
+
BaseControllerEvents,
|
|
5
|
+
} from "./base-controller";
|
|
2
6
|
import { ContentView } from "../components/single-views";
|
|
3
7
|
import { TabBar } from "../components/tabbar";
|
|
4
8
|
|
|
@@ -19,18 +23,18 @@ interface TabBarControllerEvents extends BaseControllerEvents {
|
|
|
19
23
|
doubleTapped?: (controller: TabBarController, index: number) => void;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
/**
|
|
26
|
+
/**
|
|
23
27
|
* # CView TabBar Controller
|
|
24
28
|
*
|
|
25
29
|
* TabBarController 是一个 PagingController
|
|
26
30
|
*
|
|
27
31
|
* ## 属性
|
|
28
|
-
*
|
|
29
|
-
* - items: {title?: string,
|
|
30
|
-
* symbol?: string,
|
|
31
|
-
* image?: UIImage,
|
|
32
|
-
* tintColor?: UIColor,
|
|
33
|
-
* bgcolor?: UIColor,
|
|
32
|
+
*
|
|
33
|
+
* - items: {title?: string,
|
|
34
|
+
* symbol?: string,
|
|
35
|
+
* image?: UIImage,
|
|
36
|
+
* tintColor?: UIColor,
|
|
37
|
+
* bgcolor?: UIColor,
|
|
34
38
|
* controller: Controller}[]
|
|
35
39
|
* - index: number = 0
|
|
36
40
|
*/
|
|
@@ -39,9 +43,13 @@ export class TabBarController extends BaseController {
|
|
|
39
43
|
cviews: {
|
|
40
44
|
tabbar: TabBar;
|
|
41
45
|
pageContentView: ContentView;
|
|
42
|
-
}
|
|
46
|
+
};
|
|
43
47
|
pages: ContentView[];
|
|
44
|
-
constructor({
|
|
48
|
+
constructor({
|
|
49
|
+
props,
|
|
50
|
+
layout,
|
|
51
|
+
events = {},
|
|
52
|
+
}: {
|
|
45
53
|
props: TabBarControllerProps;
|
|
46
54
|
layout?: (make: MASConstraintMaker, view: UIView) => void;
|
|
47
55
|
events?: TabBarControllerEvents;
|
|
@@ -49,7 +57,7 @@ export class TabBarController extends BaseController {
|
|
|
49
57
|
super({
|
|
50
58
|
props: {
|
|
51
59
|
id: props.id,
|
|
52
|
-
bgcolor: props.bgcolor
|
|
60
|
+
bgcolor: props.bgcolor,
|
|
53
61
|
},
|
|
54
62
|
layout,
|
|
55
63
|
events: {
|
|
@@ -61,12 +69,12 @@ export class TabBarController extends BaseController {
|
|
|
61
69
|
didDisappear: () => {
|
|
62
70
|
this._props.items[this.index].controller.disappear();
|
|
63
71
|
events.didDisappear?.(this);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
72
|
+
},
|
|
73
|
+
},
|
|
66
74
|
});
|
|
67
75
|
this._props = {
|
|
68
76
|
items: props.items,
|
|
69
|
-
index: props.index || 0
|
|
77
|
+
index: props.index || 0,
|
|
70
78
|
};
|
|
71
79
|
this.cviews = {} as {
|
|
72
80
|
tabbar: TabBar;
|
|
@@ -75,39 +83,41 @@ export class TabBarController extends BaseController {
|
|
|
75
83
|
this.cviews.tabbar = new TabBar({
|
|
76
84
|
props: {
|
|
77
85
|
items: this._props.items,
|
|
78
|
-
index: this._props.index
|
|
86
|
+
index: this._props.index,
|
|
79
87
|
},
|
|
80
88
|
events: {
|
|
81
89
|
changed: (cview, index) => {
|
|
82
90
|
this.index = index;
|
|
83
|
-
this._props.items
|
|
91
|
+
this._props.items
|
|
92
|
+
.find((item) => item.controller.status === 2)
|
|
93
|
+
?.controller.disappear();
|
|
84
94
|
this._props.items[index].controller.appear();
|
|
85
95
|
events.changed?.(this, index);
|
|
86
96
|
},
|
|
87
97
|
doubleTapped: (cview, index) => {
|
|
88
98
|
events.doubleTapped?.(this, index);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
99
|
+
},
|
|
100
|
+
},
|
|
91
101
|
});
|
|
92
102
|
|
|
93
103
|
this.pages = this._props.items.map((n, i) => {
|
|
94
104
|
return new ContentView({
|
|
95
105
|
props: {
|
|
96
106
|
bgcolor: n.bgcolor || this._props.bgcolor,
|
|
97
|
-
hidden: i !== this._props.index
|
|
107
|
+
hidden: i !== this._props.index,
|
|
98
108
|
},
|
|
99
109
|
layout: $layout.fill,
|
|
100
|
-
views: [n.controller.rootView.definition]
|
|
110
|
+
views: [n.controller.rootView.definition],
|
|
101
111
|
});
|
|
102
112
|
});
|
|
103
113
|
this.cviews.pageContentView = new ContentView({
|
|
104
114
|
props: {
|
|
105
|
-
bgcolor: $color("clear")
|
|
115
|
+
bgcolor: $color("clear"),
|
|
106
116
|
},
|
|
107
117
|
layout: $layout.fill,
|
|
108
|
-
views: this.pages.map(n => n.definition)
|
|
118
|
+
views: this.pages.map((n) => n.definition),
|
|
109
119
|
});
|
|
110
|
-
this.rootView.views = [this.cviews.pageContentView, this.cviews.tabbar]
|
|
120
|
+
this.rootView.views = [this.cviews.pageContentView, this.cviews.tabbar];
|
|
111
121
|
}
|
|
112
122
|
|
|
113
123
|
set index(num) {
|
|
@@ -15,7 +15,7 @@ const l10n_1 = require("../../utils/l10n");
|
|
|
15
15
|
* @param cancelText 取消按钮文字
|
|
16
16
|
* @param confirmText 确认按钮文字
|
|
17
17
|
*/
|
|
18
|
-
function inputAlert({ title = "", message = "", text = "", placeholder, type = 0, secure = false, cancelText = (0, l10n_1.l10n)("CANCEL"), confirmText = (0, l10n_1.l10n)("OK") }) {
|
|
18
|
+
function inputAlert({ title = "", message = "", text = "", placeholder, type = 0, secure = false, cancelText = (0, l10n_1.l10n)("CANCEL"), confirmText = (0, l10n_1.l10n)("OK"), }) {
|
|
19
19
|
return new Promise((resolve, reject) => {
|
|
20
20
|
const alertVC = new uialert_1.UIAlertController(title, message, uialert_1.UIAlertControllerStyle.Alert);
|
|
21
21
|
alertVC.addTextField({
|
|
@@ -28,8 +28,8 @@ function inputAlert({ title = "", message = "", text = "", placeholder, type = 0
|
|
|
28
28
|
const input = alertVC.getText(0);
|
|
29
29
|
const isValid = input.length > 0;
|
|
30
30
|
return isValid;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
33
|
});
|
|
34
34
|
alertVC.addAction(new uialert_1.UIAlertAction(cancelText, uialert_1.UIAlertActionStyle.Destructive, cancelEvent));
|
|
35
35
|
alertVC.addAction(new uialert_1.UIAlertAction(confirmText, uialert_1.UIAlertActionStyle.Default, confirmEvent));
|
|
@@ -13,11 +13,11 @@ const l10n_1 = require("../../utils/l10n");
|
|
|
13
13
|
* @param cancelText 取消按钮文字
|
|
14
14
|
* @param confirmText 确认按钮文字
|
|
15
15
|
*/
|
|
16
|
-
function loginAlert({ title = "", message = "", placeholder1 = "", placeholder2 = "", cancelText = (0, l10n_1.l10n)("CANCEL"), confirmText = (0, l10n_1.l10n)("OK") } = {}) {
|
|
16
|
+
function loginAlert({ title = "", message = "", placeholder1 = "", placeholder2 = "", cancelText = (0, l10n_1.l10n)("CANCEL"), confirmText = (0, l10n_1.l10n)("OK"), } = {}) {
|
|
17
17
|
return new Promise((resolve, reject) => {
|
|
18
18
|
const alertVC = new uialert_1.UIAlertController(title, message, uialert_1.UIAlertControllerStyle.Alert);
|
|
19
19
|
alertVC.addTextField({
|
|
20
|
-
placeholder: placeholder1
|
|
20
|
+
placeholder: placeholder1,
|
|
21
21
|
});
|
|
22
22
|
alertVC.addTextField({
|
|
23
23
|
placeholder: placeholder2,
|
|
@@ -28,8 +28,8 @@ function loginAlert({ title = "", message = "", placeholder1 = "", placeholder2
|
|
|
28
28
|
const password = alertVC.getText(1);
|
|
29
29
|
const isValid = username.length > 0 && password.length > 0;
|
|
30
30
|
return isValid;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
33
|
});
|
|
34
34
|
alertVC.addAction(new uialert_1.UIAlertAction(cancelText, uialert_1.UIAlertActionStyle.Destructive, cancelEvent));
|
|
35
35
|
alertVC.addAction(new uialert_1.UIAlertAction(confirmText, uialert_1.UIAlertActionStyle.Default, confirmEvent));
|
|
@@ -39,7 +39,7 @@ function loginAlert({ title = "", message = "", placeholder1 = "", placeholder2
|
|
|
39
39
|
const password = alertVC.getText(1);
|
|
40
40
|
resolve({
|
|
41
41
|
username,
|
|
42
|
-
password
|
|
42
|
+
password,
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
function cancelEvent() {
|
|
@@ -12,7 +12,7 @@ const l10n_1 = require("../../utils/l10n");
|
|
|
12
12
|
* @param confirmText 确认按钮文字
|
|
13
13
|
* @returns Promise
|
|
14
14
|
*/
|
|
15
|
-
function plainAlert({ title = "", message = "", cancelText = (0, l10n_1.l10n)("CANCEL"), confirmText = (0, l10n_1.l10n)("OK") } = {}) {
|
|
15
|
+
function plainAlert({ title = "", message = "", cancelText = (0, l10n_1.l10n)("CANCEL"), confirmText = (0, l10n_1.l10n)("OK"), } = {}) {
|
|
16
16
|
return new Promise((resolve, reject) => {
|
|
17
17
|
const alertVC = new uialert_1.UIAlertController(title, message, uialert_1.UIAlertControllerStyle.Alert);
|
|
18
18
|
alertVC.addAction(new uialert_1.UIAlertAction(cancelText, uialert_1.UIAlertActionStyle.Destructive, cancelEvent));
|