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
package/dist/test/searchbar.js
CHANGED
|
@@ -3,34 +3,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const searchbar_1 = require("../components/searchbar");
|
|
4
4
|
const s0 = new searchbar_1.SearchBar({
|
|
5
5
|
props: {
|
|
6
|
-
style: 0
|
|
6
|
+
style: 0,
|
|
7
7
|
},
|
|
8
8
|
layout: (make, view) => {
|
|
9
9
|
make.centerX.equalTo(view.super);
|
|
10
10
|
make.size.equalTo($size(300, 44));
|
|
11
11
|
make.top.equalTo(view.super).inset(50);
|
|
12
|
-
}
|
|
12
|
+
},
|
|
13
13
|
});
|
|
14
14
|
const s1 = new searchbar_1.SearchBar({
|
|
15
15
|
props: {
|
|
16
|
-
style: 1
|
|
16
|
+
style: 1,
|
|
17
17
|
},
|
|
18
18
|
layout: (make, view) => {
|
|
19
19
|
make.centerX.equalTo(view.super);
|
|
20
20
|
make.size.equalTo($size(300, 44));
|
|
21
21
|
make.top.equalTo(view.super).inset(125);
|
|
22
|
-
}
|
|
22
|
+
},
|
|
23
23
|
});
|
|
24
24
|
const s2 = new searchbar_1.SearchBar({
|
|
25
25
|
props: {
|
|
26
|
-
style: 2
|
|
26
|
+
style: 2,
|
|
27
27
|
},
|
|
28
28
|
layout: (make, view) => {
|
|
29
29
|
make.centerX.equalTo(view.super);
|
|
30
30
|
make.size.equalTo($size(300, 44));
|
|
31
31
|
make.top.equalTo(view.super).inset(200);
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
33
|
});
|
|
34
34
|
$ui.render({
|
|
35
|
-
views: [s0.definition, s1.definition, s2.definition]
|
|
35
|
+
views: [s0.definition, s1.definition, s2.definition],
|
|
36
36
|
});
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const splitview_controller_1 = require("../controller/splitview-controller");
|
|
4
4
|
const base_controller_1 = require("../controller/base-controller");
|
|
5
|
-
const items = [
|
|
5
|
+
const items = [
|
|
6
|
+
{
|
|
6
7
|
controller: new base_controller_1.BaseController({
|
|
7
8
|
props: { bgcolor: $color("red") },
|
|
8
9
|
events: {
|
|
@@ -11,11 +12,12 @@ const items = [{
|
|
|
11
12
|
},
|
|
12
13
|
didDisappear: () => {
|
|
13
14
|
console.log("Page 1 did disappear");
|
|
14
|
-
}
|
|
15
|
-
}
|
|
15
|
+
},
|
|
16
|
+
},
|
|
16
17
|
}),
|
|
17
|
-
bgcolor: $color("red")
|
|
18
|
-
},
|
|
18
|
+
bgcolor: $color("red"),
|
|
19
|
+
},
|
|
20
|
+
{
|
|
19
21
|
controller: new base_controller_1.BaseController({
|
|
20
22
|
props: { bgcolor: $color("yellow") },
|
|
21
23
|
events: {
|
|
@@ -24,15 +26,16 @@ const items = [{
|
|
|
24
26
|
},
|
|
25
27
|
didDisappear: () => {
|
|
26
28
|
console.log("Page 2 did disappear");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
+
},
|
|
30
|
+
},
|
|
29
31
|
}),
|
|
30
|
-
bgcolor: $color("green")
|
|
31
|
-
}
|
|
32
|
+
bgcolor: $color("green"),
|
|
33
|
+
},
|
|
34
|
+
];
|
|
32
35
|
const pageViewerController = new splitview_controller_1.SplitViewController({
|
|
33
36
|
props: {
|
|
34
|
-
items
|
|
37
|
+
items,
|
|
35
38
|
},
|
|
36
|
-
events: {}
|
|
39
|
+
events: {},
|
|
37
40
|
});
|
|
38
41
|
pageViewerController.uirender();
|
|
@@ -9,19 +9,19 @@ const sections = [
|
|
|
9
9
|
type: "string",
|
|
10
10
|
title: "string",
|
|
11
11
|
key: "string",
|
|
12
|
-
value: "测试一号测试二号测试三号测试四号测试五号测试六号"
|
|
12
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号",
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
type: "number",
|
|
16
16
|
title: "number",
|
|
17
17
|
key: "number",
|
|
18
|
-
value: 1111.1
|
|
18
|
+
value: 1111.1,
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
type: "integer",
|
|
22
22
|
title: "integer",
|
|
23
23
|
key: "integer",
|
|
24
|
-
value: 1111
|
|
24
|
+
value: 1111,
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
type: "stepper",
|
|
@@ -29,9 +29,9 @@ const sections = [
|
|
|
29
29
|
key: "stepper",
|
|
30
30
|
value: 2,
|
|
31
31
|
min: 2,
|
|
32
|
-
max: 5
|
|
33
|
-
}
|
|
34
|
-
]
|
|
32
|
+
max: 5,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
title: "Section 2",
|
|
@@ -40,7 +40,7 @@ const sections = [
|
|
|
40
40
|
type: "boolean",
|
|
41
41
|
title: "boolean",
|
|
42
42
|
key: "boolean",
|
|
43
|
-
value: true
|
|
43
|
+
value: true,
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
type: "slider",
|
|
@@ -49,30 +49,30 @@ const sections = [
|
|
|
49
49
|
value: 1,
|
|
50
50
|
decimal: 0,
|
|
51
51
|
min: 0,
|
|
52
|
-
max: 100
|
|
52
|
+
max: 100,
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
type: "list",
|
|
56
56
|
title: "list",
|
|
57
57
|
key: "list",
|
|
58
58
|
items: ["测试一号", "测试bbb"],
|
|
59
|
-
value: 0
|
|
59
|
+
value: 0,
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
type: "tab",
|
|
63
63
|
title: "tab",
|
|
64
64
|
key: "tab",
|
|
65
65
|
items: ["测试aaa", "测试bbb"],
|
|
66
|
-
value: 0
|
|
66
|
+
value: 0,
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
type: "date",
|
|
70
70
|
title: "date",
|
|
71
71
|
key: "date",
|
|
72
72
|
//value: new Date()
|
|
73
|
-
mode: 1
|
|
74
|
-
}
|
|
75
|
-
]
|
|
73
|
+
mode: 1,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
title: "Section 3",
|
|
@@ -80,19 +80,19 @@ const sections = [
|
|
|
80
80
|
{
|
|
81
81
|
type: "info",
|
|
82
82
|
title: "info",
|
|
83
|
-
value: "this is info"
|
|
83
|
+
value: "this is info",
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
86
|
type: "link",
|
|
87
87
|
title: "link",
|
|
88
|
-
value: "https://apple.com"
|
|
88
|
+
value: "https://apple.com",
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
91
|
type: "action",
|
|
92
92
|
title: "action",
|
|
93
|
-
value: () => console.info(0)
|
|
94
|
-
}
|
|
95
|
-
]
|
|
93
|
+
value: () => console.info(0),
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
title: "Section 4",
|
|
@@ -101,25 +101,25 @@ const sections = [
|
|
|
101
101
|
type: "interactive-info",
|
|
102
102
|
title: "interactive-info",
|
|
103
103
|
key: "interactive-info",
|
|
104
|
-
value: "测试一号测试二号测试三号测试四号测试五号测试六号"
|
|
104
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号",
|
|
105
105
|
},
|
|
106
106
|
{
|
|
107
107
|
type: "interactive-info",
|
|
108
108
|
title: "interactive-info2",
|
|
109
109
|
key: "interactive-info2",
|
|
110
110
|
value: "测试一号测试二号测试三号测试四号测试五号测试六号",
|
|
111
|
-
copyable: true
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
}
|
|
111
|
+
copyable: true,
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
115
|
];
|
|
116
116
|
const v = new static_preference_listview_1.PreferenceListView({
|
|
117
117
|
props: { data: [] },
|
|
118
118
|
sections: sections,
|
|
119
119
|
layout: $layout.fill,
|
|
120
120
|
events: {
|
|
121
|
-
changed: (values) => console.info(values)
|
|
122
|
-
}
|
|
121
|
+
changed: (values) => console.info(values),
|
|
122
|
+
},
|
|
123
123
|
});
|
|
124
124
|
$ui.render({
|
|
125
125
|
props: {
|
|
@@ -127,10 +127,9 @@ $ui.render({
|
|
|
127
127
|
navButtons: [
|
|
128
128
|
{
|
|
129
129
|
symbol: "plus",
|
|
130
|
-
handler: () => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
]
|
|
130
|
+
handler: () => { },
|
|
131
|
+
},
|
|
132
|
+
],
|
|
134
133
|
},
|
|
135
|
-
views: [v.definition]
|
|
134
|
+
views: [v.definition],
|
|
136
135
|
});
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tabbar_controller_1 = require("../controller/tabbar-controller");
|
|
4
4
|
const base_controller_1 = require("../controller/base-controller");
|
|
5
|
-
const items = [
|
|
5
|
+
const items = [
|
|
6
|
+
{
|
|
6
7
|
controller: new base_controller_1.BaseController({
|
|
7
8
|
props: { bgcolor: $color("red") },
|
|
8
9
|
events: {
|
|
@@ -11,11 +12,12 @@ const items = [{
|
|
|
11
12
|
},
|
|
12
13
|
didDisappear: () => {
|
|
13
14
|
console.log("Page 1 did disappear");
|
|
14
|
-
}
|
|
15
|
-
}
|
|
15
|
+
},
|
|
16
|
+
},
|
|
16
17
|
}),
|
|
17
|
-
title: "Page 1"
|
|
18
|
-
},
|
|
18
|
+
title: "Page 1",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
19
21
|
controller: new base_controller_1.BaseController({
|
|
20
22
|
props: { bgcolor: $color("yellow") },
|
|
21
23
|
events: {
|
|
@@ -24,14 +26,15 @@ const items = [{
|
|
|
24
26
|
},
|
|
25
27
|
didDisappear: () => {
|
|
26
28
|
console.log("Page 2 did disappear");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
+
},
|
|
30
|
+
},
|
|
29
31
|
}),
|
|
30
|
-
title: "Page 2"
|
|
31
|
-
}
|
|
32
|
+
title: "Page 2",
|
|
33
|
+
},
|
|
34
|
+
];
|
|
32
35
|
const pageViewerController = new tabbar_controller_1.TabBarController({
|
|
33
36
|
props: {
|
|
34
|
-
items
|
|
37
|
+
items,
|
|
35
38
|
},
|
|
36
39
|
events: {
|
|
37
40
|
changed: (sender, index) => {
|
|
@@ -39,7 +42,7 @@ const pageViewerController = new tabbar_controller_1.TabBarController({
|
|
|
39
42
|
},
|
|
40
43
|
doubleTapped: (sender, index) => {
|
|
41
44
|
console.log(`Double tapped on index ${index}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
45
|
+
},
|
|
46
|
+
},
|
|
44
47
|
});
|
|
45
48
|
pageViewerController.uirender({});
|
package/dist/utils/colors.js
CHANGED
|
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.sectionHeaderColor = exports.gold = exports.searchBarBgcolor = exports.searchBarSymbolColor = exports.footBarDefaultSegmentColor = exports.sheetNavBarColor = void 0;
|
|
5
5
|
exports.sheetNavBarColor = $color("tint", $color("tertiarySurface"));
|
|
6
6
|
exports.footBarDefaultSegmentColor = $color("#b7bec6", "#6e6e6e");
|
|
7
|
-
//fixedSecondarySurface: $color("#f2f2f7", $color("secondarySurface")), // 让 secondarySurface 在light mode下可以和纯白区分
|
|
8
7
|
exports.searchBarSymbolColor = $color("#777", "#aaa");
|
|
9
8
|
exports.searchBarBgcolor = $color("backgroundColor", "secondarySurface");
|
|
10
9
|
exports.gold = $color("#ffd700");
|
|
11
10
|
exports.sectionHeaderColor = $color({
|
|
12
11
|
light: "#666666",
|
|
13
12
|
dark: "#acacac",
|
|
14
|
-
black: "#ababab"
|
|
13
|
+
black: "#ababab",
|
|
15
14
|
});
|
package/dist/utils/l10n.js
CHANGED
|
@@ -5,35 +5,35 @@ exports.l10n = void 0;
|
|
|
5
5
|
const language = $device.info.language;
|
|
6
6
|
const strings = {
|
|
7
7
|
"zh-Hans": {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
DUPLICATE_VALUES: "取值重复",
|
|
9
|
+
DONE: "完成",
|
|
10
|
+
ADD: "添加",
|
|
11
|
+
SEARCH: "搜索",
|
|
12
|
+
PREVIOUS: "上一步",
|
|
13
|
+
NEXT: "下一步",
|
|
14
|
+
REMOVE: "移除",
|
|
15
|
+
EDIT: "编辑",
|
|
16
|
+
FINISHED: "完成",
|
|
17
|
+
INVALID_VALUES: "取值不合法",
|
|
18
|
+
CANCEL: "取消",
|
|
19
|
+
CLIPBOARD: "剪贴板",
|
|
20
|
+
OK: "好的",
|
|
21
|
+
},
|
|
22
|
+
en: {
|
|
23
|
+
DUPLICATE_VALUES: "Duplicate values",
|
|
24
|
+
DONE: "Done",
|
|
25
|
+
ADD: "Add",
|
|
26
|
+
SEARCH: "Search",
|
|
27
|
+
PREVIOUS: "Previous",
|
|
28
|
+
NEXT: "Next",
|
|
29
|
+
REMOVE: "Remove",
|
|
30
|
+
EDIT: "Edit",
|
|
31
|
+
FINISHED: "Finished",
|
|
32
|
+
INVALID_VALUES: "Invalid values",
|
|
33
|
+
CANCEL: "Cancel",
|
|
34
|
+
CLIPBOARD: "Clipboard",
|
|
35
|
+
OK: "OK",
|
|
21
36
|
},
|
|
22
|
-
"en": {
|
|
23
|
-
"DUPLICATE_VALUES": "Duplicate values",
|
|
24
|
-
"DONE": "Done",
|
|
25
|
-
"ADD": "Add",
|
|
26
|
-
"SEARCH": "Search",
|
|
27
|
-
"PREVIOUS": "Previous",
|
|
28
|
-
"NEXT": "Next",
|
|
29
|
-
"REMOVE": "Remove",
|
|
30
|
-
"EDIT": "Edit",
|
|
31
|
-
"FINISHED": "Finished",
|
|
32
|
-
"INVALID_VALUES": "Invalid values",
|
|
33
|
-
"CANCEL": "Cancel",
|
|
34
|
-
"CLIPBOARD": "Clipboard",
|
|
35
|
-
"OK": "OK"
|
|
36
|
-
}
|
|
37
37
|
};
|
|
38
38
|
function l10n(key) {
|
|
39
39
|
if (!strings[language])
|
package/dist/utils/path.js
CHANGED
|
@@ -36,7 +36,7 @@ function split(path) {
|
|
|
36
36
|
else {
|
|
37
37
|
return [
|
|
38
38
|
protocol + remainingPath.slice(0, lastIndex),
|
|
39
|
-
remainingPath.slice(lastIndex + 1)
|
|
39
|
+
remainingPath.slice(lastIndex + 1),
|
|
40
40
|
];
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -73,7 +73,7 @@ function join(...args) {
|
|
|
73
73
|
return part.trim().replace(/(^[/]*|[/]*$)/g, "");
|
|
74
74
|
}
|
|
75
75
|
})
|
|
76
|
-
.filter(x => x.length)
|
|
76
|
+
.filter((x) => x.length)
|
|
77
77
|
.join("/");
|
|
78
78
|
}
|
|
79
79
|
exports.join = join;
|
package/dist/utils/rect.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
// 用于处理矩形的工具函数
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.inset = exports.translate = exports.union = exports.intersection = exports.intersects = exports.containsRect = exports.containsPoint = exports.center = void 0;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* When called without arguments, return the center of the rectangle.
|
|
7
|
+
* When a Point is passed as an argument, the rectangle’s x and y values
|
|
8
|
+
* are adjusted, so that the new center of the rectangle is p.
|
|
9
|
+
*/
|
|
6
10
|
function center(rect, point) {
|
|
7
11
|
const { x = 0, y = 0, width: w, height: h } = rect;
|
|
8
12
|
if (!point)
|
|
@@ -13,28 +17,40 @@ function center(rect, point) {
|
|
|
13
17
|
return point;
|
|
14
18
|
}
|
|
15
19
|
exports.center = center;
|
|
16
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Return true if the given point lies within the bounds of the rectangle,
|
|
22
|
+
* false otherwise.
|
|
23
|
+
*/
|
|
17
24
|
function containsPoint(rect, point) {
|
|
18
25
|
const { x, y, width: w, height: h } = rect;
|
|
19
26
|
const { x: px, y: py } = point;
|
|
20
27
|
return x <= px && px <= x + w && y <= py && py <= y + h;
|
|
21
28
|
}
|
|
22
29
|
exports.containsPoint = containsPoint;
|
|
23
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Return true if the given rectangle lies entirely within the bounds of
|
|
32
|
+
* this rectangle, false otherwise.
|
|
33
|
+
*/
|
|
24
34
|
function containsRect(rect, otherRect) {
|
|
25
35
|
const { x, y, width: w, height: h } = rect;
|
|
26
36
|
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
27
37
|
return x <= x1 && y <= y1 && x1 + w1 <= x + w && y1 + h1 <= y + h;
|
|
28
38
|
}
|
|
29
39
|
exports.containsRect = containsRect;
|
|
30
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Return true if this rectangle intersects with the other rectangle,
|
|
42
|
+
* false otherwise.
|
|
43
|
+
*/
|
|
31
44
|
function intersects(rect, otherRect) {
|
|
32
45
|
const { x, y, width: w, height: h } = rect;
|
|
33
46
|
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
34
47
|
return x < x1 + w1 && x1 < x + w && y < y1 + h1 && y1 < y + h;
|
|
35
48
|
}
|
|
36
49
|
exports.intersects = intersects;
|
|
37
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Return a $rect that corresponds to the intersection of this rectangle with
|
|
52
|
+
* the other one.
|
|
53
|
+
*/
|
|
38
54
|
function intersection(rect, otherRect) {
|
|
39
55
|
const { x, y, width: w, height: h } = rect;
|
|
40
56
|
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
@@ -45,7 +61,9 @@ function intersection(rect, otherRect) {
|
|
|
45
61
|
return $rect(nx, ny, nw, nh);
|
|
46
62
|
}
|
|
47
63
|
exports.intersection = intersection;
|
|
48
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Return the smallest $rect that encloses both rectangles.
|
|
66
|
+
*/
|
|
49
67
|
function union(rect, otherRect) {
|
|
50
68
|
const { x, y, width: w, height: h } = rect;
|
|
51
69
|
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
@@ -56,14 +74,18 @@ function union(rect, otherRect) {
|
|
|
56
74
|
return $rect(nx, ny, nw, nh);
|
|
57
75
|
}
|
|
58
76
|
exports.union = union;
|
|
59
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Equivalent to $rect(r.x + x, r.y + y, r.w, r.h)
|
|
79
|
+
*/
|
|
60
80
|
function translate(rect, point) {
|
|
61
81
|
const { x, y, width, height } = rect;
|
|
62
82
|
const { x: x1, y: y1 } = point;
|
|
63
83
|
return $rect(x + x1, y + y1, width, height);
|
|
64
84
|
}
|
|
65
85
|
exports.translate = translate;
|
|
66
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Return a $rect that is adjusted by the given edge insets.
|
|
88
|
+
*/
|
|
67
89
|
function inset(rect, insets) {
|
|
68
90
|
const { x, y, width, height } = rect;
|
|
69
91
|
const { top, left, bottom, right } = insets;
|
package/dist/utils/uitools.js
CHANGED
|
@@ -2,36 +2,44 @@
|
|
|
2
2
|
// 用于UI相关的工具函数
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.setLayer = exports.layerCommonOptions = exports.absoluteFrame = exports.getTextHeight = exports.getTextWidth = exports.getWindowSize = void 0;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* 立即获得window size
|
|
7
|
+
*/
|
|
6
8
|
function getWindowSize() {
|
|
7
9
|
const window = $objc("UIWindow").$keyWindow().jsValue();
|
|
8
10
|
return window.size;
|
|
9
11
|
}
|
|
10
12
|
exports.getWindowSize = getWindowSize;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
/**
|
|
14
|
+
* 获取单行字符串应有的宽度
|
|
15
|
+
* 默认额外添加3 inset
|
|
16
|
+
*/
|
|
13
17
|
function getTextWidth(text, { font = $font(17), inset = 3 } = {}) {
|
|
14
18
|
return (Math.ceil($text.sizeThatFits({
|
|
15
19
|
text,
|
|
16
20
|
width: 10000,
|
|
17
21
|
font,
|
|
18
|
-
lineSpacing: 0
|
|
22
|
+
lineSpacing: 0,
|
|
19
23
|
}).width) + inset);
|
|
20
24
|
}
|
|
21
25
|
exports.getTextWidth = getTextWidth;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
/**
|
|
27
|
+
* 获取字符串指定宽度后应有的高度
|
|
28
|
+
* 默认额外添加3 inset
|
|
29
|
+
*/
|
|
30
|
+
function getTextHeight(text, { width = 300, font = $font(17), inset = 3, lineSpacing = 0 } = {}) {
|
|
25
31
|
return (Math.ceil($text.sizeThatFits({
|
|
26
32
|
text,
|
|
27
33
|
width,
|
|
28
34
|
font,
|
|
29
|
-
lineSpacing
|
|
35
|
+
lineSpacing,
|
|
30
36
|
}).height) + inset);
|
|
31
37
|
}
|
|
32
38
|
exports.getTextHeight = getTextHeight;
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
/**
|
|
40
|
+
* 计算某个view在某个上级view(若不指定则为UIWindow)上的绝对frame
|
|
41
|
+
* 此方法不考虑旋转变形等特殊情况
|
|
42
|
+
*/
|
|
35
43
|
function absoluteFrame(view, endView) {
|
|
36
44
|
const frame = view.frame;
|
|
37
45
|
let superView = view.super;
|
|
@@ -51,40 +59,42 @@ exports.layerCommonOptions = {
|
|
|
51
59
|
shadowRadius: 0,
|
|
52
60
|
shadowOpacity: 0,
|
|
53
61
|
shadowOffset: $size(0, 0),
|
|
54
|
-
shadowColor: $color("clear")
|
|
62
|
+
shadowColor: $color("clear"),
|
|
55
63
|
},
|
|
56
64
|
roundedShadow: {
|
|
57
65
|
cornerRadius: 12,
|
|
58
66
|
shadowRadius: 10,
|
|
59
67
|
shadowOpacity: 1,
|
|
60
68
|
shadowOffset: $size(0, 0),
|
|
61
|
-
shadowColor: $color("black")
|
|
69
|
+
shadowColor: $color("black"),
|
|
62
70
|
},
|
|
63
71
|
textShadow: {
|
|
64
72
|
cornerRadius: 0,
|
|
65
73
|
shadowRadius: 1.2,
|
|
66
74
|
shadowOpacity: 1,
|
|
67
75
|
shadowOffset: $size(0, 1),
|
|
68
|
-
shadowColor: $color("black")
|
|
76
|
+
shadowColor: $color("black"),
|
|
69
77
|
},
|
|
70
78
|
circleViewShadow: {
|
|
71
79
|
cornerRadius: 25,
|
|
72
80
|
shadowRadius: 3,
|
|
73
81
|
shadowOpacity: 0.6,
|
|
74
82
|
shadowOffset: $size(0, 3),
|
|
75
|
-
shadowColor: $color("black")
|
|
83
|
+
shadowColor: $color("black"),
|
|
76
84
|
},
|
|
77
85
|
toastShadows: {
|
|
78
86
|
cornerRadius: 15,
|
|
79
87
|
shadowRadius: 8,
|
|
80
88
|
shadowOpacity: 0.35,
|
|
81
89
|
shadowOffset: $size(0, 0),
|
|
82
|
-
shadowColor: $color("black")
|
|
83
|
-
}
|
|
90
|
+
shadowColor: $color("black"),
|
|
91
|
+
},
|
|
84
92
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
/**
|
|
94
|
+
* 在layout中使用
|
|
95
|
+
* 所应用的view不可以指定radius和clipTobounds,否则无效
|
|
96
|
+
*/
|
|
97
|
+
function setLayer(view, { cornerRadius = 0, shadowRadius = 0, shadowOpacity = 0, shadowOffset = $size(0, 0), shadowColor = $color("clear"), } = {}) {
|
|
88
98
|
const layer = view.ocValue().invoke("layer");
|
|
89
99
|
layer.invoke("setCornerRadius", cornerRadius);
|
|
90
100
|
layer.invoke("setShadowRadius", shadowRadius);
|