jsbox-cview 1.0.0 → 1.1.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/dist/components/alert/input-alert.js +39 -0
- package/dist/components/alert/login-alert.js +45 -0
- package/dist/components/alert/plain-alert.js +25 -0
- package/dist/components/alert/uialert.js +89 -0
- package/dist/components/artificial-flowlayout.js +258 -0
- package/dist/components/base.js +43 -0
- package/dist/components/custom-navigation-bar.js +519 -0
- package/dist/components/dialogs/dialog-sheet.js +67 -0
- package/dist/components/dialogs/form-dialog.js +24 -0
- package/dist/components/dialogs/list-dialog.js +87 -0
- package/dist/components/dialogs/text-dialog.js +31 -0
- package/dist/components/dynamic-itemsize-matrix.js +129 -0
- package/dist/components/dynamic-preference-listview.js +557 -0
- package/dist/components/dynamic-rowheight-list.js +44 -0
- package/dist/components/enhanced-imageview.js +114 -0
- package/dist/components/image-pager.js +157 -0
- package/dist/components/page-control.js +76 -0
- package/dist/components/pageviewer-titlebar.js +143 -0
- package/dist/components/pageviewer.js +96 -0
- package/dist/components/rotating-view.js +102 -0
- package/dist/components/searchbar.js +322 -0
- package/dist/components/sheet.js +82 -0
- package/dist/components/single-views.js +429 -0
- package/dist/components/spinners/loading-double-rings.js +104 -0
- package/dist/components/spinners/loading-dual-ring.js +82 -0
- package/dist/components/spinners/loading-wedges.js +104 -0
- package/dist/components/spinners/spinner-androidstyle.js +248 -0
- package/dist/components/static-preference-listview.js +798 -0
- package/dist/components/symbol-button.js +79 -0
- package/dist/components/tabbar.js +357 -0
- package/dist/controller/base-controller.js +178 -0
- package/dist/controller/controller-router.js +68 -0
- package/dist/controller/pageviewer-controller.js +63 -0
- package/dist/controller/presented-page-controller.js +48 -0
- package/dist/controller/splitview-controller.js +252 -0
- package/dist/controller/tabbar-controller.js +74 -0
- package/dist/index.js +58 -0
- package/dist/test.js +1 -0
- package/dist/utils/colors.js +15 -0
- package/dist/utils/cvid.js +28 -0
- package/dist/utils/l10n.js +44 -0
- package/dist/utils/path.js +107 -0
- package/dist/utils/rect.js +72 -0
- package/dist/utils/uitools.js +95 -0
- package/index.ts +42 -0
- package/package.json +4 -3
- package/tsconfig.json +5 -3
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* # CView SearchBar
|
|
4
|
+
*
|
|
5
|
+
* props
|
|
6
|
+
*
|
|
7
|
+
* - 读写 text: string
|
|
8
|
+
* - style: number 搜索框的样式
|
|
9
|
+
* - 0: 取消按钮在输入框内,聚焦时显示取消按钮
|
|
10
|
+
* - 1: 取消按钮在输入框右侧,聚焦时会有左右移动的动画
|
|
11
|
+
* - 2: 取消按钮布局同 1,但是 placeholder 平时显示在中间,聚焦时才会移动到左边。
|
|
12
|
+
* 如果使用此样式,建议每次 blur 的时候都清除 text
|
|
13
|
+
* - accessoryCview: cview 请通过下面的事件来和 SearchBar 互相操作
|
|
14
|
+
* - placeholder: string
|
|
15
|
+
* - cancelText: string
|
|
16
|
+
* - tintColor: \$color("systemLink")
|
|
17
|
+
* - bgcolor: colors.searchBarBgcolor
|
|
18
|
+
*
|
|
19
|
+
* events
|
|
20
|
+
*
|
|
21
|
+
* - didBeginEditing: cview => void
|
|
22
|
+
* - didEndEditing: cview => void
|
|
23
|
+
* - changed: cview => void
|
|
24
|
+
* - returned: cview => void
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.SearchBar = void 0;
|
|
28
|
+
const base_1 = require("./base");
|
|
29
|
+
const single_views_1 = require("./single-views");
|
|
30
|
+
const colors_1 = require("../utils/colors");
|
|
31
|
+
const l10n_1 = require("../utils/l10n");
|
|
32
|
+
const uitools_1 = require("../utils/uitools");
|
|
33
|
+
class SearchBar extends base_1.Base {
|
|
34
|
+
constructor({ props, layout, events = {} }) {
|
|
35
|
+
super();
|
|
36
|
+
this._props = Object.assign({ placeholder: (0, l10n_1.l10n)("SEARCH"), cancelText: (0, l10n_1.l10n)("CANCEL"), tintColor: $color("systemLink"), bgcolor: colors_1.searchBarBgcolor, style: 0 }, props);
|
|
37
|
+
const cancelButtonWidth = (0, uitools_1.getTextWidth)(this._props.cancelText, {
|
|
38
|
+
inset: 20
|
|
39
|
+
});
|
|
40
|
+
const placeholderWidth = (0, uitools_1.getTextWidth)(this._props.cancelText, {
|
|
41
|
+
inset: 20
|
|
42
|
+
});
|
|
43
|
+
this._focused = false;
|
|
44
|
+
this._layouts = this._defineLayouts(cancelButtonWidth, placeholderWidth);
|
|
45
|
+
this.cviews = {};
|
|
46
|
+
this.cviews.input = new single_views_1.Input({
|
|
47
|
+
props: {
|
|
48
|
+
type: $kbType.search,
|
|
49
|
+
placeholder: this._props.placeholder,
|
|
50
|
+
bgcolor: $color("clear"),
|
|
51
|
+
radius: 0,
|
|
52
|
+
accessoryView: this._props.accessoryCview && this._props.accessoryCview.definition
|
|
53
|
+
},
|
|
54
|
+
layout: (make, view) => {
|
|
55
|
+
make.left.equalTo(view.prev.right);
|
|
56
|
+
make.top.bottom.right.inset(0);
|
|
57
|
+
},
|
|
58
|
+
events: {
|
|
59
|
+
changed: sender => {
|
|
60
|
+
if (events.changed)
|
|
61
|
+
events.changed(this);
|
|
62
|
+
},
|
|
63
|
+
didBeginEditing: sender => {
|
|
64
|
+
this._onFocused();
|
|
65
|
+
if (events.didBeginEditing)
|
|
66
|
+
events.didBeginEditing(this);
|
|
67
|
+
},
|
|
68
|
+
didEndEditing: sender => {
|
|
69
|
+
if (events.didEndEditing)
|
|
70
|
+
events.didEndEditing(this);
|
|
71
|
+
},
|
|
72
|
+
returned: sender => {
|
|
73
|
+
this.blur();
|
|
74
|
+
if (events.returned)
|
|
75
|
+
events.returned(this);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
this.cviews.iconInput = new single_views_1.ContentView({
|
|
80
|
+
props: {
|
|
81
|
+
bgcolor: undefined
|
|
82
|
+
},
|
|
83
|
+
layout: this._layouts.iconInput.normal,
|
|
84
|
+
views: [
|
|
85
|
+
{
|
|
86
|
+
type: "view",
|
|
87
|
+
props: {},
|
|
88
|
+
views: [
|
|
89
|
+
{
|
|
90
|
+
type: "image",
|
|
91
|
+
props: {
|
|
92
|
+
//tintColor: searchBarSymbolColor,
|
|
93
|
+
tintColor: $color("systemPlaceholderText"),
|
|
94
|
+
symbol: "magnifyingglass"
|
|
95
|
+
},
|
|
96
|
+
layout: (make, view) => {
|
|
97
|
+
make.size.equalTo($size(20, 20));
|
|
98
|
+
make.center.equalTo(view.super);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
layout: (make, view) => {
|
|
103
|
+
make.top.bottom.inset(0);
|
|
104
|
+
make.width.equalTo(20);
|
|
105
|
+
make.left.inset(6);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
this.cviews.input.definition
|
|
109
|
+
]
|
|
110
|
+
});
|
|
111
|
+
this.cviews.cancelButton = new single_views_1.Label({
|
|
112
|
+
props: {
|
|
113
|
+
text: this._props.cancelText,
|
|
114
|
+
textColor: this._props.tintColor,
|
|
115
|
+
font: $font(17),
|
|
116
|
+
align: $align.center,
|
|
117
|
+
userInteractionEnabled: true,
|
|
118
|
+
alpha: 0
|
|
119
|
+
},
|
|
120
|
+
layout: this._layouts.cancelButton.normal,
|
|
121
|
+
events: {
|
|
122
|
+
tapped: sender => this.blur()
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
this.cviews.bgview = new single_views_1.ContentView({
|
|
126
|
+
props: {
|
|
127
|
+
bgcolor: this._props.bgcolor,
|
|
128
|
+
radius: 8,
|
|
129
|
+
userInteractionEnabled: true
|
|
130
|
+
},
|
|
131
|
+
layout: this._layouts.bgview.normal,
|
|
132
|
+
events: {
|
|
133
|
+
tapped: sender => {
|
|
134
|
+
if (!this._focused)
|
|
135
|
+
this.focus();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
this._defineView = () => {
|
|
140
|
+
return {
|
|
141
|
+
type: "view",
|
|
142
|
+
props: {
|
|
143
|
+
id: this.id,
|
|
144
|
+
clipsToBounds: true
|
|
145
|
+
},
|
|
146
|
+
layout,
|
|
147
|
+
views: [
|
|
148
|
+
this.cviews.bgview.definition,
|
|
149
|
+
this.cviews.iconInput.definition,
|
|
150
|
+
this.cviews.cancelButton.definition
|
|
151
|
+
]
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
_defineLayouts(cancelButtonWidth, placeholderWidth) {
|
|
156
|
+
switch (this._props.style) {
|
|
157
|
+
case 0: {
|
|
158
|
+
const IconInputLayout = $layout.fill;
|
|
159
|
+
const cancelButtonLayout = (make, view) => {
|
|
160
|
+
make.right.top.bottom.inset(0);
|
|
161
|
+
make.width.equalTo(cancelButtonWidth);
|
|
162
|
+
};
|
|
163
|
+
const bgviewLayout = $layout.fill;
|
|
164
|
+
return {
|
|
165
|
+
iconInput: { normal: IconInputLayout },
|
|
166
|
+
cancelButton: { normal: cancelButtonLayout },
|
|
167
|
+
bgview: { normal: bgviewLayout }
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
case 1: {
|
|
171
|
+
const IconInputLayout = (make, view) => {
|
|
172
|
+
make.left.top.bottom.inset(0);
|
|
173
|
+
make.right.inset(cancelButtonWidth);
|
|
174
|
+
};
|
|
175
|
+
const cancelButtonLayout = (make, view) => {
|
|
176
|
+
make.top.bottom.inset(0);
|
|
177
|
+
make.left.equalTo(view.prev.prev.right);
|
|
178
|
+
make.width.equalTo(cancelButtonWidth);
|
|
179
|
+
};
|
|
180
|
+
const bgviewLayoutNormal = $layout.fill;
|
|
181
|
+
const bgviewLayoutFocused = (make, view) => {
|
|
182
|
+
make.left.top.bottom.inset(0);
|
|
183
|
+
make.right.inset(cancelButtonWidth);
|
|
184
|
+
};
|
|
185
|
+
return {
|
|
186
|
+
iconInput: { normal: IconInputLayout },
|
|
187
|
+
cancelButton: { normal: cancelButtonLayout },
|
|
188
|
+
bgview: { normal: bgviewLayoutNormal, focused: bgviewLayoutFocused }
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
case 2: {
|
|
192
|
+
const IconInputLayoutNormal = (make, view) => {
|
|
193
|
+
make.center.equalTo(view.super);
|
|
194
|
+
make.top.bottom.inset(0);
|
|
195
|
+
make.width.equalTo(placeholderWidth + 50);
|
|
196
|
+
};
|
|
197
|
+
const IconInputLayoutFocused = (make, view) => {
|
|
198
|
+
make.left.top.bottom.inset(0);
|
|
199
|
+
make.right.inset(cancelButtonWidth);
|
|
200
|
+
};
|
|
201
|
+
const cancelButtonLayout = (make, view) => {
|
|
202
|
+
make.right.top.bottom.inset(0);
|
|
203
|
+
make.left.equalTo(view.prev.prev.right);
|
|
204
|
+
make.width.equalTo(cancelButtonWidth);
|
|
205
|
+
};
|
|
206
|
+
const bgviewLayoutNormal = $layout.fill;
|
|
207
|
+
const bgviewLayoutFocused = (make, view) => {
|
|
208
|
+
make.left.top.bottom.inset(0);
|
|
209
|
+
make.right.inset(cancelButtonWidth);
|
|
210
|
+
};
|
|
211
|
+
return {
|
|
212
|
+
iconInput: {
|
|
213
|
+
normal: IconInputLayoutNormal,
|
|
214
|
+
focused: IconInputLayoutFocused
|
|
215
|
+
},
|
|
216
|
+
cancelButton: { normal: cancelButtonLayout },
|
|
217
|
+
bgview: { normal: bgviewLayoutNormal, focused: bgviewLayoutFocused }
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
default:
|
|
221
|
+
throw new Error("style not supported");
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
_onFocused() {
|
|
225
|
+
this._focused = true;
|
|
226
|
+
switch (this._props.style) {
|
|
227
|
+
case 0: {
|
|
228
|
+
$ui.animate({
|
|
229
|
+
duration: 0.2,
|
|
230
|
+
animation: () => {
|
|
231
|
+
this.cviews.cancelButton.view.alpha = 1;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
case 1: {
|
|
237
|
+
if (this._layouts.bgview.focused)
|
|
238
|
+
this.cviews.bgview.view.remakeLayout(this._layouts.bgview.focused);
|
|
239
|
+
$ui.animate({
|
|
240
|
+
duration: 0.2,
|
|
241
|
+
animation: () => {
|
|
242
|
+
this.cviews.bgview.view.relayout();
|
|
243
|
+
this.cviews.cancelButton.view.alpha = 1;
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
case 2: {
|
|
249
|
+
if (this._layouts.iconInput.focused)
|
|
250
|
+
this.cviews.iconInput.view.remakeLayout(this._layouts.iconInput.focused);
|
|
251
|
+
if (this._layouts.bgview.focused)
|
|
252
|
+
this.cviews.bgview.view.remakeLayout(this._layouts.bgview.focused);
|
|
253
|
+
$ui.animate({
|
|
254
|
+
duration: 0.2,
|
|
255
|
+
animation: () => {
|
|
256
|
+
this.cviews.iconInput.view.relayout();
|
|
257
|
+
this.cviews.bgview.view.relayout();
|
|
258
|
+
this.cviews.cancelButton.view.alpha = 1;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
default:
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
_onBlurred() {
|
|
268
|
+
this._focused = false;
|
|
269
|
+
switch (this._props.style) {
|
|
270
|
+
case 0: {
|
|
271
|
+
$ui.animate({
|
|
272
|
+
duration: 0.2,
|
|
273
|
+
animation: () => {
|
|
274
|
+
this.cviews.cancelButton.view.alpha = 0;
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
case 1: {
|
|
280
|
+
this.cviews.bgview.view.remakeLayout(this._layouts.bgview.normal);
|
|
281
|
+
$ui.animate({
|
|
282
|
+
duration: 0.2,
|
|
283
|
+
animation: () => {
|
|
284
|
+
this.cviews.bgview.view.relayout();
|
|
285
|
+
this.cviews.cancelButton.view.alpha = 0;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
case 2: {
|
|
291
|
+
this.cviews.iconInput.view.remakeLayout(this._layouts.iconInput.normal);
|
|
292
|
+
this.cviews.bgview.view.remakeLayout(this._layouts.bgview.normal);
|
|
293
|
+
$ui.animate({
|
|
294
|
+
duration: 0.2,
|
|
295
|
+
animation: () => {
|
|
296
|
+
this.cviews.iconInput.view.relayout();
|
|
297
|
+
this.cviews.bgview.view.relayout();
|
|
298
|
+
this.cviews.cancelButton.view.alpha = 0;
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
default:
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
focus() {
|
|
308
|
+
this.cviews.input.view.focus();
|
|
309
|
+
this._onFocused();
|
|
310
|
+
}
|
|
311
|
+
blur() {
|
|
312
|
+
this._onBlurred();
|
|
313
|
+
this.cviews.input.view.blur();
|
|
314
|
+
}
|
|
315
|
+
set text(text) {
|
|
316
|
+
this.cviews.input.view.text = text;
|
|
317
|
+
}
|
|
318
|
+
get text() {
|
|
319
|
+
return this.cviews.input.view.text;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
exports.SearchBar = SearchBar;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Sheet = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* # cview Sheet
|
|
6
|
+
*
|
|
7
|
+
* 创建新的 UIViewController,主要用于 formSheet 和 pageSheet
|
|
8
|
+
*
|
|
9
|
+
* ## 参数:
|
|
10
|
+
* - presentMode: number, default: 1, pageSheet: 1, formSheet: 2
|
|
11
|
+
* - animated: boolean = true 是否启用动画效果
|
|
12
|
+
* - interactiveDismissalDisabled: boolean = false 是否禁用下拉退出
|
|
13
|
+
* - bgcolor: $color $color("secondarySurface")
|
|
14
|
+
* - cview: Cview
|
|
15
|
+
* - dismissalHandler: function 退出时的回调
|
|
16
|
+
*
|
|
17
|
+
* ## 方法:
|
|
18
|
+
* - present()
|
|
19
|
+
* - dismiss()
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
const cvid_1 = require("../utils/cvid");
|
|
23
|
+
const UIModalPresentationStyle = {
|
|
24
|
+
automatic: -2,
|
|
25
|
+
pageSheet: 1,
|
|
26
|
+
formSheet: 2,
|
|
27
|
+
fullScreen: 0,
|
|
28
|
+
currentContext: 3,
|
|
29
|
+
custom: 4,
|
|
30
|
+
overFullScreen: 5,
|
|
31
|
+
overCurrentContext: 6,
|
|
32
|
+
popover: 7,
|
|
33
|
+
none: -1
|
|
34
|
+
};
|
|
35
|
+
class Sheet {
|
|
36
|
+
constructor({ presentMode = UIModalPresentationStyle.pageSheet, animated = true, interactiveDismissalDisabled = false, bgcolor = $color("secondarySurface"), cview, dismissalHandler }) {
|
|
37
|
+
this._animated = animated;
|
|
38
|
+
this._presentMode = presentMode;
|
|
39
|
+
this._interactiveDismissalDisabled = interactiveDismissalDisabled;
|
|
40
|
+
this._bgcolor = bgcolor;
|
|
41
|
+
this._cview = cview;
|
|
42
|
+
this._dismissalHandler = dismissalHandler;
|
|
43
|
+
this.id = cvid_1.cvid.newId;
|
|
44
|
+
}
|
|
45
|
+
_create() {
|
|
46
|
+
this._define();
|
|
47
|
+
this._PSViewController = $objc(this.id).invoke("alloc.init");
|
|
48
|
+
this._PSViewControllerView = this._PSViewController.$view();
|
|
49
|
+
this._PSViewControllerView.$setBackgroundColor(this._bgcolor);
|
|
50
|
+
this._PSViewController.$setModalPresentationStyle(this._presentMode);
|
|
51
|
+
if (this._interactiveDismissalDisabled)
|
|
52
|
+
this._PSViewController.$setModalInPresentation(true);
|
|
53
|
+
if (this._cview)
|
|
54
|
+
this._add(this._cview);
|
|
55
|
+
}
|
|
56
|
+
_define() {
|
|
57
|
+
$define({
|
|
58
|
+
type: this.id + ": UIViewController",
|
|
59
|
+
events: {
|
|
60
|
+
"viewDidDisappear:": () => {
|
|
61
|
+
if (this._dismissalHandler)
|
|
62
|
+
this._dismissalHandler();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
_add(cview) {
|
|
68
|
+
const definition = cview.definition;
|
|
69
|
+
definition.layout = $layout.fill;
|
|
70
|
+
this._PSViewControllerView.jsValue().add(definition);
|
|
71
|
+
}
|
|
72
|
+
present() {
|
|
73
|
+
this._create();
|
|
74
|
+
$ui.controller
|
|
75
|
+
.ocValue()
|
|
76
|
+
.invoke("presentModalViewController:animated", this._PSViewController, this._animated);
|
|
77
|
+
}
|
|
78
|
+
dismiss() {
|
|
79
|
+
this._PSViewController.invoke("dismissModalViewControllerAnimated", true);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.Sheet = Sheet;
|