jsbox-cview 1.6.5 → 1.6.7
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/README.md +4 -0
- package/dist/components/alert/input-alert.d.ts +22 -0
- package/dist/components/alert/input-alert.js +1 -2
- package/dist/components/alert/login-alert.d.ts +21 -0
- package/dist/components/alert/login-alert.js +1 -2
- package/dist/components/alert/plain-alert.d.ts +15 -0
- package/dist/components/alert/plain-alert.js +1 -2
- package/dist/components/alert/uialert.d.ts +29 -0
- package/{components/base.ts → dist/components/base.d.ts} +9 -28
- package/dist/components/custom-navigation-bar.d.ts +117 -0
- package/dist/components/custom-navigation-bar.js +7 -1
- package/dist/components/dialogs/dialog-sheet.d.ts +46 -0
- package/dist/components/dialogs/dialog-sheet.js +3 -1
- package/dist/components/dialogs/form-dialog.d.ts +15 -0
- package/dist/components/dialogs/form-dialog.js +1 -2
- package/dist/components/dialogs/list-dialog.d.ts +23 -0
- package/dist/components/dialogs/list-dialog.js +2 -3
- package/dist/components/dialogs/text-dialog.d.ts +13 -0
- package/dist/components/dialogs/text-dialog.js +1 -2
- package/dist/components/dynamic-contextmenu-view.d.ts +40 -0
- package/dist/components/dynamic-contextmenu-view.js +5 -1
- package/dist/components/dynamic-itemsize-matrix.d.ts +79 -0
- package/dist/components/dynamic-itemsize-matrix.js +18 -15
- package/dist/components/dynamic-itemsize-section-matrix.d.ts +115 -0
- package/dist/components/dynamic-itemsize-section-matrix.js +293 -0
- package/dist/components/dynamic-preference-listview.d.ts +63 -0
- package/dist/components/dynamic-preference-listview.js +25 -16
- package/dist/components/dynamic-rowheight-list.d.ts +38 -0
- package/dist/components/dynamic-rowheight-list.js +10 -3
- package/dist/components/enhanced-imageview.d.ts +41 -0
- package/dist/components/enhanced-imageview.js +1 -1
- package/dist/components/flowlayout.d.ts +63 -0
- package/dist/components/flowlayout.js +10 -13
- package/dist/components/image-pager.d.ts +49 -0
- package/dist/components/image-pager.js +6 -1
- package/dist/components/oc-webview.d.ts +64 -0
- package/dist/components/oc-webview.js +13 -5
- package/dist/components/page-control.d.ts +45 -0
- package/dist/components/page-control.js +2 -13
- package/dist/components/pageviewer-titlebar.d.ts +48 -0
- package/dist/components/pageviewer-titlebar.js +7 -13
- package/dist/components/pageviewer.d.ts +41 -0
- package/dist/components/pageviewer.js +4 -1
- package/dist/components/refresh-button.d.ts +25 -0
- package/dist/components/refresh-button.js +3 -4
- package/dist/components/rotating-view.d.ts +45 -0
- package/dist/components/rotating-view.js +10 -2
- package/dist/components/searchbar.d.ts +118 -0
- package/dist/components/searchbar.js +8 -1
- package/dist/components/sheet.d.ts +42 -0
- package/dist/components/single-views.d.ts +289 -0
- package/dist/components/single-views.js +11 -4
- package/dist/components/spinners/loading-dual-ring.d.ts +18 -0
- package/dist/components/spinners/loading-wedges.d.ts +15 -0
- package/dist/components/spinners/spinner-androidstyle.d.ts +30 -0
- package/dist/components/spinners/spinner-androidstyle.js +7 -1
- package/dist/components/static-preference-listview.d.ts +389 -0
- package/dist/components/static-preference-listview.js +13 -10
- package/dist/components/symbol-button.d.ts +39 -0
- package/dist/components/symbol-button.js +8 -1
- package/dist/components/tabbar.d.ts +140 -0
- package/dist/components/tabbar.js +8 -1
- package/dist/controller/base-controller.d.ts +125 -0
- package/dist/controller/base-controller.js +11 -11
- package/dist/controller/controller-router.d.ts +48 -0
- package/dist/controller/pageviewer-controller.d.ts +38 -0
- package/dist/controller/pageviewer-controller.js +4 -1
- package/dist/controller/presented-page-controller.d.ts +41 -0
- package/dist/controller/presented-page-controller.js +7 -9
- package/dist/controller/splitview-controller.d.ts +90 -0
- package/dist/controller/splitview-controller.js +27 -11
- package/dist/controller/tabbar-controller.d.ts +49 -0
- package/dist/controller/tabbar-controller.js +12 -15
- package/{index.ts → dist/index.d.ts} +2 -0
- package/dist/index.js +2 -0
- package/dist/utils/colors.d.ts +7 -0
- package/dist/utils/cvid.d.ts +11 -0
- package/dist/utils/l10n.d.ts +1 -0
- package/dist/utils/l10n.js +1 -2
- package/dist/utils/path.d.ts +8 -0
- package/dist/utils/path.js +8 -9
- package/dist/utils/rect.d.ts +38 -0
- package/dist/utils/rect.js +8 -9
- package/dist/utils/uitools.d.ts +75 -0
- package/dist/utils/uitools.js +6 -6
- package/package.json +20 -5
- package/.prettierignore +0 -6
- package/.prettierrc +0 -3
- package/components/alert/input-alert.ts +0 -64
- package/components/alert/login-alert.ts +0 -66
- package/components/alert/plain-alert.ts +0 -39
- package/components/alert/uialert.ts +0 -107
- package/components/custom-navigation-bar.ts +0 -579
- package/components/dialogs/dialog-sheet.ts +0 -111
- package/components/dialogs/form-dialog.ts +0 -63
- package/components/dialogs/list-dialog.ts +0 -119
- package/components/dialogs/text-dialog.ts +0 -44
- package/components/dynamic-contextmenu-view.ts +0 -115
- package/components/dynamic-itemsize-matrix.ts +0 -206
- package/components/dynamic-preference-listview.ts +0 -684
- package/components/dynamic-rowheight-list.ts +0 -77
- package/components/enhanced-imageview.ts +0 -132
- package/components/flowlayout.ts +0 -248
- package/components/image-pager.ts +0 -180
- package/components/oc-webview.ts +0 -177
- package/components/page-control.ts +0 -93
- package/components/pageviewer-titlebar.ts +0 -166
- package/components/pageviewer.ts +0 -125
- package/components/refresh-button.ts +0 -83
- package/components/rotating-view.ts +0 -133
- package/components/searchbar.ts +0 -398
- package/components/sheet.ts +0 -104
- package/components/single-views.ts +0 -956
- package/components/spinners/loading-dual-ring.ts +0 -97
- package/components/spinners/loading-wedges.ts +0 -106
- package/components/spinners/spinner-androidstyle.ts +0 -269
- package/components/static-preference-listview.ts +0 -1282
- package/components/symbol-button.ts +0 -108
- package/components/tabbar.ts +0 -453
- package/controller/base-controller.ts +0 -214
- package/controller/controller-router.ts +0 -73
- package/controller/pageviewer-controller.ts +0 -93
- package/controller/presented-page-controller.ts +0 -76
- package/controller/splitview-controller.ts +0 -359
- package/controller/tabbar-controller.ts +0 -131
- package/dist/test/custom-navigation-bar.js +0 -40
- package/dist/test/dialog-sheet.js +0 -40
- package/dist/test/dynamic-contextmenu-view.js +0 -66
- package/dist/test/dynamic-itemsize-matrix.js +0 -74
- package/dist/test/dynamic-preference-listview.js +0 -150
- package/dist/test/flowlayout.js +0 -76
- package/dist/test/form-dialog.js +0 -51
- package/dist/test/oc-webview.js +0 -195
- package/dist/test/pageviewer-controller.js +0 -20
- package/dist/test/pageviewer-titlebar.js +0 -18
- package/dist/test/pageviewer.js +0 -32
- package/dist/test/refresh-button.js +0 -26
- package/dist/test/searchbar.js +0 -36
- package/dist/test/splitview-controller.js +0 -41
- package/dist/test/static-preference-listview.js +0 -143
- package/dist/test/tabbar-controller.js +0 -48
- package/test/custom-navigation-bar.ts +0 -40
- package/test/dialog-sheet.ts +0 -40
- package/test/dynamic-contextmenu-view.ts +0 -67
- package/test/dynamic-itemsize-matrix.ts +0 -74
- package/test/dynamic-preference-listview.ts +0 -151
- package/test/flowlayout.ts +0 -79
- package/test/form-dialog.ts +0 -48
- package/test/oc-webview.ts +0 -197
- package/test/pageviewer-controller.ts +0 -21
- package/test/pageviewer-titlebar.ts +0 -18
- package/test/pageviewer.ts +0 -31
- package/test/refresh-button.ts +0 -26
- package/test/searchbar.ts +0 -38
- package/test/splitview-controller.ts +0 -42
- package/test/static-preference-listview.ts +0 -142
- package/test/tabbar-controller.ts +0 -49
- package/tsconfig.json +0 -122
- package/utils/colors.ts +0 -17
- package/utils/cvid.ts +0 -32
- package/utils/l10n.ts +0 -42
- package/utils/path.ts +0 -97
- package/utils/rect.ts +0 -90
- package/utils/uitools.ts +0 -122
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
export const UIAlertActionStyle = {
|
|
2
|
-
Default: 0,
|
|
3
|
-
Cancel: 1,
|
|
4
|
-
Destructive: 2,
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const UIAlertControllerStyle = {
|
|
8
|
-
ActionSheet: 0,
|
|
9
|
-
Alert: 1,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export class UIAlertAction {
|
|
13
|
-
title: string;
|
|
14
|
-
style: number;
|
|
15
|
-
instance: any;
|
|
16
|
-
|
|
17
|
-
constructor(title: string, style = UIAlertActionStyle.Default, handler: Function) {
|
|
18
|
-
this.title = title;
|
|
19
|
-
this.style = style;
|
|
20
|
-
this.instance = $objc("UIAlertAction").$actionWithTitle_style_handler(
|
|
21
|
-
title,
|
|
22
|
-
style,
|
|
23
|
-
$block("void, UIAlertAction *", () => {
|
|
24
|
-
if (handler) {
|
|
25
|
-
handler(this);
|
|
26
|
-
}
|
|
27
|
-
}),
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Alert的基础类
|
|
34
|
-
*/
|
|
35
|
-
export class UIAlertController {
|
|
36
|
-
title: string;
|
|
37
|
-
message: string;
|
|
38
|
-
style: number;
|
|
39
|
-
instance: any;
|
|
40
|
-
constructor(title: string, message: string, style = UIAlertControllerStyle.ActionSheet) {
|
|
41
|
-
this.title = title;
|
|
42
|
-
this.message = message;
|
|
43
|
-
this.style = style;
|
|
44
|
-
this.instance = $objc("UIAlertController").$alertControllerWithTitle_message_preferredStyle(title, message, style);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
addAction(action: UIAlertAction) {
|
|
48
|
-
this.instance.$addAction(action.instance);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
addTextField(options: any) {
|
|
52
|
-
this.instance.$addTextFieldWithConfigurationHandler(
|
|
53
|
-
$block("void, UITextField *", (textField: any) => {
|
|
54
|
-
textField.$setClearButtonMode(1);
|
|
55
|
-
|
|
56
|
-
if (options.type) {
|
|
57
|
-
textField.$setKeyboardType(options.type);
|
|
58
|
-
}
|
|
59
|
-
if (options.placeholder) {
|
|
60
|
-
textField.$setPlaceholder(options.placeholder);
|
|
61
|
-
}
|
|
62
|
-
if (options.text) {
|
|
63
|
-
textField.$setText(options.text);
|
|
64
|
-
}
|
|
65
|
-
if (options.textColor) {
|
|
66
|
-
textField.$setTextColor(options.textColor.ocValue());
|
|
67
|
-
}
|
|
68
|
-
if (options.font) {
|
|
69
|
-
textField.$setFont(options.font.ocValue());
|
|
70
|
-
}
|
|
71
|
-
if (options.align) {
|
|
72
|
-
textField.$setTextAlignment(options.align);
|
|
73
|
-
}
|
|
74
|
-
if (options.secure) {
|
|
75
|
-
textField.$setSecureTextEntry(true);
|
|
76
|
-
}
|
|
77
|
-
if (options.events) {
|
|
78
|
-
const events = options.events;
|
|
79
|
-
textField.$setDelegate(
|
|
80
|
-
$delegate({
|
|
81
|
-
type: "UITextFieldDelegate",
|
|
82
|
-
events: {
|
|
83
|
-
"textFieldShouldReturn:": (textField: any) => {
|
|
84
|
-
if (events.shouldReturn) {
|
|
85
|
-
return events.shouldReturn();
|
|
86
|
-
} else {
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
}),
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
}),
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
getText(index: number) {
|
|
99
|
-
const textField = this.instance.$textFields().$objectAtIndex(index);
|
|
100
|
-
const text = textField.$text();
|
|
101
|
-
return text.jsValue();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
present() {
|
|
105
|
-
this.instance.$show();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,579 +0,0 @@
|
|
|
1
|
-
import { Base } from "./base";
|
|
2
|
-
import { ContentView, Label, Button, Blur } from "./single-views";
|
|
3
|
-
import { SymbolButton } from "./symbol-button";
|
|
4
|
-
import { getTextWidth } from "../utils/uitools";
|
|
5
|
-
|
|
6
|
-
const navBarStyles = {
|
|
7
|
-
hidden: 0,
|
|
8
|
-
minimized: 1,
|
|
9
|
-
normal: 2,
|
|
10
|
-
expanded: 3,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const navBarLayouts = [
|
|
14
|
-
(make: MASConstraintMaker, view: AllUIView) => {
|
|
15
|
-
make.left.right.top.inset(0);
|
|
16
|
-
make.height.equalTo(0);
|
|
17
|
-
},
|
|
18
|
-
(make: MASConstraintMaker, view: AllUIView) => {
|
|
19
|
-
make.left.right.top.inset(0);
|
|
20
|
-
make.bottom.equalTo(view.super.safeAreaTop).inset(-25);
|
|
21
|
-
},
|
|
22
|
-
(make: MASConstraintMaker, view: AllUIView) => {
|
|
23
|
-
make.left.right.top.inset(0);
|
|
24
|
-
make.bottom.equalTo(view.super.safeAreaTop).inset(-50);
|
|
25
|
-
},
|
|
26
|
-
(make: MASConstraintMaker, view: AllUIView) => {
|
|
27
|
-
make.left.right.top.inset(0);
|
|
28
|
-
make.bottom.equalTo(view.super.safeAreaTop).inset(-100);
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
export interface NavigationBarProps {
|
|
33
|
-
style: number;
|
|
34
|
-
title?: string;
|
|
35
|
-
titleView?: Base<any, any>;
|
|
36
|
-
popButtonEnabled?: boolean;
|
|
37
|
-
popButtonTitle?: string;
|
|
38
|
-
popToRootEnabled?: boolean;
|
|
39
|
-
leftBarButtonItems: BarButtonItem[];
|
|
40
|
-
rightBarButtonItems: BarButtonItem[];
|
|
41
|
-
toolView?: Base<any, any>;
|
|
42
|
-
tintColor: UIColor;
|
|
43
|
-
bgcolor?: UIColor;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface BarButtonItem {
|
|
47
|
-
cview?: Base<any, any>;
|
|
48
|
-
width?: number;
|
|
49
|
-
title?: string;
|
|
50
|
-
symbol?: string;
|
|
51
|
-
image?: UIImage;
|
|
52
|
-
tintColor?: UIColor;
|
|
53
|
-
handler?: (sender: UIButtonView) => void;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
interface NavigationBarEvents {
|
|
57
|
-
hidden?: (cview: CustomNavigationBar) => void;
|
|
58
|
-
minimized?: (cview: CustomNavigationBar) => void;
|
|
59
|
-
restored?: (cview: CustomNavigationBar) => void;
|
|
60
|
-
expanded?: (cview: CustomNavigationBar) => void;
|
|
61
|
-
popHandler?: (cview: CustomNavigationBar) => void;
|
|
62
|
-
popToRootHandler?: (cview: CustomNavigationBar) => void;
|
|
63
|
-
titleTapped?: (cview: CustomNavigationBar) => void;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface NavigationBarCViews {
|
|
67
|
-
leftItemView?: ContentView | Button;
|
|
68
|
-
rightItemView?: ContentView;
|
|
69
|
-
titleViewWrapper?: ContentView | Label;
|
|
70
|
-
contentView?: ContentView;
|
|
71
|
-
toolViewWrapper?: ContentView;
|
|
72
|
-
bgview?: ContentView | Blur;
|
|
73
|
-
separator?: ContentView;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* # CView Custom NavigationBar
|
|
78
|
-
*
|
|
79
|
-
* 仿制 navBar
|
|
80
|
-
*
|
|
81
|
-
* ## features:
|
|
82
|
-
*
|
|
83
|
-
* - 拥有隐藏、最小化、普通、扩展四种布局方式
|
|
84
|
-
* - 隐藏: 什么都不显示
|
|
85
|
-
* - 最小化: safeAreaHeight 为 25, 只显示 titleView, 若用 title, font 为\$font(14)
|
|
86
|
-
* - 普通: safeAreaHeight 为 50, 显示 titleView, leftBarButtonItems 或 popButton,
|
|
87
|
-
* rightBarButtonItems, 若用 title, font 为\$font("bold", 17)
|
|
88
|
-
* - 扩展: safeAreaHeight 为 100, 除上面的之外, 再显示一个 toolView
|
|
89
|
-
* - 自动适应全面屏和非全面屏
|
|
90
|
-
*
|
|
91
|
-
* ## Arguments
|
|
92
|
-
*
|
|
93
|
-
* props:
|
|
94
|
-
*
|
|
95
|
-
* - 读写 style: number 0, 1, 2, 3,指定布局
|
|
96
|
-
* - 读写 title: string 但必须使用此种方案才可以在生成后写入,自动创建 Label 作为 titleView
|
|
97
|
-
* - titleView: cview 自定义的 titleView
|
|
98
|
-
* - popButtonEnabled: boolean 返回上一级的按钮,若为 true,则 leftBarButtonItems 忽略
|
|
99
|
-
* - popButtonTitle: string 返回上一级的按钮标题
|
|
100
|
-
* - popToRootEnabled: boolean popButton 是否可以长按返回到顶级
|
|
101
|
-
* - leftBarButtonItems: cview[]
|
|
102
|
-
* | {symbol: string, handler: () => void, tintColor?: UIColor}[]
|
|
103
|
-
* | {title: string, handler: () => void, tintColor?: UIColor}[]
|
|
104
|
-
* | {image: UIImage, handler: () => void, tintColor?: UIColor}[]
|
|
105
|
-
* 如果用的是 cview,其布局将被重新指定,即不需要(也不能)指定布局。
|
|
106
|
-
* 可以通过 cview.width 来指定应有的宽度,如果没有此属性,则宽度为 50
|
|
107
|
-
* 建议最多放两个
|
|
108
|
-
* - rightBarButtonItems 定义同上,建议最多放两个
|
|
109
|
-
* - toolView: cview 在 expanded 模式下才会显现的
|
|
110
|
-
* - tintColor: UIColor 这将作用于 title, popButton, 自动创建的 barButton
|
|
111
|
-
* - bgcolor: UIColor 如不设置,则自动使用 blur(style 10),如果设置则没有 blur 效果
|
|
112
|
-
*
|
|
113
|
-
* events:
|
|
114
|
-
*
|
|
115
|
-
* - hidden: cview => void hide()时执行
|
|
116
|
-
* - minimized: cview => void minimize()时执行
|
|
117
|
-
* - restored: cview => void restore()时执行
|
|
118
|
-
* - expanded: cview => void expand()时执行
|
|
119
|
-
* - popHandler: cview => void 返回上一级时执行,需要popButtonEnabled
|
|
120
|
-
* - popToRootHandler: cview => void 返回顶级时执行,需要popButtonEnabled和popToRootEnabled
|
|
121
|
-
* - titleTapped: cview => void 点击标题时执行,需要使用title
|
|
122
|
-
*
|
|
123
|
-
* methods:
|
|
124
|
-
*
|
|
125
|
-
* - hide() 隐藏布局
|
|
126
|
-
* - minimize() 最小化布局
|
|
127
|
-
* - restore() 普通布局
|
|
128
|
-
* - expand() 扩展布局
|
|
129
|
-
*/
|
|
130
|
-
export class CustomNavigationBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTypes.BlurOptions> {
|
|
131
|
-
_props: NavigationBarProps;
|
|
132
|
-
_events: NavigationBarEvents;
|
|
133
|
-
cviews: Required<NavigationBarCViews>;
|
|
134
|
-
_defineView: () => UiTypes.ViewOptions | UiTypes.BlurOptions;
|
|
135
|
-
constructor({
|
|
136
|
-
props = {},
|
|
137
|
-
events = {},
|
|
138
|
-
}: {
|
|
139
|
-
props?: Partial<NavigationBarProps>;
|
|
140
|
-
events?: NavigationBarEvents;
|
|
141
|
-
} = {}) {
|
|
142
|
-
super();
|
|
143
|
-
this._props = {
|
|
144
|
-
leftBarButtonItems: [],
|
|
145
|
-
rightBarButtonItems: [],
|
|
146
|
-
style: navBarStyles.normal,
|
|
147
|
-
tintColor: $color("primaryText"),
|
|
148
|
-
...props,
|
|
149
|
-
};
|
|
150
|
-
this._events = events;
|
|
151
|
-
this.cviews = {} as Required<NavigationBarCViews>;
|
|
152
|
-
this._defineView = () => {
|
|
153
|
-
/*
|
|
154
|
-
设计思路
|
|
155
|
-
一共5个子视图:
|
|
156
|
-
- contentView 下有3个子视图
|
|
157
|
-
- leftItemView popButton或者leftButtonItems
|
|
158
|
-
- rightItemView rightButtonItems
|
|
159
|
-
- titleView
|
|
160
|
-
- toolView
|
|
161
|
-
*/
|
|
162
|
-
// leftItemView
|
|
163
|
-
let leftInset = 0;
|
|
164
|
-
if (this._props.popButtonEnabled) {
|
|
165
|
-
const titleWidth = this._props.popButtonTitle ? getTextWidth(this._props.popButtonTitle) : 0;
|
|
166
|
-
leftInset = titleWidth + 35;
|
|
167
|
-
const views = [];
|
|
168
|
-
const chevronOptions: UiTypes.ViewOptions = {
|
|
169
|
-
type: "view",
|
|
170
|
-
props: {
|
|
171
|
-
userInteractionEnabled: false,
|
|
172
|
-
},
|
|
173
|
-
layout: (make: MASConstraintMaker) => {
|
|
174
|
-
make.left.top.bottom.inset(0);
|
|
175
|
-
make.width.equalTo(35);
|
|
176
|
-
},
|
|
177
|
-
views: [
|
|
178
|
-
{
|
|
179
|
-
type: "image",
|
|
180
|
-
props: {
|
|
181
|
-
symbol: "chevron.left",
|
|
182
|
-
contentMode: 1,
|
|
183
|
-
tintColor: this._props.tintColor,
|
|
184
|
-
},
|
|
185
|
-
layout: (make: MASConstraintMaker) => make.edges.insets($insets(12.5, 10, 12.5, 0)),
|
|
186
|
-
},
|
|
187
|
-
],
|
|
188
|
-
};
|
|
189
|
-
views.push(chevronOptions);
|
|
190
|
-
if (this._props.popButtonTitle) {
|
|
191
|
-
const popButtonTitleOptions: UiTypes.LabelOptions = {
|
|
192
|
-
type: "label",
|
|
193
|
-
props: {
|
|
194
|
-
align: $align.left,
|
|
195
|
-
text: this._props.popButtonTitle,
|
|
196
|
-
font: $font(17),
|
|
197
|
-
textColor: this._props.tintColor,
|
|
198
|
-
},
|
|
199
|
-
layout: (make: MASConstraintMaker, view: UILabelView) => {
|
|
200
|
-
make.top.bottom.right.inset(0);
|
|
201
|
-
make.left.equalTo(view.prev.right);
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
views.push(popButtonTitleOptions);
|
|
205
|
-
}
|
|
206
|
-
this.cviews.leftItemView = new Button({
|
|
207
|
-
props: {
|
|
208
|
-
bgcolor: $color("clear"),
|
|
209
|
-
cornerRadius: 0,
|
|
210
|
-
},
|
|
211
|
-
views,
|
|
212
|
-
layout: (make, view) => {
|
|
213
|
-
make.width.equalTo(leftInset);
|
|
214
|
-
make.left.top.bottom.inset(0);
|
|
215
|
-
},
|
|
216
|
-
events: {
|
|
217
|
-
tapped: (sender) => {
|
|
218
|
-
if (this._events.popHandler) this._events.popHandler(this);
|
|
219
|
-
$ui.pop();
|
|
220
|
-
},
|
|
221
|
-
longPressed: this._props.popToRootEnabled
|
|
222
|
-
? (sender) => {
|
|
223
|
-
if (this._events.popToRootHandler) this._events.popToRootHandler(this);
|
|
224
|
-
$ui.popToRoot();
|
|
225
|
-
}
|
|
226
|
-
: undefined,
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
} else {
|
|
230
|
-
leftInset = this._calculateItemViewWidth(this._props.leftBarButtonItems);
|
|
231
|
-
this.cviews.leftItemView = new ContentView({
|
|
232
|
-
props: {
|
|
233
|
-
bgcolor: undefined,
|
|
234
|
-
},
|
|
235
|
-
layout: (make, view) => {
|
|
236
|
-
make.width.equalTo(leftInset);
|
|
237
|
-
make.left.top.bottom.inset(0);
|
|
238
|
-
},
|
|
239
|
-
views: this._createCviewsOnItemView(this._props.leftBarButtonItems).map((n) => n.definition),
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// rightItemView
|
|
244
|
-
const rightInset = this._calculateItemViewWidth(this._props.rightBarButtonItems);
|
|
245
|
-
this.cviews.rightItemView = new ContentView({
|
|
246
|
-
props: {
|
|
247
|
-
bgcolor: undefined,
|
|
248
|
-
},
|
|
249
|
-
layout: (make, view) => {
|
|
250
|
-
make.width.equalTo(rightInset);
|
|
251
|
-
make.right.top.bottom.inset(0);
|
|
252
|
-
},
|
|
253
|
-
views: this._createCviewsOnItemView(this._props.rightBarButtonItems).map((n) => n.definition),
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
// titleView
|
|
257
|
-
const titleViewInset = Math.max(leftInset, rightInset);
|
|
258
|
-
if (this._props.title) {
|
|
259
|
-
this.cviews.titleViewWrapper = new Label({
|
|
260
|
-
props: {
|
|
261
|
-
text: this._props.title,
|
|
262
|
-
font: $font("bold", 17),
|
|
263
|
-
align: $align.center,
|
|
264
|
-
textColor: this._props.tintColor,
|
|
265
|
-
userInteractionEnabled: true,
|
|
266
|
-
},
|
|
267
|
-
layout: (make, view) => {
|
|
268
|
-
make.left.right.inset(titleViewInset);
|
|
269
|
-
make.top.bottom.inset(0);
|
|
270
|
-
},
|
|
271
|
-
events: {
|
|
272
|
-
tapped: (sender) => {
|
|
273
|
-
if (this._events.titleTapped) this._events.titleTapped(this);
|
|
274
|
-
},
|
|
275
|
-
},
|
|
276
|
-
});
|
|
277
|
-
} else {
|
|
278
|
-
this.cviews.titleViewWrapper = new ContentView({
|
|
279
|
-
props: {
|
|
280
|
-
bgcolor: undefined,
|
|
281
|
-
},
|
|
282
|
-
layout: (make, view) => {
|
|
283
|
-
make.left.right.inset(titleViewInset);
|
|
284
|
-
make.top.bottom.inset(0);
|
|
285
|
-
},
|
|
286
|
-
views: this._props.titleView && [this._props.titleView.definition],
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// contentView
|
|
291
|
-
this.cviews.contentView = new ContentView({
|
|
292
|
-
props: {
|
|
293
|
-
bgcolor: undefined,
|
|
294
|
-
},
|
|
295
|
-
layout: (make, view) => {
|
|
296
|
-
make.top.inset(0);
|
|
297
|
-
make.left.right.inset(5);
|
|
298
|
-
make.height.equalTo(50);
|
|
299
|
-
},
|
|
300
|
-
views: [
|
|
301
|
-
this.cviews.titleViewWrapper.definition,
|
|
302
|
-
this.cviews.leftItemView.definition,
|
|
303
|
-
this.cviews.rightItemView.definition,
|
|
304
|
-
],
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
// toolView
|
|
308
|
-
this.cviews.toolViewWrapper = new ContentView({
|
|
309
|
-
props: {
|
|
310
|
-
bgcolor: undefined,
|
|
311
|
-
},
|
|
312
|
-
layout: (make, view) => {
|
|
313
|
-
make.left.right.bottom.equalTo(view.super);
|
|
314
|
-
make.top.equalTo(view.super).inset(50);
|
|
315
|
-
},
|
|
316
|
-
views: this._props.toolView && [this._props.toolView.definition],
|
|
317
|
-
});
|
|
318
|
-
if (this._props.bgcolor) {
|
|
319
|
-
this.cviews.bgview = new ContentView({
|
|
320
|
-
props: {
|
|
321
|
-
bgcolor: this._props.bgcolor,
|
|
322
|
-
},
|
|
323
|
-
layout: $layout.fill,
|
|
324
|
-
});
|
|
325
|
-
} else {
|
|
326
|
-
this.cviews.bgview = new Blur({
|
|
327
|
-
props: {
|
|
328
|
-
style: 10,
|
|
329
|
-
},
|
|
330
|
-
layout: $layout.fill,
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
this.cviews.separator = new ContentView({
|
|
334
|
-
props: {
|
|
335
|
-
bgcolor: $color("separatorColor"),
|
|
336
|
-
},
|
|
337
|
-
layout: (make, view) => {
|
|
338
|
-
make.bottom.left.right.inset(0);
|
|
339
|
-
make.height.equalTo(0.5);
|
|
340
|
-
},
|
|
341
|
-
});
|
|
342
|
-
return {
|
|
343
|
-
type: "view",
|
|
344
|
-
props: {
|
|
345
|
-
id: this.id,
|
|
346
|
-
},
|
|
347
|
-
layout: navBarLayouts[this._props.style],
|
|
348
|
-
events: {
|
|
349
|
-
ready: () => (this.style = this.style),
|
|
350
|
-
},
|
|
351
|
-
views: [
|
|
352
|
-
this.cviews.bgview.definition,
|
|
353
|
-
{
|
|
354
|
-
type: "view",
|
|
355
|
-
props: {},
|
|
356
|
-
layout: $layout.fillSafeArea,
|
|
357
|
-
views: [this.cviews.contentView.definition, this.cviews.toolViewWrapper.definition],
|
|
358
|
-
},
|
|
359
|
-
this.cviews.separator.definition,
|
|
360
|
-
],
|
|
361
|
-
};
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
private _calculateItemViewWidth(items: BarButtonItem[]) {
|
|
366
|
-
if (!items || items.length === 0) return 0;
|
|
367
|
-
let width = 0;
|
|
368
|
-
items.forEach((n) => {
|
|
369
|
-
if (n.cview) width += n.width || 50;
|
|
370
|
-
else if (n.title) width += getTextWidth(n.title, { inset: 20 });
|
|
371
|
-
else width += 50;
|
|
372
|
-
});
|
|
373
|
-
return width;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
private _createCviewsOnItemView(items: BarButtonItem[]) {
|
|
377
|
-
return items.map((n) => {
|
|
378
|
-
if (n.cview) {
|
|
379
|
-
const width = n.width || 50;
|
|
380
|
-
n.cview._layout = (make: MASConstraintMaker, view: AllUIView) => {
|
|
381
|
-
make.top.bottom.inset(0);
|
|
382
|
-
make.width.equalTo(width);
|
|
383
|
-
make.left.equalTo((view.prev && view.prev.right) || 0);
|
|
384
|
-
};
|
|
385
|
-
return n.cview;
|
|
386
|
-
} else if (n.title) {
|
|
387
|
-
const width = getTextWidth(n.title, { inset: 20 });
|
|
388
|
-
return new Button({
|
|
389
|
-
props: {
|
|
390
|
-
title: n.title,
|
|
391
|
-
bgcolor: $color("clear"),
|
|
392
|
-
titleColor: n.tintColor || this._props.tintColor,
|
|
393
|
-
cornerRadius: 0,
|
|
394
|
-
},
|
|
395
|
-
layout: (make, view) => {
|
|
396
|
-
make.top.bottom.inset(0);
|
|
397
|
-
make.width.equalTo(width);
|
|
398
|
-
make.left.equalTo((view.prev && view.prev.right) || 0);
|
|
399
|
-
},
|
|
400
|
-
events: {
|
|
401
|
-
tapped: n.handler,
|
|
402
|
-
},
|
|
403
|
-
});
|
|
404
|
-
} else if (n.symbol || n.image) {
|
|
405
|
-
return new SymbolButton({
|
|
406
|
-
props: {
|
|
407
|
-
symbol: n.symbol,
|
|
408
|
-
image: n.image,
|
|
409
|
-
tintColor: n.tintColor || this._props.tintColor,
|
|
410
|
-
},
|
|
411
|
-
layout: (make, view) => {
|
|
412
|
-
make.top.bottom.inset(0);
|
|
413
|
-
make.width.equalTo(50);
|
|
414
|
-
make.left.equalTo((view.prev && view.prev.right) || 0);
|
|
415
|
-
},
|
|
416
|
-
events: {
|
|
417
|
-
tapped: n.handler,
|
|
418
|
-
},
|
|
419
|
-
});
|
|
420
|
-
} else {
|
|
421
|
-
throw Error("Invalid BarButtonItem");
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
get title() {
|
|
427
|
-
return this._props.title || "";
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
set title(title: string) {
|
|
431
|
-
if (this._props.title === undefined) return;
|
|
432
|
-
this._props.title = title;
|
|
433
|
-
if ("text" in this.cviews.titleViewWrapper.view) this.cviews.titleViewWrapper.view.text = title;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
hide(animated = true) {
|
|
437
|
-
this.view.hidden = false;
|
|
438
|
-
this.cviews.leftItemView.view.hidden = true;
|
|
439
|
-
this.cviews.rightItemView.view.hidden = true;
|
|
440
|
-
this.cviews.toolViewWrapper.view.hidden = true;
|
|
441
|
-
this.cviews.titleViewWrapper.view.hidden = true;
|
|
442
|
-
this.view.remakeLayout(navBarLayouts[navBarStyles.hidden]);
|
|
443
|
-
this.cviews.contentView.view.updateLayout((make) => make.height.equalTo(0));
|
|
444
|
-
if (animated) {
|
|
445
|
-
$ui.animate({
|
|
446
|
-
duration: 0.3,
|
|
447
|
-
animation: () => {
|
|
448
|
-
this.view.relayout();
|
|
449
|
-
this.cviews.contentView.view.relayout();
|
|
450
|
-
},
|
|
451
|
-
completion: () => {
|
|
452
|
-
this.view.hidden = true;
|
|
453
|
-
if (this._events.hidden) this._events.hidden(this);
|
|
454
|
-
},
|
|
455
|
-
});
|
|
456
|
-
} else {
|
|
457
|
-
this.view.hidden = true;
|
|
458
|
-
if (this._events.hidden) this._events.hidden(this);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
minimize(animated = true) {
|
|
463
|
-
this.view.hidden = false;
|
|
464
|
-
this.cviews.leftItemView.view.hidden = true;
|
|
465
|
-
this.cviews.rightItemView.view.hidden = true;
|
|
466
|
-
this.cviews.toolViewWrapper.view.hidden = true;
|
|
467
|
-
this.cviews.titleViewWrapper.view.hidden = false;
|
|
468
|
-
this.view.remakeLayout(navBarLayouts[navBarStyles.minimized]);
|
|
469
|
-
this.cviews.contentView.view.updateLayout((make) => make.height.equalTo(25));
|
|
470
|
-
if (animated) {
|
|
471
|
-
$ui.animate({
|
|
472
|
-
duration: 0.3,
|
|
473
|
-
animation: () => {
|
|
474
|
-
this.view.relayout();
|
|
475
|
-
this.cviews.contentView.view.relayout();
|
|
476
|
-
if (this._props.title && "font" in this.cviews.titleViewWrapper.view)
|
|
477
|
-
this.cviews.titleViewWrapper.view.font = $font("bold", 14);
|
|
478
|
-
},
|
|
479
|
-
completion: () => {
|
|
480
|
-
if (this._events.minimized) this._events.minimized(this);
|
|
481
|
-
},
|
|
482
|
-
});
|
|
483
|
-
} else {
|
|
484
|
-
if (this._props.title && "font" in this.cviews.titleViewWrapper.view)
|
|
485
|
-
this.cviews.titleViewWrapper.view.font = $font("bold", 14);
|
|
486
|
-
if (this._events.minimized) this._events.minimized(this);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
restore(animated = true) {
|
|
491
|
-
this.view.hidden = false;
|
|
492
|
-
this.cviews.titleViewWrapper.view.hidden = false;
|
|
493
|
-
//this.cviews.toolViewWrapper.view.hidden = true;
|
|
494
|
-
this.view.remakeLayout(navBarLayouts[navBarStyles.normal]);
|
|
495
|
-
this.cviews.contentView.view.updateLayout((make) => make.height.equalTo(50));
|
|
496
|
-
if (animated) {
|
|
497
|
-
$ui.animate({
|
|
498
|
-
duration: 0.3,
|
|
499
|
-
animation: () => {
|
|
500
|
-
this.view.relayout();
|
|
501
|
-
this.cviews.contentView.view.relayout();
|
|
502
|
-
if (this._props.title && "font" in this.cviews.titleViewWrapper.view)
|
|
503
|
-
this.cviews.titleViewWrapper.view.font = $font("bold", 17);
|
|
504
|
-
},
|
|
505
|
-
completion: () => {
|
|
506
|
-
this.cviews.leftItemView.view.hidden = false;
|
|
507
|
-
this.cviews.rightItemView.view.hidden = false;
|
|
508
|
-
if (this._events.restored) this._events.restored(this);
|
|
509
|
-
},
|
|
510
|
-
});
|
|
511
|
-
} else {
|
|
512
|
-
this.cviews.leftItemView.view.hidden = false;
|
|
513
|
-
this.cviews.rightItemView.view.hidden = false;
|
|
514
|
-
if (this._props.title && "font" in this.cviews.titleViewWrapper.view)
|
|
515
|
-
this.cviews.titleViewWrapper.view.font = $font("bold", 17);
|
|
516
|
-
if (this._events.restored) this._events.restored(this);
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
expand(animated = true) {
|
|
521
|
-
this.view.hidden = false;
|
|
522
|
-
this.cviews.toolViewWrapper.view.hidden = false;
|
|
523
|
-
this.cviews.titleViewWrapper.view.hidden = false;
|
|
524
|
-
this.view.remakeLayout(navBarLayouts[navBarStyles.expanded]);
|
|
525
|
-
this.cviews.contentView.view.updateLayout((make) => make.height.equalTo(50));
|
|
526
|
-
if (animated) {
|
|
527
|
-
$ui.animate({
|
|
528
|
-
duration: 0.3,
|
|
529
|
-
animation: () => {
|
|
530
|
-
this.view.relayout();
|
|
531
|
-
this.cviews.contentView.view.relayout();
|
|
532
|
-
if (this._props.title && "font" in this.cviews.titleViewWrapper.view)
|
|
533
|
-
this.cviews.titleViewWrapper.view.font = $font("bold", 17);
|
|
534
|
-
},
|
|
535
|
-
completion: () => {
|
|
536
|
-
this.cviews.leftItemView.view.hidden = false;
|
|
537
|
-
this.cviews.rightItemView.view.hidden = false;
|
|
538
|
-
//this.cviews.toolViewWrapper.view.hidden = false;
|
|
539
|
-
if (this._events.expanded) this._events.expanded(this);
|
|
540
|
-
},
|
|
541
|
-
});
|
|
542
|
-
} else {
|
|
543
|
-
this.cviews.leftItemView.view.hidden = false;
|
|
544
|
-
this.cviews.rightItemView.view.hidden = false;
|
|
545
|
-
//this.cviews.toolViewWrapper.view.hidden = false;
|
|
546
|
-
if (this._props.title && "font" in this.cviews.titleViewWrapper.view)
|
|
547
|
-
this.cviews.titleViewWrapper.view.font = $font("bold", 17);
|
|
548
|
-
if (this._events.expanded) this._events.expanded(this);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
get style() {
|
|
553
|
-
return this._props.style;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
set style(num) {
|
|
557
|
-
this._props.style = num;
|
|
558
|
-
switch (num) {
|
|
559
|
-
case 0: {
|
|
560
|
-
this.hide();
|
|
561
|
-
break;
|
|
562
|
-
}
|
|
563
|
-
case 1: {
|
|
564
|
-
this.minimize();
|
|
565
|
-
break;
|
|
566
|
-
}
|
|
567
|
-
case 2: {
|
|
568
|
-
this.restore();
|
|
569
|
-
break;
|
|
570
|
-
}
|
|
571
|
-
case 3: {
|
|
572
|
-
this.expand();
|
|
573
|
-
break;
|
|
574
|
-
}
|
|
575
|
-
default:
|
|
576
|
-
break;
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
}
|