jsbox-cview 1.6.4 → 1.6.6
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/dynamic-itemsize-section-matrix.ts +363 -0
- package/components/oc-webview.ts +50 -0
- package/dist/components/alert/input-alert.js +1 -2
- package/dist/components/alert/login-alert.js +1 -2
- package/dist/components/alert/plain-alert.js +1 -2
- package/dist/components/custom-navigation-bar.js +7 -1
- package/dist/components/dialogs/form-dialog.js +1 -2
- package/dist/components/dialogs/list-dialog.js +1 -2
- package/dist/components/dialogs/text-dialog.js +1 -2
- package/dist/components/dynamic-contextmenu-view.js +5 -1
- package/dist/components/dynamic-itemsize-matrix.js +17 -15
- package/dist/components/dynamic-itemsize-section-matrix.js +293 -0
- package/dist/components/dynamic-preference-listview.js +25 -16
- package/dist/components/dynamic-rowheight-list.js +10 -3
- package/dist/components/enhanced-imageview.js +1 -1
- package/dist/components/flowlayout.js +10 -13
- package/dist/components/image-pager.js +6 -1
- package/dist/components/oc-webview.js +37 -0
- package/dist/components/page-control.js +2 -13
- package/dist/components/pageviewer-titlebar.js +7 -13
- package/dist/components/pageviewer.js +4 -1
- package/dist/components/refresh-button.js +3 -4
- package/dist/components/rotating-view.js +10 -2
- package/dist/components/searchbar.js +8 -1
- package/dist/components/single-views.js +11 -4
- package/dist/components/spinners/loading-dual-ring.js +3 -12
- package/dist/components/spinners/loading-wedges.js +3 -12
- package/dist/components/spinners/spinner-androidstyle.js +7 -1
- package/dist/components/static-preference-listview.js +13 -10
- package/dist/components/symbol-button.js +8 -1
- package/dist/components/tabbar.js +8 -1
- package/dist/controller/pageviewer-controller.js +4 -1
- package/dist/controller/presented-page-controller.js +7 -9
- package/dist/controller/splitview-controller.js +23 -11
- package/dist/controller/tabbar-controller.js +13 -14
- package/dist/index.js +1 -0
- package/dist/test/dialog-sheet.js +3 -12
- package/dist/test/dynamic-itemsize-section-matrix.js +138 -0
- package/dist/test/form-dialog.js +3 -12
- package/dist/test/oc-webview.js +195 -0
- package/dist/test/refresh-button.js +3 -12
- package/dist/utils/l10n.js +1 -2
- package/dist/utils/path.js +8 -9
- package/dist/utils/rect.js +8 -9
- package/dist/utils/uitools.js +6 -6
- package/index.ts +1 -0
- package/package.json +4 -3
- package/test/dynamic-itemsize-section-matrix.ts +142 -0
- package/test/oc-webview.ts +197 -0
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { getTextHeight } from "../utils/uitools";
|
|
2
|
+
import { Base } from "./base";
|
|
3
|
+
import { Matrix } from "./single-views";
|
|
4
|
+
|
|
5
|
+
export interface DynamicItemSizeSectionMatrixSection {
|
|
6
|
+
title: string;
|
|
7
|
+
items: Record<string, unknown>[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface DynamicItemSizeSectionMatrixProps extends Omit<
|
|
11
|
+
UiTypes.MatrixProps,
|
|
12
|
+
"data" | "itemSize" | "autoItemSize" | "estimatedItemSize" | "columns" | "square" | "waterfall" | "reorder" | "menu"
|
|
13
|
+
> {
|
|
14
|
+
data?: DynamicItemSizeSectionMatrixSection[];
|
|
15
|
+
fixedItemHeight?: number;
|
|
16
|
+
minItemWidth?: number;
|
|
17
|
+
maxColumns?: number;
|
|
18
|
+
spacing?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface DynamicItemSizeSectionMatrixEvents extends Omit<
|
|
22
|
+
UiTypes.MatrixEvents,
|
|
23
|
+
"itemSize" | "reorderBegan" | "reorderMoved" | "canMoveItem" | "reorderFinished"
|
|
24
|
+
> {
|
|
25
|
+
itemHeight?: (width: number) => number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _getColumnsAndItemSizeWidth(
|
|
29
|
+
containerWidth: number,
|
|
30
|
+
minItemWidth: number,
|
|
31
|
+
maxColumns: number,
|
|
32
|
+
spacing: number,
|
|
33
|
+
) {
|
|
34
|
+
if (minItemWidth > containerWidth - 2 * spacing) {
|
|
35
|
+
return {
|
|
36
|
+
columns: 1,
|
|
37
|
+
itemSizeWidth: containerWidth - 2 * spacing,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const columns = Math.max(
|
|
41
|
+
Math.min(Math.floor((containerWidth - spacing) / (minItemWidth + spacing)), maxColumns),
|
|
42
|
+
1, // 最少一列
|
|
43
|
+
);
|
|
44
|
+
const itemSizeWidth = Math.max(
|
|
45
|
+
Math.floor((containerWidth - spacing * (columns + 1)) / columns),
|
|
46
|
+
minItemWidth, // 最小宽度
|
|
47
|
+
);
|
|
48
|
+
return {
|
|
49
|
+
columns,
|
|
50
|
+
itemSizeWidth,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function _getTextHeight(text: string, width: number) {
|
|
55
|
+
return getTextHeight(text, {
|
|
56
|
+
width,
|
|
57
|
+
font: $font(13),
|
|
58
|
+
inset: 0,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* # CView Dynamic ItemSize Section Matrix
|
|
64
|
+
*
|
|
65
|
+
* 此组件是为了在 Dynamic ItemSize Matrix 的基础上添加 SectionTitle
|
|
66
|
+
*
|
|
67
|
+
* - 使用此组件必须在每个section中添加title,如果title为空字符串,依然添加高度35的空格(包含spacing)
|
|
68
|
+
* - sectionTitle的字体为font(13),左右边距为16(不含spacing),即总宽度为 totalWidth - 2 * spacing - 32
|
|
69
|
+
* - 由于它必然和底下的item会有spacing,所以不建议spacing设的太大,那样会很违和
|
|
70
|
+
* - sectionTitle会使得section之间的间隔增加自身的高度
|
|
71
|
+
* - matrix事件会自动调整indexPath,包括didSelect、didLongPress、forEachItem
|
|
72
|
+
* - matrix的方法都在该组件中重新实现,自动调整indexPath
|
|
73
|
+
* - 不支持matrix原有的重新排序、自动大小功能,为防止sectionTitle暴露,也不支持menu
|
|
74
|
+
* - 不支持Dynamic ItemSize Matrix的dynamicHeightEnabled、heightToWidth
|
|
75
|
+
*
|
|
76
|
+
* ## 动态调整 itemSize
|
|
77
|
+
*
|
|
78
|
+
* 动态的改变自己的 itemSize,从而使得 spacing 被优先满足。
|
|
79
|
+
* 思路为在 matrix 上层套一个 superView,在旋转的时候 superView 会调用 matrix.relayout()
|
|
80
|
+
* 和 matrix.reload(),从而触发 itemSize 事件
|
|
81
|
+
*
|
|
82
|
+
* 其排布逻辑是这样的:
|
|
83
|
+
*
|
|
84
|
+
* 1. 由 minItemWidth,spacing,maxColumns 这三个参数决定 cloumns,
|
|
85
|
+
* 并结合 totalWidth 确定 itemSize.width
|
|
86
|
+
* 2. 确定 itemHeight 有两种方法:
|
|
87
|
+
* - fixedItemHeight 固定高度,优先级第二
|
|
88
|
+
* - event: itemHeight(width) => height 通过 width 动态计算,优先级最高
|
|
89
|
+
* 3. 如果 minItemWidth 比 totalWidth - 2 * spacing 还要小,那么 itemSize.width
|
|
90
|
+
* 会被设定为 totalWidth - 2 * spacing,以保证item不会超出边框
|
|
91
|
+
*
|
|
92
|
+
* ## props:
|
|
93
|
+
*
|
|
94
|
+
* 可以使用 matrix 的全部属性。
|
|
95
|
+
*
|
|
96
|
+
* 但data的类型调整为:
|
|
97
|
+
* { title: string; items: Record<string, unknown>[] }
|
|
98
|
+
*
|
|
99
|
+
* 特殊属性:
|
|
100
|
+
*
|
|
101
|
+
* - fixedItemHeight 固定 itemSize 高度
|
|
102
|
+
* - minItemWidth 最小的 itemSize 宽度
|
|
103
|
+
* - maxColumns 最大列数
|
|
104
|
+
* - spacing
|
|
105
|
+
*
|
|
106
|
+
* events:
|
|
107
|
+
*
|
|
108
|
+
* 可以使用 matrix 除 itemSize 以外的全部事件
|
|
109
|
+
*
|
|
110
|
+
* 其他特殊事件:
|
|
111
|
+
*
|
|
112
|
+
* - itemHeight: width => height 通过 itemWidth 动态计算 itemHeight
|
|
113
|
+
*
|
|
114
|
+
*
|
|
115
|
+
* 方法:
|
|
116
|
+
* - get data
|
|
117
|
+
* - set data
|
|
118
|
+
* - reload(): void;
|
|
119
|
+
* - object(indexPath: NSIndexPath): any;
|
|
120
|
+
* - insert(args: { indexPath: NSIndexPath;value: any; } ): void;
|
|
121
|
+
* - delete(indexPathOrIndex: NSIndexPath | number): void;
|
|
122
|
+
* - cell(indexPath: NSIndexPath): AllUIView;
|
|
123
|
+
* - scrollTo(args: { indexPath: NSIndexPath; animated?: boolean }): void;
|
|
124
|
+
*/
|
|
125
|
+
export class DynamicItemSizeSectionMatrix extends Base<UIView, UiTypes.ViewOptions> {
|
|
126
|
+
_defineView: () => UiTypes.ViewOptions;
|
|
127
|
+
private _props: DynamicItemSizeSectionMatrixProps;
|
|
128
|
+
private _data: DynamicItemSizeSectionMatrixSection[];
|
|
129
|
+
private _events: DynamicItemSizeSectionMatrixEvents;
|
|
130
|
+
private _itemSizeWidth: number;
|
|
131
|
+
private _itemSizeHeight: number;
|
|
132
|
+
private _totalWidth: number = 0;
|
|
133
|
+
private _columns: number = 1;
|
|
134
|
+
private _fixedItemHeight: number;
|
|
135
|
+
private _minItemWidth: number;
|
|
136
|
+
private _maxColumns: number;
|
|
137
|
+
private _spacing: number;
|
|
138
|
+
matrix: Matrix;
|
|
139
|
+
constructor({
|
|
140
|
+
props,
|
|
141
|
+
layout,
|
|
142
|
+
events,
|
|
143
|
+
}: {
|
|
144
|
+
props: DynamicItemSizeSectionMatrixProps;
|
|
145
|
+
layout: (make: MASConstraintMaker, view: UIView) => void;
|
|
146
|
+
events: DynamicItemSizeSectionMatrixEvents;
|
|
147
|
+
}) {
|
|
148
|
+
super();
|
|
149
|
+
this._props = props;
|
|
150
|
+
this._data = this._props.data ?? [];
|
|
151
|
+
this._events = events;
|
|
152
|
+
this._itemSizeWidth = 0;
|
|
153
|
+
this._itemSizeHeight = 0;
|
|
154
|
+
this._fixedItemHeight = this._props.fixedItemHeight ?? 96;
|
|
155
|
+
this._minItemWidth = this._props.minItemWidth ?? 96;
|
|
156
|
+
this._maxColumns = this._props.maxColumns ?? 5;
|
|
157
|
+
this._spacing = this._props.spacing ?? 6;
|
|
158
|
+
const { itemHeight, didSelect, didLongPress, forEachItem, ...otherEvents } = this._events;
|
|
159
|
+
this.matrix = new Matrix({
|
|
160
|
+
props: {
|
|
161
|
+
...props,
|
|
162
|
+
data: this._mapData(this._data),
|
|
163
|
+
template: this._mapTemplate(props.template),
|
|
164
|
+
},
|
|
165
|
+
layout: $layout.fill,
|
|
166
|
+
events: {
|
|
167
|
+
...otherEvents,
|
|
168
|
+
itemSize: (_sender, indexPath) => {
|
|
169
|
+
if (this._totalWidth === 0) {
|
|
170
|
+
return $size(0, 0);
|
|
171
|
+
}
|
|
172
|
+
if (indexPath.item === 0) {
|
|
173
|
+
const width = Math.max(this._totalWidth - 2 * this._spacing, 32);
|
|
174
|
+
const textHeight = _getTextHeight(this._data[indexPath.section].title, width - 32);
|
|
175
|
+
const height = textHeight + 35 - this._spacing * (indexPath.section === 0 ? 1 : 2);
|
|
176
|
+
return $size(width, height);
|
|
177
|
+
} else {
|
|
178
|
+
return $size(this._itemSizeWidth, this._itemSizeHeight);
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
didSelect: didSelect
|
|
182
|
+
? (sender, indexPath) => {
|
|
183
|
+
if (indexPath.item === 0) {
|
|
184
|
+
return;
|
|
185
|
+
} else {
|
|
186
|
+
didSelect(
|
|
187
|
+
sender,
|
|
188
|
+
$indexPath(indexPath.section, indexPath.item - 1),
|
|
189
|
+
this._data[indexPath.section].items[indexPath.item - 1],
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
: undefined,
|
|
194
|
+
didLongPress: didLongPress
|
|
195
|
+
? (sender, indexPath) => {
|
|
196
|
+
if (indexPath.item === 0) {
|
|
197
|
+
return;
|
|
198
|
+
} else {
|
|
199
|
+
didLongPress(
|
|
200
|
+
sender,
|
|
201
|
+
$indexPath(indexPath.section, indexPath.item - 1),
|
|
202
|
+
this._data[indexPath.section].items[indexPath.item - 1],
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
: undefined,
|
|
207
|
+
forEachItem: forEachItem
|
|
208
|
+
? (sender, indexPath) => {
|
|
209
|
+
if (indexPath.item === 0) {
|
|
210
|
+
return;
|
|
211
|
+
} else {
|
|
212
|
+
forEachItem(sender, $indexPath(indexPath.section, indexPath.item - 1));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
: undefined,
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
this._defineView = () => {
|
|
219
|
+
return {
|
|
220
|
+
type: "view",
|
|
221
|
+
props: {
|
|
222
|
+
id: this.id,
|
|
223
|
+
bgcolor: $color("clear"),
|
|
224
|
+
},
|
|
225
|
+
layout,
|
|
226
|
+
views: [this.matrix.definition],
|
|
227
|
+
events: {
|
|
228
|
+
layoutSubviews: (sender) => {
|
|
229
|
+
sender.relayout();
|
|
230
|
+
if (sender.frame.width === this._totalWidth) return;
|
|
231
|
+
this._totalWidth = sender.frame.width;
|
|
232
|
+
const { columns, itemSizeWidth } = _getColumnsAndItemSizeWidth(
|
|
233
|
+
this._totalWidth,
|
|
234
|
+
this._minItemWidth,
|
|
235
|
+
this._maxColumns,
|
|
236
|
+
this._spacing,
|
|
237
|
+
);
|
|
238
|
+
this._columns = columns;
|
|
239
|
+
this._itemSizeWidth = itemSizeWidth;
|
|
240
|
+
this._itemSizeHeight = this._events.itemHeight
|
|
241
|
+
? this._events.itemHeight(this._itemSizeWidth)
|
|
242
|
+
: this._fixedItemHeight;
|
|
243
|
+
this.matrix.view.reload();
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private _mapData(data: DynamicItemSizeSectionMatrixSection[]) {
|
|
251
|
+
return data.map((n) => {
|
|
252
|
+
const mappedItems = n.items.map((n) => {
|
|
253
|
+
return {
|
|
254
|
+
__section_title__: { hidden: true },
|
|
255
|
+
__original_template__: { hidden: false },
|
|
256
|
+
...n,
|
|
257
|
+
};
|
|
258
|
+
});
|
|
259
|
+
return {
|
|
260
|
+
title: "",
|
|
261
|
+
items: [
|
|
262
|
+
{
|
|
263
|
+
__section_title__: { hidden: false },
|
|
264
|
+
__section_title_label__: { text: n.title },
|
|
265
|
+
__original_template__: { hidden: true },
|
|
266
|
+
},
|
|
267
|
+
...mappedItems,
|
|
268
|
+
],
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
private _mapTemplate(template: UiTypes.MatrixProps["template"]): UiTypes.MatrixProps["template"] {
|
|
274
|
+
if (!template) return;
|
|
275
|
+
const newTemplate: UiTypes.MatrixProps["template"] = {
|
|
276
|
+
views: [
|
|
277
|
+
{
|
|
278
|
+
type: "view",
|
|
279
|
+
props: {
|
|
280
|
+
id: "__section_title__",
|
|
281
|
+
},
|
|
282
|
+
layout: $layout.fill,
|
|
283
|
+
views: [
|
|
284
|
+
{
|
|
285
|
+
// 在这里放一个透明且无效果的button,从而取消item自己的highlight效果
|
|
286
|
+
type: "button",
|
|
287
|
+
props: {
|
|
288
|
+
bgcolor: $color("clear"),
|
|
289
|
+
},
|
|
290
|
+
layout: $layout.fill,
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
type: "label",
|
|
294
|
+
props: {
|
|
295
|
+
id: "__section_title_label__",
|
|
296
|
+
bgcolor: $color("clear"),
|
|
297
|
+
font: $font(13),
|
|
298
|
+
textColor: $color("secondaryText"),
|
|
299
|
+
lines: 0,
|
|
300
|
+
},
|
|
301
|
+
layout: (make, view) => {
|
|
302
|
+
make.left.right.inset(16);
|
|
303
|
+
make.bottom.inset(0);
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
type: "view",
|
|
310
|
+
props: {
|
|
311
|
+
...template.props,
|
|
312
|
+
id: "__original_template__",
|
|
313
|
+
},
|
|
314
|
+
layout: $layout.fill,
|
|
315
|
+
views: template.views,
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
return newTemplate;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
get data() {
|
|
324
|
+
return this._data;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
set data(data) {
|
|
328
|
+
this._data = data;
|
|
329
|
+
this.matrix.view.data = this._mapData(data);
|
|
330
|
+
this.reload();
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
reload() {
|
|
334
|
+
this.matrix.view.reload();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
object(indexPath: NSIndexPath) {
|
|
338
|
+
return this._data?.[indexPath.section]?.items[indexPath.item];
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
insert({ indexPath, value }: { indexPath: NSIndexPath; value: any }) {
|
|
342
|
+
this._data?.[indexPath.section]?.items.splice(indexPath.item, 0, value);
|
|
343
|
+
this.matrix.view.data = this._mapData(this._data);
|
|
344
|
+
this.reload();
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
delete(indexPath: NSIndexPath): void {
|
|
348
|
+
this._data?.[indexPath.section]?.items.splice(indexPath.item, 1);
|
|
349
|
+
this.matrix.view.data = this._mapData(this._data);
|
|
350
|
+
this.reload();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
cell(indexPath: NSIndexPath): AllUIView {
|
|
354
|
+
return this.matrix.view.cell($indexPath(indexPath.section, indexPath.item + 1));
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
scrollTo({ indexPath, animated }: { indexPath: NSIndexPath; animated?: boolean }): void {
|
|
358
|
+
this.matrix.view.scrollTo({
|
|
359
|
+
indexPath: $indexPath(indexPath.section, indexPath.item + 1),
|
|
360
|
+
animated,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}
|
package/components/oc-webview.ts
CHANGED
|
@@ -29,11 +29,13 @@ import { Base } from "./base";
|
|
|
29
29
|
* - goForward()
|
|
30
30
|
* - stopLoading()
|
|
31
31
|
* - reload()
|
|
32
|
+
* - evaluateJavaScript(script)
|
|
32
33
|
*
|
|
33
34
|
*/
|
|
34
35
|
export class OCWebView extends Base<UIView, UiTypes.RuntimeOptions> {
|
|
35
36
|
_defineView: () => UiTypes.RuntimeOptions;
|
|
36
37
|
webView: any; // 实际为WKWebView OC类型
|
|
38
|
+
private _originUrl: string;
|
|
37
39
|
constructor({
|
|
38
40
|
props,
|
|
39
41
|
layout,
|
|
@@ -53,6 +55,7 @@ export class OCWebView extends Base<UIView, UiTypes.RuntimeOptions> {
|
|
|
53
55
|
config.invoke("setWebsiteDataStore:", $objc("WKWebsiteDataStore").invoke("defaultDataStore"));
|
|
54
56
|
const webView = $objc("WKWebView").invoke("alloc.initWithFrame:configuration:", $rect(0, 0, 0, 0), config);
|
|
55
57
|
this.webView = webView;
|
|
58
|
+
this._originUrl = props.url;
|
|
56
59
|
|
|
57
60
|
this._defineView = () => {
|
|
58
61
|
return {
|
|
@@ -101,6 +104,17 @@ export class OCWebView extends Base<UIView, UiTypes.RuntimeOptions> {
|
|
|
101
104
|
return nsurl ? nsurl.invoke("absoluteString").rawValue() : "";
|
|
102
105
|
}
|
|
103
106
|
|
|
107
|
+
set url(urlStr: string) {
|
|
108
|
+
const url = $objc("NSURL").invoke("URLWithString:", urlStr);
|
|
109
|
+
const req = $objc("NSURLRequest").invoke("requestWithURL:", url);
|
|
110
|
+
this.webView.invoke("loadRequest:", req);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get title(): string {
|
|
114
|
+
const title = this.webView.invoke("title");
|
|
115
|
+
return title ? title.rawValue() : "";
|
|
116
|
+
}
|
|
117
|
+
|
|
104
118
|
get canGoBack(): boolean {
|
|
105
119
|
return this.webView.invoke("canGoBack");
|
|
106
120
|
}
|
|
@@ -124,4 +138,40 @@ export class OCWebView extends Base<UIView, UiTypes.RuntimeOptions> {
|
|
|
124
138
|
reload() {
|
|
125
139
|
this.webView.invoke("reload");
|
|
126
140
|
}
|
|
141
|
+
|
|
142
|
+
reloadFromOrigin() {
|
|
143
|
+
this.url = this._originUrl;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
exec<T = any>(script: string): Promise<T> {
|
|
147
|
+
return new Promise((resolve, reject) => {
|
|
148
|
+
this.webView.invoke(
|
|
149
|
+
"evaluateJavaScript:completionHandler:",
|
|
150
|
+
script,
|
|
151
|
+
$block("void, id, NSError *", (result: any, error: any) => {
|
|
152
|
+
const jsError = error ? error.jsValue() : null;
|
|
153
|
+
if (jsError) {
|
|
154
|
+
reject(jsError);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!result) {
|
|
158
|
+
resolve(result);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (typeof result.jsValue === "function") {
|
|
162
|
+
resolve(result.jsValue());
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
resolve(result);
|
|
166
|
+
}),
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
eval({ script, handler }: { script: string; handler: (result: any, error?: NSError) => void }) {
|
|
172
|
+
this.exec(script).then(
|
|
173
|
+
(result) => handler(result),
|
|
174
|
+
(error) => handler(undefined, error),
|
|
175
|
+
);
|
|
176
|
+
}
|
|
127
177
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inputAlert =
|
|
3
|
+
exports.inputAlert = inputAlert;
|
|
4
4
|
const uialert_1 = require("./uialert");
|
|
5
5
|
const l10n_1 = require("../../utils/l10n");
|
|
6
6
|
/**
|
|
@@ -43,4 +43,3 @@ function inputAlert({ title = "", message = "", text = "", placeholder, type = 0
|
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
exports.inputAlert = inputAlert;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loginAlert =
|
|
3
|
+
exports.loginAlert = loginAlert;
|
|
4
4
|
const uialert_1 = require("./uialert");
|
|
5
5
|
const l10n_1 = require("../../utils/l10n");
|
|
6
6
|
/**
|
|
@@ -47,4 +47,3 @@ function loginAlert({ title = "", message = "", placeholder1 = "", placeholder2
|
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
exports.loginAlert = loginAlert;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.plainAlert =
|
|
3
|
+
exports.plainAlert = plainAlert;
|
|
4
4
|
const uialert_1 = require("./uialert");
|
|
5
5
|
const l10n_1 = require("../../utils/l10n");
|
|
6
6
|
/**
|
|
@@ -26,4 +26,3 @@ function plainAlert({ title = "", message = "", cancelText = (0, l10n_1.l10n)("C
|
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
exports.plainAlert = plainAlert;
|
|
@@ -86,7 +86,13 @@ const navBarLayouts = [
|
|
|
86
86
|
class CustomNavigationBar extends base_1.Base {
|
|
87
87
|
constructor({ props = {}, events = {}, } = {}) {
|
|
88
88
|
super();
|
|
89
|
-
this._props =
|
|
89
|
+
this._props = {
|
|
90
|
+
leftBarButtonItems: [],
|
|
91
|
+
rightBarButtonItems: [],
|
|
92
|
+
style: navBarStyles.normal,
|
|
93
|
+
tintColor: $color("primaryText"),
|
|
94
|
+
...props,
|
|
95
|
+
};
|
|
90
96
|
this._events = events;
|
|
91
97
|
this.cviews = {};
|
|
92
98
|
this._defineView = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formDialog =
|
|
3
|
+
exports.formDialog = formDialog;
|
|
4
4
|
const static_preference_listview_1 = require("../static-preference-listview");
|
|
5
5
|
const dialog_sheet_1 = require("./dialog-sheet");
|
|
6
6
|
class DialogSheetForm extends dialog_sheet_1.DialogSheet {
|
|
@@ -38,4 +38,3 @@ function formDialog({ sections, title, checkHandler, }) {
|
|
|
38
38
|
sheet.present();
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
exports.formDialog = formDialog;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listDialog =
|
|
3
|
+
exports.listDialog = listDialog;
|
|
4
4
|
const dialog_sheet_1 = require("./dialog-sheet");
|
|
5
5
|
const single_views_1 = require("../single-views");
|
|
6
6
|
function listDialog({ items, multiSelectEnabled, value, values = [], title, }) {
|
|
@@ -76,4 +76,3 @@ function listDialog({ items, multiSelectEnabled, value, values = [], title, }) {
|
|
|
76
76
|
sheet.present();
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
exports.listDialog = listDialog;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.textDialog =
|
|
3
|
+
exports.textDialog = textDialog;
|
|
4
4
|
const single_views_1 = require("../single-views");
|
|
5
5
|
const dialog_sheet_1 = require("./dialog-sheet");
|
|
6
6
|
/**
|
|
@@ -34,4 +34,3 @@ function textDialog({ title, text = "", placeholder = "", editable = true, }) {
|
|
|
34
34
|
sheet.present();
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
exports.textDialog = textDialog;
|
|
@@ -26,7 +26,11 @@ class DynamicContextMenuView extends base_1.Base {
|
|
|
26
26
|
this._defineView = () => {
|
|
27
27
|
return {
|
|
28
28
|
type: "runtime",
|
|
29
|
-
props:
|
|
29
|
+
props: {
|
|
30
|
+
...props,
|
|
31
|
+
id: this.id,
|
|
32
|
+
view: runtimeView,
|
|
33
|
+
},
|
|
30
34
|
layout,
|
|
31
35
|
events,
|
|
32
36
|
views,
|
|
@@ -1,15 +1,4 @@
|
|
|
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.DynamicItemSizeMatrix = void 0;
|
|
15
4
|
const base_1 = require("./base");
|
|
@@ -78,16 +67,29 @@ class DynamicItemSizeMatrix extends base_1.Base {
|
|
|
78
67
|
super();
|
|
79
68
|
this._totalWidth = 0;
|
|
80
69
|
this._columns = 1;
|
|
81
|
-
this._props =
|
|
70
|
+
this._props = {
|
|
71
|
+
fixedItemHeight: 40,
|
|
72
|
+
minItemWidth: 96,
|
|
73
|
+
maxColumns: 5,
|
|
74
|
+
spacing: 6,
|
|
75
|
+
dynamicHeightEnabled: false,
|
|
76
|
+
...props,
|
|
77
|
+
};
|
|
82
78
|
this._events = events;
|
|
83
|
-
const
|
|
79
|
+
const { itemHeight, heightChanged, ...rest } = this._events;
|
|
84
80
|
const _matrixEvents = rest;
|
|
85
81
|
this._itemSizeWidth = 0;
|
|
86
82
|
this._itemSizeHeight = 0;
|
|
87
83
|
this.matrix = new single_views_1.Matrix({
|
|
88
|
-
props:
|
|
84
|
+
props: {
|
|
85
|
+
...this._props,
|
|
86
|
+
scrollEnabled: !this._props.dynamicHeightEnabled,
|
|
87
|
+
},
|
|
89
88
|
layout: $layout.fill,
|
|
90
|
-
events:
|
|
89
|
+
events: {
|
|
90
|
+
..._matrixEvents,
|
|
91
|
+
itemSize: (sender) => $size(this._itemSizeWidth, this._itemSizeHeight),
|
|
92
|
+
},
|
|
91
93
|
});
|
|
92
94
|
this._defineView = () => {
|
|
93
95
|
return {
|