jsbox-cview 1.3.5 → 1.4.0
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 +12 -6
- package/components/alert/login-alert.ts +11 -7
- package/components/alert/plain-alert.ts +9 -6
- package/components/alert/uialert.ts +3 -4
- package/components/base.ts +3 -4
- package/components/custom-navigation-bar.ts +52 -53
- package/components/dialogs/dialog-sheet.ts +10 -15
- package/components/dialogs/form-dialog.ts +5 -7
- package/components/dialogs/list-dialog.ts +9 -6
- package/components/dialogs/text-dialog.ts +7 -6
- package/components/dynamic-itemsize-matrix.ts +25 -26
- package/components/dynamic-preference-listview.ts +29 -31
- package/components/dynamic-rowheight-list.ts +10 -11
- package/components/enhanced-imageview.ts +4 -4
- package/components/flowlayout.ts +233 -0
- package/components/image-pager.ts +16 -10
- package/components/page-control.ts +16 -13
- package/components/pageviewer-titlebar.ts +15 -16
- package/components/pageviewer.ts +16 -15
- package/components/rotating-view.ts +27 -22
- package/components/searchbar.ts +30 -25
- package/components/sheet.ts +16 -17
- package/components/single-views.ts +107 -105
- package/components/spinners/loading-dual-ring.ts +15 -8
- package/components/spinners/loading-wedges.ts +8 -4
- package/components/spinners/spinner-androidstyle.ts +15 -16
- package/components/static-preference-listview.ts +94 -95
- package/components/symbol-button.ts +16 -30
- package/components/tabbar.ts +24 -25
- package/controller/base-controller.ts +57 -58
- package/controller/controller-router.ts +2 -3
- package/controller/pageviewer-controller.ts +16 -15
- package/controller/presented-page-controller.ts +14 -13
- package/controller/splitview-controller.ts +22 -13
- package/controller/tabbar-controller.ts +15 -15
- package/dist/components/alert/input-alert.js +12 -5
- package/dist/components/alert/login-alert.js +10 -5
- package/dist/components/alert/plain-alert.js +9 -5
- package/dist/components/alert/uialert.js +3 -3
- package/dist/components/base.js +4 -4
- package/dist/components/custom-navigation-bar.js +30 -30
- package/dist/components/dialogs/dialog-sheet.js +9 -12
- package/dist/components/dialogs/form-dialog.js +5 -5
- package/dist/components/dialogs/list-dialog.js +9 -5
- package/dist/components/dialogs/text-dialog.js +7 -5
- package/dist/components/dynamic-itemsize-matrix.js +15 -15
- package/dist/components/dynamic-preference-listview.js +4 -4
- package/dist/components/dynamic-rowheight-list.js +3 -3
- package/dist/components/enhanced-imageview.js +3 -3
- package/dist/components/flowlayout.js +184 -0
- package/dist/components/image-pager.js +14 -9
- package/dist/components/page-control.js +21 -18
- package/dist/components/pageviewer-titlebar.js +15 -15
- package/dist/components/pageviewer.js +16 -14
- package/dist/components/rotating-view.js +24 -19
- package/dist/components/searchbar.js +29 -24
- package/dist/components/sheet.js +13 -14
- package/dist/components/single-views.js +5 -5
- package/dist/components/spinners/loading-dual-ring.js +12 -5
- package/dist/components/spinners/loading-wedges.js +7 -3
- package/dist/components/spinners/spinner-androidstyle.js +13 -15
- package/dist/components/static-preference-listview.js +94 -94
- package/dist/components/symbol-button.js +0 -14
- package/dist/components/tabbar.js +24 -24
- package/dist/controller/base-controller.js +36 -36
- package/dist/controller/controller-router.js +2 -2
- package/dist/controller/pageviewer-controller.js +10 -8
- package/dist/controller/presented-page-controller.js +8 -6
- package/dist/controller/splitview-controller.js +19 -12
- package/dist/controller/tabbar-controller.js +3 -3
- package/dist/index.js +1 -2
- package/dist/test/flowlayout.js +74 -0
- package/index.ts +1 -2
- package/package.json +1 -1
- package/test/flowlayout.ts +77 -0
- package/components/artificial-flowlayout.ts +0 -321
- package/components/spinners/loading-double-rings.ts +0 -121
- package/dist/components/artificial-flowlayout.js +0 -258
- package/dist/components/spinners/loading-double-rings.js +0 -104
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* # CView LoginAlert
|
|
4
|
-
*
|
|
5
|
-
* 显示一个登录输入框提示
|
|
6
|
-
*/
|
|
7
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.loginAlert = void 0;
|
|
9
4
|
const uialert_1 = require("./uialert");
|
|
10
5
|
const l10n_1 = require("../../utils/l10n");
|
|
6
|
+
/**
|
|
7
|
+
* 显示一个登录输入框提示
|
|
8
|
+
*
|
|
9
|
+
* @param title 标题
|
|
10
|
+
* @param message 内容
|
|
11
|
+
* @param placeholder1 输入框1的占位符
|
|
12
|
+
* @param placeholder2 输入框2的占位符
|
|
13
|
+
* @param cancelText 取消按钮文字
|
|
14
|
+
* @param confirmText 确认按钮文字
|
|
15
|
+
*/
|
|
11
16
|
function loginAlert({ title = "", message = "", placeholder1 = "", placeholder2 = "", cancelText = (0, l10n_1.l10n)("CANCEL"), confirmText = (0, l10n_1.l10n)("OK") } = {}) {
|
|
12
17
|
return new Promise((resolve, reject) => {
|
|
13
18
|
const alertVC = new uialert_1.UIAlertController(title, message, uialert_1.UIAlertControllerStyle.Alert);
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* # CView PlainAlert
|
|
4
|
-
*
|
|
5
|
-
* 显示一个文字提示
|
|
6
|
-
*/
|
|
7
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.plainAlert = void 0;
|
|
9
4
|
const uialert_1 = require("./uialert");
|
|
10
5
|
const l10n_1 = require("../../utils/l10n");
|
|
6
|
+
/**
|
|
7
|
+
* 显示一个文字提示
|
|
8
|
+
*
|
|
9
|
+
* @param title 标题
|
|
10
|
+
* @param message 内容
|
|
11
|
+
* @param cancelText 取消按钮文字
|
|
12
|
+
* @param confirmText 确认按钮文字
|
|
13
|
+
* @returns Promise
|
|
14
|
+
*/
|
|
11
15
|
function plainAlert({ title = "", message = "", cancelText = (0, l10n_1.l10n)("CANCEL"), confirmText = (0, l10n_1.l10n)("OK") } = {}) {
|
|
12
16
|
return new Promise((resolve, reject) => {
|
|
13
17
|
const alertVC = new uialert_1.UIAlertController(title, message, uialert_1.UIAlertControllerStyle.Alert);
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Alert的基础类
|
|
4
|
-
*/
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.UIAlertController = exports.UIAlertAction = exports.UIAlertControllerStyle = exports.UIAlertActionStyle = void 0;
|
|
7
4
|
exports.UIAlertActionStyle = {
|
|
@@ -25,6 +22,9 @@ class UIAlertAction {
|
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
24
|
exports.UIAlertAction = UIAlertAction;
|
|
25
|
+
/**
|
|
26
|
+
* Alert的基础类
|
|
27
|
+
*/
|
|
28
28
|
class UIAlertController {
|
|
29
29
|
constructor(title, message, style = exports.UIAlertControllerStyle.ActionSheet) {
|
|
30
30
|
this.title = title;
|
package/dist/components/base.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Base = void 0;
|
|
4
|
+
const cvid_1 = require("../utils/cvid");
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
6
|
+
*
|
|
4
7
|
* 组件 Base 基类,用于创建自定义组件。CView 的所有子类都应该继承自 Base。
|
|
5
8
|
*
|
|
6
9
|
* ## 属性
|
|
@@ -16,9 +19,6 @@
|
|
|
16
19
|
* - 通过组件化的方式,将JSBox view的定义和实例绑定,使用起来更加方便
|
|
17
20
|
* - 可以便利地创建自定义组件
|
|
18
21
|
*/
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.Base = void 0;
|
|
21
|
-
const cvid_1 = require("../utils/cvid");
|
|
22
22
|
class Base {
|
|
23
23
|
constructor() {
|
|
24
24
|
this.id = cvid_1.cvid.newId;
|
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomNavigationBar = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
const single_views_1 = require("./single-views");
|
|
6
|
+
const symbol_button_1 = require("./symbol-button");
|
|
7
|
+
const uitools_1 = require("../utils/uitools");
|
|
8
|
+
const navBarStyles = {
|
|
9
|
+
hidden: 0,
|
|
10
|
+
minimized: 1,
|
|
11
|
+
normal: 2,
|
|
12
|
+
expanded: 3
|
|
13
|
+
};
|
|
14
|
+
const navBarLayouts = [
|
|
15
|
+
(make, view) => {
|
|
16
|
+
make.left.right.top.inset(0);
|
|
17
|
+
make.height.equalTo(0);
|
|
18
|
+
},
|
|
19
|
+
(make, view) => {
|
|
20
|
+
make.left.right.top.inset(0);
|
|
21
|
+
make.bottom.equalTo(view.super.safeAreaTop).inset(-25);
|
|
22
|
+
},
|
|
23
|
+
(make, view) => {
|
|
24
|
+
make.left.right.top.inset(0);
|
|
25
|
+
make.bottom.equalTo(view.super.safeAreaTop).inset(-50);
|
|
26
|
+
},
|
|
27
|
+
(make, view) => {
|
|
28
|
+
make.left.right.top.inset(0);
|
|
29
|
+
make.bottom.equalTo(view.super.safeAreaTop).inset(-100);
|
|
30
|
+
}
|
|
31
|
+
];
|
|
2
32
|
/**
|
|
3
33
|
* # CView Custom NavigationBar
|
|
4
34
|
*
|
|
@@ -51,36 +81,6 @@
|
|
|
51
81
|
* - restore() 普通布局
|
|
52
82
|
* - expand() 扩展布局
|
|
53
83
|
*/
|
|
54
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
-
exports.CustomNavigationBar = void 0;
|
|
56
|
-
const base_1 = require("./base");
|
|
57
|
-
const single_views_1 = require("./single-views");
|
|
58
|
-
const symbol_button_1 = require("./symbol-button");
|
|
59
|
-
const uitools_1 = require("../utils/uitools");
|
|
60
|
-
const navBarStyles = {
|
|
61
|
-
hidden: 0,
|
|
62
|
-
minimized: 1,
|
|
63
|
-
normal: 2,
|
|
64
|
-
expanded: 3
|
|
65
|
-
};
|
|
66
|
-
const navBarLayouts = [
|
|
67
|
-
(make, view) => {
|
|
68
|
-
make.left.right.top.inset(0);
|
|
69
|
-
make.height.equalTo(0);
|
|
70
|
-
},
|
|
71
|
-
(make, view) => {
|
|
72
|
-
make.left.right.top.inset(0);
|
|
73
|
-
make.bottom.equalTo(view.super.safeAreaTop).inset(-25);
|
|
74
|
-
},
|
|
75
|
-
(make, view) => {
|
|
76
|
-
make.left.right.top.inset(0);
|
|
77
|
-
make.bottom.equalTo(view.super.safeAreaTop).inset(-50);
|
|
78
|
-
},
|
|
79
|
-
(make, view) => {
|
|
80
|
-
make.left.right.top.inset(0);
|
|
81
|
-
make.bottom.equalTo(view.super.safeAreaTop).inset(-100);
|
|
82
|
-
}
|
|
83
|
-
];
|
|
84
84
|
class CustomNavigationBar extends base_1.Base {
|
|
85
85
|
constructor({ props = {}, events = {} } = {}) {
|
|
86
86
|
super();
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* # cview DialogSheet
|
|
4
|
-
*
|
|
5
|
-
* dialog所需要的sheet
|
|
6
|
-
*
|
|
7
|
-
* ## 参数
|
|
8
|
-
* - `title` 标题
|
|
9
|
-
* - `cview` CView
|
|
10
|
-
* - `doneHandler` 完成时的回调
|
|
11
|
-
* - `presentMode` presentMode
|
|
12
|
-
* - `bgcolor` 背景颜色
|
|
13
|
-
*/
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.DialogSheet = void 0;
|
|
16
4
|
const sheet_1 = require("../sheet");
|
|
17
5
|
const custom_navigation_bar_1 = require("../custom-navigation-bar");
|
|
18
6
|
const l10n_1 = require("../../utils/l10n");
|
|
19
7
|
const single_views_1 = require("../single-views");
|
|
8
|
+
/**
|
|
9
|
+
* dialog所需要的sheet
|
|
10
|
+
*
|
|
11
|
+
* @param title 标题
|
|
12
|
+
* @param cview 内容视图
|
|
13
|
+
* @param doneHandler 完成时的回调
|
|
14
|
+
* @param presentMode 显示模式
|
|
15
|
+
* @param bgcolor 背景颜色
|
|
16
|
+
*/
|
|
20
17
|
class DialogSheet extends sheet_1.Sheet {
|
|
21
18
|
constructor(props) {
|
|
22
19
|
super({
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* # CView Form Dialog
|
|
4
|
-
*
|
|
5
|
-
* 显示一个表单
|
|
6
|
-
*/
|
|
7
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.formDialog = void 0;
|
|
9
4
|
const static_preference_listview_1 = require("../static-preference-listview");
|
|
10
5
|
const dialog_sheet_1 = require("./dialog-sheet");
|
|
6
|
+
/**
|
|
7
|
+
* 显示一个表单
|
|
8
|
+
* @param sections 表单分组, 请参考`PreferenceListView`中的`PreferenceSection`
|
|
9
|
+
* @param title 标题
|
|
10
|
+
*/
|
|
11
11
|
function formDialog({ sections, title }) {
|
|
12
12
|
const view = new static_preference_listview_1.PreferenceListView({ sections });
|
|
13
13
|
const sheet = new dialog_sheet_1.DialogSheet({
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* # CView List Dialog
|
|
4
|
-
*
|
|
5
|
-
* 显示一个列表以供选择
|
|
6
|
-
*/
|
|
7
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.listDialog = void 0;
|
|
9
4
|
const dialog_sheet_1 = require("./dialog-sheet");
|
|
10
5
|
const single_views_1 = require("../single-views");
|
|
6
|
+
/**
|
|
7
|
+
* 显示一个列表以供选择
|
|
8
|
+
*
|
|
9
|
+
* @param items 选项
|
|
10
|
+
* @param multiSelectEnabled 是否允许多选
|
|
11
|
+
* @param value 默认选中的选项
|
|
12
|
+
* @param values 默认选中的选项, 配合multiSelectEnabled使用
|
|
13
|
+
* @param title 标题
|
|
14
|
+
*/
|
|
11
15
|
function listDialog({ items, multiSelectEnabled, value, values = [], title }) {
|
|
12
16
|
if (value)
|
|
13
17
|
values = [value];
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* # CView Text Dialog
|
|
4
|
-
*
|
|
5
|
-
* 返回一个Promise用于输入文本
|
|
6
|
-
*/
|
|
7
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.textDialog = void 0;
|
|
9
4
|
const single_views_1 = require("../single-views");
|
|
10
5
|
const dialog_sheet_1 = require("./dialog-sheet");
|
|
6
|
+
/**
|
|
7
|
+
* 返回一个Promise用于输入文本
|
|
8
|
+
* @param title 标题
|
|
9
|
+
* @param text 初始文本
|
|
10
|
+
* @param placeholder 占位符
|
|
11
|
+
* @param editable 是否可编辑
|
|
12
|
+
*/
|
|
11
13
|
function textDialog({ title, text = "", placeholder = "", editable = true }) {
|
|
12
14
|
const textView = new single_views_1.Text({
|
|
13
15
|
props: {
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.DynamicItemSizeMatrix = void 0;
|
|
15
|
+
const base_1 = require("./base");
|
|
16
|
+
const single_views_1 = require("./single-views");
|
|
2
17
|
/**
|
|
3
18
|
* # CView Dynamic ItemSize Matrix
|
|
4
19
|
*
|
|
@@ -41,21 +56,6 @@
|
|
|
41
56
|
* 方法:
|
|
42
57
|
* - heightToWidth(width) 计算特定width时的应有的高度
|
|
43
58
|
*/
|
|
44
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
45
|
-
var t = {};
|
|
46
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
47
|
-
t[p] = s[p];
|
|
48
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
49
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
50
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
51
|
-
t[p[i]] = s[p[i]];
|
|
52
|
-
}
|
|
53
|
-
return t;
|
|
54
|
-
};
|
|
55
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
|
-
exports.DynamicItemSizeMatrix = void 0;
|
|
57
|
-
const base_1 = require("./base");
|
|
58
|
-
const single_views_1 = require("./single-views");
|
|
59
59
|
class DynamicItemSizeMatrix extends base_1.Base {
|
|
60
60
|
constructor({ props, layout, events = {} }) {
|
|
61
61
|
super();
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamicPreferenceListView = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
const static_preference_listview_1 = require("./static-preference-listview");
|
|
2
6
|
/**
|
|
3
7
|
* # cview PreferenceListView_dynamic
|
|
4
8
|
*
|
|
@@ -25,10 +29,6 @@
|
|
|
25
29
|
*
|
|
26
30
|
* - cview.sections = sections 可以写入新的 sections
|
|
27
31
|
*/
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.DynamicPreferenceListView = void 0;
|
|
30
|
-
const base_1 = require("./base");
|
|
31
|
-
const static_preference_listview_1 = require("./static-preference-listview");
|
|
32
32
|
class DynamicPreferenceListView extends base_1.Base {
|
|
33
33
|
constructor({ sections, props, layout, events = {} }) {
|
|
34
34
|
super();
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamicRowHeightList = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
2
5
|
/**
|
|
3
6
|
* # cview Dynamic RowHeight List
|
|
4
7
|
*
|
|
@@ -14,9 +17,6 @@
|
|
|
14
17
|
*
|
|
15
18
|
* 除了 props.data, props.template 和 events.rowHeight 不可用,其他均和 list 一致
|
|
16
19
|
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.DynamicRowHeightList = void 0;
|
|
19
|
-
const base_1 = require("./base");
|
|
20
20
|
class DynamicRowHeightList extends base_1.Base {
|
|
21
21
|
constructor({ sections, rows, props, layout, events }) {
|
|
22
22
|
super();
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnhancedImageView = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
const single_views_1 = require("./single-views");
|
|
6
|
+
const cvid_1 = require("../utils/cvid");
|
|
4
7
|
/**
|
|
5
8
|
* 此组件是为了加强 imageView,实现以下目的:
|
|
6
9
|
* 1. 点击实现上下翻页
|
|
@@ -18,9 +21,6 @@ exports.EnhancedImageView = void 0;
|
|
|
18
21
|
* upperLocationTouched: (sender: EnhancedImageView) => void, 上半部分被点击
|
|
19
22
|
* lowerLocationTouched: (sender: EnhancedImageView) => void, 下半部分被点击
|
|
20
23
|
*/
|
|
21
|
-
const base_1 = require("./base");
|
|
22
|
-
const single_views_1 = require("./single-views");
|
|
23
|
-
const cvid_1 = require("../utils/cvid");
|
|
24
24
|
class EnhancedImageView extends base_1.Base {
|
|
25
25
|
constructor({ props, layout, events = {} }) {
|
|
26
26
|
super();
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Flowlayout = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
/**
|
|
6
|
+
* 流式布局:间距固定,项目高度固定但宽度不定,左对齐,自动换行,不能滚动。
|
|
7
|
+
*
|
|
8
|
+
* 注意事项:
|
|
9
|
+
* 1. 此控件默认是可变高度的,但前提是布局中必须有关于高度的约束。如果不需要可变高度,可以设置fixedHeight为true
|
|
10
|
+
* 1. 此控件的边缘是不留白的,这和Matrix不同
|
|
11
|
+
* 2. itemWidth 如果超过总宽度,会被设定为总宽度
|
|
12
|
+
* 3. maxRows 可以控制最大行数,如果超过则会被截断
|
|
13
|
+
*
|
|
14
|
+
* ## 属性
|
|
15
|
+
* 属性的写法尽可能和Matrix的风格保持一致
|
|
16
|
+
* - items: FlowlayoutItem[] 关键参数,必须实现一个方法itemWidth(): number, 用于告知自身理想的宽度
|
|
17
|
+
* - spacing: number
|
|
18
|
+
* - itemHeight: number
|
|
19
|
+
* - maxRows?: number
|
|
20
|
+
* - fixedHeight?: boolean
|
|
21
|
+
* - menu?: UiTypes.ContextMenuOptions
|
|
22
|
+
*
|
|
23
|
+
* ## 事件
|
|
24
|
+
* - didSelect: (sender: Flowlayout, index: number, item: FlowlayoutItem) => void
|
|
25
|
+
* - didLongPress: (sender: Flowlayout, index: number, item: FlowlayoutItem) => void
|
|
26
|
+
*
|
|
27
|
+
* ## 方法
|
|
28
|
+
* - heightToWidth(width: number): height: number 根据宽度计算其应有的高度
|
|
29
|
+
* - cell(index: number): FlowlayoutItem 获取对应位置的 cview
|
|
30
|
+
* - set items(items: FlowlayoutItem[]) 设置子视图
|
|
31
|
+
* - get items(): FlowlayoutItem[] 获取子视图
|
|
32
|
+
*/
|
|
33
|
+
class Flowlayout extends base_1.Base {
|
|
34
|
+
constructor({ props, layout, events }) {
|
|
35
|
+
super();
|
|
36
|
+
this._width = 0;
|
|
37
|
+
this._props = props;
|
|
38
|
+
this._events = events;
|
|
39
|
+
this._wrappers = props.items.map((item, index) => new WrapperView({
|
|
40
|
+
item,
|
|
41
|
+
menu: props.menu,
|
|
42
|
+
didSelect: events === null || events === void 0 ? void 0 : events.didSelect,
|
|
43
|
+
didLongPress: events === null || events === void 0 ? void 0 : events.didLongPress,
|
|
44
|
+
flowlayout: this,
|
|
45
|
+
index
|
|
46
|
+
}));
|
|
47
|
+
this._defineView = () => ({
|
|
48
|
+
type: "view",
|
|
49
|
+
props: {
|
|
50
|
+
id: this.id
|
|
51
|
+
},
|
|
52
|
+
layout,
|
|
53
|
+
events: {
|
|
54
|
+
layoutSubviews: sender => {
|
|
55
|
+
if (this._width !== sender.frame.width) {
|
|
56
|
+
this._width = sender.frame.width;
|
|
57
|
+
const height = this._layoutWrappers();
|
|
58
|
+
if (!this._props.fixedHeight)
|
|
59
|
+
sender.updateLayout((make) => make.height.equalTo(height));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
views: this._wrappers.map(wrapper => wrapper.definition)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
cell(index) {
|
|
67
|
+
return this._props.items[index];
|
|
68
|
+
}
|
|
69
|
+
get items() {
|
|
70
|
+
return this._props.items;
|
|
71
|
+
}
|
|
72
|
+
set items(items) {
|
|
73
|
+
this._props.items = items;
|
|
74
|
+
this._wrappers = items.map((item, index) => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
return new WrapperView({
|
|
77
|
+
item,
|
|
78
|
+
menu: this._props.menu,
|
|
79
|
+
didSelect: (_a = this._events) === null || _a === void 0 ? void 0 : _a.didSelect,
|
|
80
|
+
didLongPress: (_b = this._events) === null || _b === void 0 ? void 0 : _b.didLongPress,
|
|
81
|
+
flowlayout: this,
|
|
82
|
+
index
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
this.view.views.forEach(v => v.remove());
|
|
86
|
+
this._wrappers.forEach(wrapper => this.view.add(wrapper.definition));
|
|
87
|
+
const height = this._layoutWrappers();
|
|
88
|
+
if (!this._props.fixedHeight)
|
|
89
|
+
this.view.updateLayout((make) => make.height.equalTo(height));
|
|
90
|
+
}
|
|
91
|
+
_layoutWrappers() {
|
|
92
|
+
const totalWidth = this._width;
|
|
93
|
+
const itemHeight = this._props.itemHeight;
|
|
94
|
+
const itemSpacing = this._props.spacing;
|
|
95
|
+
let x = 0;
|
|
96
|
+
let y = 0;
|
|
97
|
+
let line = 1;
|
|
98
|
+
this._wrappers.forEach((wrapper, index) => {
|
|
99
|
+
const itemWidth = wrapper.item.itemWidth();
|
|
100
|
+
const width = Math.min(itemWidth, totalWidth);
|
|
101
|
+
if (x + width > totalWidth) {
|
|
102
|
+
x = 0;
|
|
103
|
+
y += itemHeight + itemSpacing;
|
|
104
|
+
line++;
|
|
105
|
+
}
|
|
106
|
+
if (this._props.fixedRows && line > this._props.fixedRows) {
|
|
107
|
+
wrapper.hidden = true;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
wrapper.hidden = false;
|
|
111
|
+
}
|
|
112
|
+
wrapper.frame = $rect(x, y, width, itemHeight);
|
|
113
|
+
x += width + itemSpacing;
|
|
114
|
+
});
|
|
115
|
+
if (this._props.fixedRows && line > this._props.fixedRows) {
|
|
116
|
+
return this._props.fixedRows * (itemHeight + itemSpacing) - itemSpacing;
|
|
117
|
+
}
|
|
118
|
+
return y + itemHeight;
|
|
119
|
+
}
|
|
120
|
+
heightToWidth(width) {
|
|
121
|
+
const totalWidth = width;
|
|
122
|
+
const itemHeight = this._props.itemHeight;
|
|
123
|
+
const itemSpacing = this._props.spacing;
|
|
124
|
+
let x = 0;
|
|
125
|
+
let y = 0;
|
|
126
|
+
let line = 1;
|
|
127
|
+
this._wrappers.forEach((wrapper, index) => {
|
|
128
|
+
const itemWidth = wrapper.item.itemWidth();
|
|
129
|
+
const width = Math.min(itemWidth, totalWidth);
|
|
130
|
+
if (x + width > totalWidth) {
|
|
131
|
+
x = 0;
|
|
132
|
+
y += itemHeight + itemSpacing;
|
|
133
|
+
line++;
|
|
134
|
+
}
|
|
135
|
+
x += width + itemSpacing;
|
|
136
|
+
});
|
|
137
|
+
if (this._props.fixedRows && line > this._props.fixedRows) {
|
|
138
|
+
return this._props.fixedRows * (itemHeight + itemSpacing) - itemSpacing;
|
|
139
|
+
}
|
|
140
|
+
return y + itemHeight;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.Flowlayout = Flowlayout;
|
|
144
|
+
class WrapperView extends base_1.Base {
|
|
145
|
+
constructor({ item, menu, didSelect, didLongPress, flowlayout, index }) {
|
|
146
|
+
super();
|
|
147
|
+
this.item = item;
|
|
148
|
+
const props = {
|
|
149
|
+
id: this.id,
|
|
150
|
+
frame: $rect(0, 0, 0, 0),
|
|
151
|
+
userInteractionEnabled: true,
|
|
152
|
+
};
|
|
153
|
+
if (menu) {
|
|
154
|
+
props.menu = menu;
|
|
155
|
+
}
|
|
156
|
+
this._defineView = () => ({
|
|
157
|
+
type: "view",
|
|
158
|
+
props,
|
|
159
|
+
views: [item.definition],
|
|
160
|
+
events: {
|
|
161
|
+
tapped: sender => {
|
|
162
|
+
if (didSelect)
|
|
163
|
+
didSelect(flowlayout, index, item);
|
|
164
|
+
},
|
|
165
|
+
longPressed: sender => {
|
|
166
|
+
if (didLongPress)
|
|
167
|
+
didLongPress(flowlayout, index, item);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
set frame(frame) {
|
|
173
|
+
this.view.frame = frame;
|
|
174
|
+
}
|
|
175
|
+
get frame() {
|
|
176
|
+
return this.view.frame;
|
|
177
|
+
}
|
|
178
|
+
set hidden(hidden) {
|
|
179
|
+
this.view.hidden = hidden;
|
|
180
|
+
}
|
|
181
|
+
get hidden() {
|
|
182
|
+
return this.view.hidden;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ImagePager = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
const single_views_1 = require("./single-views");
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
7
|
+
* 图片浏览组件
|
|
6
8
|
*
|
|
7
|
-
*
|
|
8
|
-
* srcs: string[] - 图片地址列表
|
|
9
|
-
* page: number - 当前页码
|
|
9
|
+
* 与内置的Gallery组件相比,ImagePager组件可以动态刷新,适用于图片数量较多的场景,以及需要动态加载图片列表的场景
|
|
10
10
|
*
|
|
11
|
-
* # Events
|
|
12
|
-
* changed: (page: number) => void - 页码变化时触发
|
|
13
|
-
* tapped: (sender: ImagePager) => void - 点击图片时触发
|
|
14
11
|
*/
|
|
15
|
-
const base_1 = require("./base");
|
|
16
|
-
const single_views_1 = require("./single-views");
|
|
17
12
|
class ImagePager extends base_1.Base {
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param props
|
|
16
|
+
* - srcs: string[] - 图片地址列表
|
|
17
|
+
* - page: number - 当前页码
|
|
18
|
+
* @param layout
|
|
19
|
+
* @param events
|
|
20
|
+
* - changed: (page: number) => void - 页码变化时触发
|
|
21
|
+
* - tapped: (sender: ImagePager) => void - 点击图片时触发
|
|
22
|
+
*/
|
|
18
23
|
constructor({ props, layout, events = {} }) {
|
|
19
24
|
super();
|
|
20
25
|
this._props = Object.assign({ srcs: [], page: 0 }, props);
|
|
@@ -1,22 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* # CView PageControl
|
|
4
|
-
*
|
|
5
|
-
* 基于 Runtime 构建 PageControl
|
|
6
|
-
*
|
|
7
|
-
* 请注意本视图如果没有足够的横向宽度,会显示不全
|
|
8
|
-
* ## Props
|
|
9
|
-
*
|
|
10
|
-
* - 只写 numberOfPages: numnber
|
|
11
|
-
* - 读写 currentPage: number
|
|
12
|
-
* - 只写 pageIndicatorTintColor?: JSBoxColor
|
|
13
|
-
* - 只写 currentPageIndicatorTintColor?: JSBoxColor
|
|
14
|
-
* - 其他通用属性
|
|
15
|
-
*
|
|
16
|
-
* ## Events
|
|
17
|
-
*
|
|
18
|
-
* changed: (cview: Cview, currentPage: number) => void
|
|
19
|
-
*/
|
|
20
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
21
3
|
var t = {};
|
|
22
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -31,7 +13,28 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
31
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
14
|
exports.PageControl = void 0;
|
|
33
15
|
const single_views_1 = require("./single-views");
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* 基于 Runtime 构建 PageControl
|
|
19
|
+
*
|
|
20
|
+
* 请注意本视图如果没有足够的横向宽度,会显示不全
|
|
21
|
+
*
|
|
22
|
+
* @property currentPage: number
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
34
25
|
class PageControl extends single_views_1.Runtime {
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param props 属性
|
|
29
|
+
* - numberOfPages: 页面数量
|
|
30
|
+
* - currentPage: 当前页面
|
|
31
|
+
* - pageIndicatorTintColor?: 页面指示器颜色
|
|
32
|
+
* - currentPageIndicatorTintColor?: 当前页面指示器颜色
|
|
33
|
+
* @param layout 布局
|
|
34
|
+
* @param events 事件
|
|
35
|
+
* - changed: (sender: PageControl, currentPage: number) => void
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
35
38
|
constructor({ props, layout, events = {} }) {
|
|
36
39
|
const { numberOfPages = 3, currentPage = 0, pageIndicatorTintColor, currentPageIndicatorTintColor } = props, restProps = __rest(props, ["numberOfPages", "currentPage", "pageIndicatorTintColor", "currentPageIndicatorTintColor"]);
|
|
37
40
|
const { changed } = events, restEvents = __rest(events, ["changed"]);
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* # CView PageViewer TitleBar
|
|
4
|
-
*
|
|
5
|
-
* props:
|
|
6
|
-
*
|
|
7
|
-
* - 只写 items: string[]
|
|
8
|
-
* - 读写 index: number
|
|
9
|
-
* - 只写 selectedItemColor
|
|
10
|
-
* - 只写 defaultItemColor
|
|
11
|
-
*
|
|
12
|
-
* events:
|
|
13
|
-
*
|
|
14
|
-
* - changed: (cview, index) => void 在点击变更 index 的时候回调
|
|
15
|
-
*/
|
|
16
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
3
|
var t = {};
|
|
18
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -28,14 +14,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
28
14
|
exports.PageViewerTitleBar = void 0;
|
|
29
15
|
const base_1 = require("./base");
|
|
30
16
|
const single_views_1 = require("./single-views");
|
|
31
|
-
//const { getTextWidth } = require("cview-util-ui");
|
|
32
17
|
function weightedAverageColors(c0, c1, w) {
|
|
33
18
|
const red = c0.components.red * w + c1.components.red * (1 - w);
|
|
34
19
|
const green = c0.components.green * w + c1.components.green * (1 - w);
|
|
35
20
|
const blue = c0.components.blue * w + c1.components.blue * (1 - w);
|
|
36
21
|
return $rgb(red, green, blue);
|
|
37
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* [PageViewer](./pageviewer.ts)配套的标题栏
|
|
25
|
+
* @property index: number
|
|
26
|
+
*/
|
|
38
27
|
class PageViewerTitleBar extends base_1.Base {
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param props 属性
|
|
31
|
+
* - items: string[]
|
|
32
|
+
* - index: number
|
|
33
|
+
* - selectedItemColor
|
|
34
|
+
* - defaultItemColor
|
|
35
|
+
* @param layout 布局
|
|
36
|
+
* @param events 事件
|
|
37
|
+
* - changed: (cview, index) => void 在点击变更 index 的时候回调
|
|
38
|
+
*/
|
|
39
39
|
constructor({ props, layout, events = {} }) {
|
|
40
40
|
super();
|
|
41
41
|
this._props = Object.assign({ index: 0, selectedItemColor: $color("systemLink"), defaultItemColor: $color("secondaryText") }, props);
|