jsbox-cview 1.5.16 → 1.5.18
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/refresh-button.ts +82 -0
- package/components/symbol-button.ts +1 -2
- package/dist/components/refresh-button.js +71 -0
- package/dist/components/symbol-button.js +1 -2
- package/dist/index.js +1 -0
- package/dist/test/refresh-button.js +35 -0
- package/index.ts +1 -0
- package/package.json +1 -1
- package/test/refresh-button.ts +26 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Base } from "./base";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 创建一个刷新按钮,平时显示一个刷新的symbol,刷新时显示一个loading的symbol
|
|
5
|
+
* props:
|
|
6
|
+
* - tintColor
|
|
7
|
+
* - enabled
|
|
8
|
+
* - hidden
|
|
9
|
+
* events:
|
|
10
|
+
* - tapped
|
|
11
|
+
*/
|
|
12
|
+
export class RefreshButton extends Base<UIButtonView, UiTypes.ButtonOptions> {
|
|
13
|
+
_defineView: () => UiTypes.ButtonOptions;
|
|
14
|
+
_loading: boolean = false;
|
|
15
|
+
constructor({
|
|
16
|
+
props,
|
|
17
|
+
layout,
|
|
18
|
+
events = {}
|
|
19
|
+
}: {
|
|
20
|
+
props?: {
|
|
21
|
+
tintColor?: UIColor;
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
hidden?: boolean;
|
|
24
|
+
};
|
|
25
|
+
layout?: (make: MASConstraintMaker, view: UIButtonView) => void;
|
|
26
|
+
events?: UiTypes.BaseViewEvents<UIButtonView>;
|
|
27
|
+
}) {
|
|
28
|
+
super();
|
|
29
|
+
this._defineView = () => {
|
|
30
|
+
return {
|
|
31
|
+
type: "button",
|
|
32
|
+
props: {
|
|
33
|
+
id: this.id,
|
|
34
|
+
bgcolor: $color("clear"),
|
|
35
|
+
enabled: props?.enabled ?? true,
|
|
36
|
+
hidden: props?.hidden ?? false,
|
|
37
|
+
},
|
|
38
|
+
layout,
|
|
39
|
+
events,
|
|
40
|
+
views: [
|
|
41
|
+
{
|
|
42
|
+
type: "image",
|
|
43
|
+
props: {
|
|
44
|
+
id: this.id + "_image",
|
|
45
|
+
symbol: "arrow.clockwise",
|
|
46
|
+
tintColor: props?.tintColor ?? $color("primaryText"),
|
|
47
|
+
contentMode: 1,
|
|
48
|
+
hidden: this._loading,
|
|
49
|
+
},
|
|
50
|
+
layout: (make, view) => {
|
|
51
|
+
make.edges.insets($insets(12.5, 12.5, 12.5, 12.5));
|
|
52
|
+
make.center.equalTo(view.super);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: "spinner",
|
|
57
|
+
props: {
|
|
58
|
+
id: this.id + "_spinner",
|
|
59
|
+
loading: this._loading,
|
|
60
|
+
hidden: !this._loading,
|
|
61
|
+
},
|
|
62
|
+
layout: (make, view) => {
|
|
63
|
+
make.center.equalTo(view.super);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get loading() {
|
|
72
|
+
return this._loading;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
set loading(value: boolean) {
|
|
76
|
+
this._loading = value;
|
|
77
|
+
$(this.id + "_image").hidden = value;
|
|
78
|
+
$(this.id + "_spinner").hidden = !value;
|
|
79
|
+
($(this.id + "_spinner") as UISpinnerView).loading = value;
|
|
80
|
+
this.view.enabled = !value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -79,8 +79,7 @@ export class SymbolButton extends Base<UIButtonView, UiTypes.ButtonOptions> {
|
|
|
79
79
|
},
|
|
80
80
|
layout: (make, view: UIImageView) => {
|
|
81
81
|
make.edges.insets(this._props.insets);
|
|
82
|
-
make.
|
|
83
|
-
make.width.equalTo(view.height);
|
|
82
|
+
make.center.equalTo(view.super);
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
],
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RefreshButton = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
/**
|
|
6
|
+
* 创建一个刷新按钮,平时显示一个刷新的symbol,刷新时显示一个loading的symbol
|
|
7
|
+
* props:
|
|
8
|
+
* - tintColor
|
|
9
|
+
* - enabled
|
|
10
|
+
* - hidden
|
|
11
|
+
* events:
|
|
12
|
+
* - tapped
|
|
13
|
+
*/
|
|
14
|
+
class RefreshButton extends base_1.Base {
|
|
15
|
+
constructor({ props, layout, events = {} }) {
|
|
16
|
+
super();
|
|
17
|
+
this._loading = false;
|
|
18
|
+
this._defineView = () => {
|
|
19
|
+
var _a, _b, _c;
|
|
20
|
+
return {
|
|
21
|
+
type: "button",
|
|
22
|
+
props: {
|
|
23
|
+
id: this.id,
|
|
24
|
+
bgcolor: $color("clear"),
|
|
25
|
+
enabled: (_a = props === null || props === void 0 ? void 0 : props.enabled) !== null && _a !== void 0 ? _a : true,
|
|
26
|
+
hidden: (_b = props === null || props === void 0 ? void 0 : props.hidden) !== null && _b !== void 0 ? _b : false,
|
|
27
|
+
},
|
|
28
|
+
layout,
|
|
29
|
+
events,
|
|
30
|
+
views: [
|
|
31
|
+
{
|
|
32
|
+
type: "image",
|
|
33
|
+
props: {
|
|
34
|
+
id: this.id + "_image",
|
|
35
|
+
symbol: "arrow.clockwise",
|
|
36
|
+
tintColor: (_c = props === null || props === void 0 ? void 0 : props.tintColor) !== null && _c !== void 0 ? _c : $color("primaryText"),
|
|
37
|
+
contentMode: 1,
|
|
38
|
+
hidden: this._loading,
|
|
39
|
+
},
|
|
40
|
+
layout: (make, view) => {
|
|
41
|
+
make.edges.insets($insets(12.5, 12.5, 12.5, 12.5));
|
|
42
|
+
make.center.equalTo(view.super);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "spinner",
|
|
47
|
+
props: {
|
|
48
|
+
id: this.id + "_spinner",
|
|
49
|
+
loading: this._loading,
|
|
50
|
+
hidden: !this._loading,
|
|
51
|
+
},
|
|
52
|
+
layout: (make, view) => {
|
|
53
|
+
make.center.equalTo(view.super);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
get loading() {
|
|
61
|
+
return this._loading;
|
|
62
|
+
}
|
|
63
|
+
set loading(value) {
|
|
64
|
+
this._loading = value;
|
|
65
|
+
$(this.id + "_image").hidden = value;
|
|
66
|
+
$(this.id + "_spinner").hidden = !value;
|
|
67
|
+
$(this.id + "_spinner").loading = value;
|
|
68
|
+
this.view.enabled = !value;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.RefreshButton = RefreshButton;
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __exportStar(require("./components/image-pager"), exports);
|
|
|
26
26
|
__exportStar(require("./components/page-control"), exports);
|
|
27
27
|
__exportStar(require("./components/pageviewer-titlebar"), exports);
|
|
28
28
|
__exportStar(require("./components/pageviewer"), exports);
|
|
29
|
+
__exportStar(require("./components/refresh-button"), exports);
|
|
29
30
|
__exportStar(require("./components/rotating-view"), exports);
|
|
30
31
|
__exportStar(require("./components/searchbar"), exports);
|
|
31
32
|
__exportStar(require("./components/sheet"), exports);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const refresh_button_1 = require("../components/refresh-button");
|
|
13
|
+
const refreshButton = new refresh_button_1.RefreshButton({
|
|
14
|
+
props: {
|
|
15
|
+
tintColor: $color("primaryText"),
|
|
16
|
+
enabled: true,
|
|
17
|
+
hidden: false
|
|
18
|
+
},
|
|
19
|
+
layout: (make, view) => {
|
|
20
|
+
make.width.equalTo(50);
|
|
21
|
+
make.height.equalTo(50);
|
|
22
|
+
make.top.inset(100);
|
|
23
|
+
make.centerX.equalTo(view.super);
|
|
24
|
+
},
|
|
25
|
+
events: {
|
|
26
|
+
tapped: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
refreshButton.loading = true;
|
|
28
|
+
yield $wait(2);
|
|
29
|
+
refreshButton.loading = false;
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
$ui.render({
|
|
34
|
+
views: [refreshButton.definition]
|
|
35
|
+
});
|
package/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './components/image-pager';
|
|
|
10
10
|
export * from './components/page-control';
|
|
11
11
|
export * from './components/pageviewer-titlebar';
|
|
12
12
|
export * from './components/pageviewer';
|
|
13
|
+
export * from './components/refresh-button';
|
|
13
14
|
export * from './components/rotating-view';
|
|
14
15
|
export * from './components/searchbar';
|
|
15
16
|
export * from './components/sheet';
|
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RefreshButton } from "../components/refresh-button";
|
|
2
|
+
|
|
3
|
+
const refreshButton = new RefreshButton({
|
|
4
|
+
props: {
|
|
5
|
+
tintColor: $color("primaryText"),
|
|
6
|
+
enabled: true,
|
|
7
|
+
hidden: false
|
|
8
|
+
},
|
|
9
|
+
layout: (make, view) => {
|
|
10
|
+
make.width.equalTo(50);
|
|
11
|
+
make.height.equalTo(50);
|
|
12
|
+
make.top.inset(100);
|
|
13
|
+
make.centerX.equalTo(view.super);
|
|
14
|
+
},
|
|
15
|
+
events: {
|
|
16
|
+
tapped: async () => {
|
|
17
|
+
refreshButton.loading = true;
|
|
18
|
+
await $wait(2);
|
|
19
|
+
refreshButton.loading = false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
$ui.render({
|
|
25
|
+
views: [refreshButton.definition]
|
|
26
|
+
});
|