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/utils/path.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// 用于处理路径的工具函数
|
|
2
2
|
|
|
3
|
-
function _splitProtocol(path: string): [string, string]{
|
|
3
|
+
function _splitProtocol(path: string): [string, string] {
|
|
4
4
|
const regex = /^\w+:\/\//;
|
|
5
5
|
const result = regex.exec(path);
|
|
6
6
|
if (result) {
|
|
@@ -20,7 +20,7 @@ function _normalize(path: string): string {
|
|
|
20
20
|
return protocol + remainingPath.replace(/\/{2,}/g, "/");
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function split(path: string): [string, string]{
|
|
23
|
+
export function split(path: string): [string, string] {
|
|
24
24
|
path = _normalize(path);
|
|
25
25
|
const [protocol, remainingPath] = _splitProtocol(path);
|
|
26
26
|
const lastIndex = remainingPath.lastIndexOf("/");
|
|
@@ -31,12 +31,12 @@ export function split(path: string): [string, string]{
|
|
|
31
31
|
} else {
|
|
32
32
|
return [
|
|
33
33
|
protocol + remainingPath.slice(0, lastIndex),
|
|
34
|
-
remainingPath.slice(lastIndex + 1)
|
|
34
|
+
remainingPath.slice(lastIndex + 1),
|
|
35
35
|
];
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export function dirname(path: string): string{
|
|
39
|
+
export function dirname(path: string): string {
|
|
40
40
|
return split(path)[0];
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ export function basename(path: string): string {
|
|
|
44
44
|
return split(path)[1];
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export function extname(path: string): string{
|
|
47
|
+
export function extname(path: string): string {
|
|
48
48
|
const _basename = basename(path);
|
|
49
49
|
if (!_basename) return "";
|
|
50
50
|
const components = _basename.split(".");
|
|
@@ -65,7 +65,7 @@ export function join(...args: string[]): string {
|
|
|
65
65
|
return part.trim().replace(/(^[/]*|[/]*$)/g, "");
|
|
66
66
|
}
|
|
67
67
|
})
|
|
68
|
-
.filter(x => x.length)
|
|
68
|
+
.filter((x) => x.length)
|
|
69
69
|
.join("/");
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -82,19 +82,19 @@ function _getAttributes(path: string): {
|
|
|
82
82
|
return attributesOfItemAtPath.jsValue();
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
export function getCreationDate(path: string): number{
|
|
85
|
+
export function getCreationDate(path: string): number {
|
|
86
86
|
const { NSFileCreationDate } = _getAttributes(path);
|
|
87
87
|
if (!NSFileCreationDate) return 0;
|
|
88
88
|
return NSFileCreationDate.getTime();
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export function getModificationDate(path: string): number{
|
|
91
|
+
export function getModificationDate(path: string): number {
|
|
92
92
|
const { NSFileModificationDate } = _getAttributes(path);
|
|
93
93
|
if (!NSFileModificationDate) return 0;
|
|
94
94
|
return NSFileModificationDate.getTime();
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
export function getFileSize(path: string): number{
|
|
97
|
+
export function getFileSize(path: string): number {
|
|
98
98
|
const { NSFileSize } = _getAttributes(path);
|
|
99
99
|
return NSFileSize || 0;
|
|
100
100
|
}
|
package/utils/rect.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// 用于处理矩形的工具函数
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* When called without arguments, return the center of the rectangle.
|
|
5
|
+
* When a Point is passed as an argument, the rectangle’s x and y values
|
|
6
|
+
* are adjusted, so that the new center of the rectangle is p.
|
|
7
|
+
*/
|
|
4
8
|
export function center(rect: JBRect, point?: JBPoint): JBPoint {
|
|
5
9
|
const { x = 0, y = 0, width: w, height: h } = rect;
|
|
6
10
|
if (!point) return $point(x + w / 2, y + h / 2);
|
|
@@ -10,28 +14,40 @@ export function center(rect: JBRect, point?: JBPoint): JBPoint {
|
|
|
10
14
|
return point;
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Return true if the given point lies within the bounds of the rectangle,
|
|
19
|
+
* false otherwise.
|
|
20
|
+
*/
|
|
14
21
|
export function containsPoint(rect: JBRect, point: JBPoint): boolean {
|
|
15
22
|
const { x, y, width: w, height: h } = rect;
|
|
16
23
|
const { x: px, y: py } = point;
|
|
17
24
|
return x <= px && px <= x + w && y <= py && py <= y + h;
|
|
18
25
|
}
|
|
19
26
|
|
|
20
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Return true if the given rectangle lies entirely within the bounds of
|
|
29
|
+
* this rectangle, false otherwise.
|
|
30
|
+
*/
|
|
21
31
|
export function containsRect(rect: JBRect, otherRect: JBRect): boolean {
|
|
22
32
|
const { x, y, width: w, height: h } = rect;
|
|
23
33
|
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
24
34
|
return x <= x1 && y <= y1 && x1 + w1 <= x + w && y1 + h1 <= y + h;
|
|
25
35
|
}
|
|
26
36
|
|
|
27
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Return true if this rectangle intersects with the other rectangle,
|
|
39
|
+
* false otherwise.
|
|
40
|
+
*/
|
|
28
41
|
export function intersects(rect: JBRect, otherRect: JBRect): boolean {
|
|
29
42
|
const { x, y, width: w, height: h } = rect;
|
|
30
43
|
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
31
44
|
return x < x1 + w1 && x1 < x + w && y < y1 + h1 && y1 < y + h;
|
|
32
45
|
}
|
|
33
46
|
|
|
34
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Return a $rect that corresponds to the intersection of this rectangle with
|
|
49
|
+
* the other one.
|
|
50
|
+
*/
|
|
35
51
|
export function intersection(rect: JBRect, otherRect: JBRect): JBRect {
|
|
36
52
|
const { x, y, width: w, height: h } = rect;
|
|
37
53
|
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
@@ -42,7 +58,9 @@ export function intersection(rect: JBRect, otherRect: JBRect): JBRect {
|
|
|
42
58
|
return $rect(nx, ny, nw, nh);
|
|
43
59
|
}
|
|
44
60
|
|
|
45
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Return the smallest $rect that encloses both rectangles.
|
|
63
|
+
*/
|
|
46
64
|
export function union(rect: JBRect, otherRect: JBRect): JBRect {
|
|
47
65
|
const { x, y, width: w, height: h } = rect;
|
|
48
66
|
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
@@ -52,14 +70,19 @@ export function union(rect: JBRect, otherRect: JBRect): JBRect {
|
|
|
52
70
|
const nh = Math.max(y + h, y1 + h1) - ny;
|
|
53
71
|
return $rect(nx, ny, nw, nh);
|
|
54
72
|
}
|
|
55
|
-
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Equivalent to $rect(r.x + x, r.y + y, r.w, r.h)
|
|
76
|
+
*/
|
|
56
77
|
export function translate(rect: JBRect, point: JBPoint): JBRect {
|
|
57
78
|
const { x, y, width, height } = rect;
|
|
58
79
|
const { x: x1, y: y1 } = point;
|
|
59
80
|
return $rect(x + x1, y + y1, width, height);
|
|
60
81
|
}
|
|
61
82
|
|
|
62
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Return a $rect that is adjusted by the given edge insets.
|
|
85
|
+
*/
|
|
63
86
|
export function inset(rect: JBRect, insets: JBInsets): JBRect {
|
|
64
87
|
const { x, y, width, height } = rect;
|
|
65
88
|
const { top, left, bottom, right } = insets;
|
package/utils/uitools.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
// 用于UI相关的工具函数
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* 立即获得window size
|
|
5
|
+
*/
|
|
4
6
|
export function getWindowSize(): JBSize {
|
|
5
7
|
const window = $objc("UIWindow").$keyWindow().jsValue();
|
|
6
8
|
return window.size;
|
|
7
9
|
}
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* 获取单行字符串应有的宽度
|
|
13
|
+
* 默认额外添加3 inset
|
|
14
|
+
*/
|
|
11
15
|
export function getTextWidth(
|
|
12
|
-
text: string,
|
|
16
|
+
text: string,
|
|
13
17
|
{ font = $font(17), inset = 3 } = {}
|
|
14
18
|
): number {
|
|
15
19
|
return (
|
|
@@ -18,17 +22,19 @@ export function getTextWidth(
|
|
|
18
22
|
text,
|
|
19
23
|
width: 10000,
|
|
20
24
|
font,
|
|
21
|
-
lineSpacing: 0
|
|
25
|
+
lineSpacing: 0,
|
|
22
26
|
}).width
|
|
23
27
|
) + inset
|
|
24
28
|
);
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
/**
|
|
32
|
+
* 获取字符串指定宽度后应有的高度
|
|
33
|
+
* 默认额外添加3 inset
|
|
34
|
+
*/
|
|
29
35
|
export function getTextHeight(
|
|
30
36
|
text: string,
|
|
31
|
-
{ width = 300, font = $font(17), inset = 3 } = {}
|
|
37
|
+
{ width = 300, font = $font(17), inset = 3, lineSpacing = 0 } = {}
|
|
32
38
|
): number {
|
|
33
39
|
return (
|
|
34
40
|
Math.ceil(
|
|
@@ -36,14 +42,16 @@ export function getTextHeight(
|
|
|
36
42
|
text,
|
|
37
43
|
width,
|
|
38
44
|
font,
|
|
39
|
-
lineSpacing
|
|
45
|
+
lineSpacing,
|
|
40
46
|
}).height
|
|
41
47
|
) + inset
|
|
42
48
|
);
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
/**
|
|
52
|
+
* 计算某个view在某个上级view(若不指定则为UIWindow)上的绝对frame
|
|
53
|
+
* 此方法不考虑旋转变形等特殊情况
|
|
54
|
+
*/
|
|
47
55
|
export function absoluteFrame(view: AllUIView, endView?: AllUIView): JBRect {
|
|
48
56
|
const frame = view.frame;
|
|
49
57
|
let superView = view.super;
|
|
@@ -62,40 +70,42 @@ export const layerCommonOptions = {
|
|
|
62
70
|
shadowRadius: 0,
|
|
63
71
|
shadowOpacity: 0,
|
|
64
72
|
shadowOffset: $size(0, 0),
|
|
65
|
-
shadowColor: $color("clear")
|
|
73
|
+
shadowColor: $color("clear"),
|
|
66
74
|
},
|
|
67
75
|
roundedShadow: {
|
|
68
76
|
cornerRadius: 12,
|
|
69
77
|
shadowRadius: 10,
|
|
70
78
|
shadowOpacity: 1,
|
|
71
79
|
shadowOffset: $size(0, 0),
|
|
72
|
-
shadowColor: $color("black")
|
|
80
|
+
shadowColor: $color("black"),
|
|
73
81
|
},
|
|
74
82
|
textShadow: {
|
|
75
83
|
cornerRadius: 0,
|
|
76
84
|
shadowRadius: 1.2,
|
|
77
85
|
shadowOpacity: 1,
|
|
78
86
|
shadowOffset: $size(0, 1),
|
|
79
|
-
shadowColor: $color("black")
|
|
87
|
+
shadowColor: $color("black"),
|
|
80
88
|
},
|
|
81
89
|
circleViewShadow: {
|
|
82
90
|
cornerRadius: 25,
|
|
83
91
|
shadowRadius: 3,
|
|
84
92
|
shadowOpacity: 0.6,
|
|
85
93
|
shadowOffset: $size(0, 3),
|
|
86
|
-
shadowColor: $color("black")
|
|
94
|
+
shadowColor: $color("black"),
|
|
87
95
|
},
|
|
88
96
|
toastShadows: {
|
|
89
97
|
cornerRadius: 15,
|
|
90
98
|
shadowRadius: 8,
|
|
91
99
|
shadowOpacity: 0.35,
|
|
92
100
|
shadowOffset: $size(0, 0),
|
|
93
|
-
shadowColor: $color("black")
|
|
94
|
-
}
|
|
101
|
+
shadowColor: $color("black"),
|
|
102
|
+
},
|
|
95
103
|
};
|
|
96
104
|
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
/**
|
|
106
|
+
* 在layout中使用
|
|
107
|
+
* 所应用的view不可以指定radius和clipTobounds,否则无效
|
|
108
|
+
*/
|
|
99
109
|
export function setLayer(
|
|
100
110
|
view: AllUIView,
|
|
101
111
|
{
|
|
@@ -103,7 +113,7 @@ export function setLayer(
|
|
|
103
113
|
shadowRadius = 0,
|
|
104
114
|
shadowOpacity = 0,
|
|
105
115
|
shadowOffset = $size(0, 0),
|
|
106
|
-
shadowColor = $color("clear")
|
|
116
|
+
shadowColor = $color("clear"),
|
|
107
117
|
} = {}
|
|
108
118
|
): void {
|
|
109
119
|
const layer = view.ocValue().invoke("layer");
|
|
@@ -113,5 +123,3 @@ export function setLayer(
|
|
|
113
123
|
layer.invoke("setShadowOffset", shadowOffset);
|
|
114
124
|
layer.invoke("setShadowColor", shadowColor.ocValue().invoke("CGColor"));
|
|
115
125
|
}
|
|
116
|
-
|
|
117
|
-
|