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
|
@@ -18,7 +18,7 @@ function _getColumnsAndItemSizeWidth(containerWidth, minItemWidth, maxColumns, s
|
|
|
18
18
|
if (minItemWidth > containerWidth - 2 * spacing) {
|
|
19
19
|
return {
|
|
20
20
|
columns: 1,
|
|
21
|
-
itemSizeWidth: containerWidth - 2 * spacing
|
|
21
|
+
itemSizeWidth: containerWidth - 2 * spacing,
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
const columns = Math.max(Math.min(Math.floor((containerWidth - spacing) / (minItemWidth + spacing)), maxColumns), 1 // 最少一列
|
|
@@ -27,7 +27,7 @@ function _getColumnsAndItemSizeWidth(containerWidth, minItemWidth, maxColumns, s
|
|
|
27
27
|
);
|
|
28
28
|
return {
|
|
29
29
|
columns,
|
|
30
|
-
itemSizeWidth
|
|
30
|
+
itemSizeWidth,
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
@@ -36,18 +36,20 @@ function _getColumnsAndItemSizeWidth(containerWidth, minItemWidth, maxColumns, s
|
|
|
36
36
|
* 此组件是为了解决让 Matrix 的 ItemSize 跟随重新布局而动态变化的问题
|
|
37
37
|
*
|
|
38
38
|
* 动态的改变自己的 itemSize,从而使得 spacing 被优先满足。
|
|
39
|
-
* 思路为在 matrix 上层套一个 superView,在旋转的时候 superView 会调用 matrix.relayout()
|
|
40
|
-
*
|
|
39
|
+
* 思路为在 matrix 上层套一个 superView,在旋转的时候 superView 会调用 matrix.relayout()
|
|
40
|
+
* 和 matrix.reload(),从而触发 itemSize 事件
|
|
41
41
|
*
|
|
42
42
|
* 此视图的高度可以自动调整,需要 dynamicHeightEnabled 设为 true,且 layout 中要有关于 height 的约束
|
|
43
43
|
*
|
|
44
44
|
* 其排布逻辑是这样的:
|
|
45
45
|
*
|
|
46
|
-
* 1. 由 minItemWidth,spacing,maxColumns 这三个参数决定 cloumns
|
|
46
|
+
* 1. 由 minItemWidth,spacing,maxColumns 这三个参数决定 cloumns,
|
|
47
|
+
* 并结合 totalWidth 确定 itemSize.width
|
|
47
48
|
* 2. 确定 itemHeight 有两种方法:
|
|
48
49
|
* - fixedItemHeight 固定高度,优先级第二
|
|
49
50
|
* - event: itemHeight(width) => height 通过 width 动态计算,优先级最高
|
|
50
|
-
* 3. 如果 minItemWidth 比 totalWidth - 2 * spacing 还要小,那么 itemSize.width
|
|
51
|
+
* 3. 如果 minItemWidth 比 totalWidth - 2 * spacing 还要小,那么 itemSize.width
|
|
52
|
+
* 会被设定为 totalWidth - 2 * spacing,以保证item不会超出边框
|
|
51
53
|
*
|
|
52
54
|
* props:
|
|
53
55
|
*
|
|
@@ -74,7 +76,7 @@ function _getColumnsAndItemSizeWidth(containerWidth, minItemWidth, maxColumns, s
|
|
|
74
76
|
* - heightToWidth(width) 计算特定width时的应有的高度
|
|
75
77
|
*/
|
|
76
78
|
class DynamicItemSizeMatrix extends base_1.Base {
|
|
77
|
-
constructor({ props, layout, events = {} }) {
|
|
79
|
+
constructor({ props, layout, events = {}, }) {
|
|
78
80
|
super();
|
|
79
81
|
this._totalWidth = 0;
|
|
80
82
|
this._columns = 1;
|
|
@@ -87,18 +89,18 @@ class DynamicItemSizeMatrix extends base_1.Base {
|
|
|
87
89
|
this.matrix = new single_views_1.Matrix({
|
|
88
90
|
props: Object.assign(Object.assign({}, this._props), { scrollEnabled: !this._props.dynamicHeightEnabled }),
|
|
89
91
|
layout: $layout.fill,
|
|
90
|
-
events: Object.assign(Object.assign({}, _matrixEvents), { itemSize: sender => $size(this._itemSizeWidth, this._itemSizeHeight) })
|
|
92
|
+
events: Object.assign(Object.assign({}, _matrixEvents), { itemSize: (sender) => $size(this._itemSizeWidth, this._itemSizeHeight) }),
|
|
91
93
|
});
|
|
92
94
|
this._defineView = () => {
|
|
93
95
|
return {
|
|
94
96
|
type: "view",
|
|
95
97
|
props: {
|
|
96
98
|
bgcolor: $color("clear"),
|
|
97
|
-
id: this.id
|
|
99
|
+
id: this.id,
|
|
98
100
|
},
|
|
99
101
|
layout,
|
|
100
102
|
events: {
|
|
101
|
-
layoutSubviews: sender => {
|
|
103
|
+
layoutSubviews: (sender) => {
|
|
102
104
|
sender.relayout();
|
|
103
105
|
if (sender.frame.width === this._totalWidth)
|
|
104
106
|
return;
|
|
@@ -111,13 +113,13 @@ class DynamicItemSizeMatrix extends base_1.Base {
|
|
|
111
113
|
this.matrix.view.reload();
|
|
112
114
|
if (this._props.dynamicHeightEnabled) {
|
|
113
115
|
const height = this.heightToWidth(sender.frame.width);
|
|
114
|
-
sender.updateLayout(make => make.height.equalTo(height));
|
|
116
|
+
sender.updateLayout((make) => make.height.equalTo(height));
|
|
115
117
|
if (this._events.heightChanged)
|
|
116
118
|
this._events.heightChanged(this, height);
|
|
117
119
|
}
|
|
118
|
-
}
|
|
120
|
+
},
|
|
119
121
|
},
|
|
120
|
-
views: [this.matrix.definition]
|
|
122
|
+
views: [this.matrix.definition],
|
|
121
123
|
};
|
|
122
124
|
};
|
|
123
125
|
}
|
|
@@ -19,7 +19,8 @@ const static_preference_listview_1 = require("./static-preference-listview");
|
|
|
19
19
|
*
|
|
20
20
|
* 为了缓解上面的问题, 让修改布局无需调整源代码, 增加下列 props:
|
|
21
21
|
*
|
|
22
|
-
* - stringLeftInset?: number = 120 将同时作用于 string, number, integer, list, date
|
|
22
|
+
* - stringLeftInset?: number = 120 将同时作用于 string, number, integer, list, date
|
|
23
|
+
* 但是由于后四者内容可控, 可视为只作用于 string
|
|
23
24
|
* - infoAndLinkLeftInset?: number = 120 作用于 info, link
|
|
24
25
|
* - sliderWidth?: number = 200 作用于 slider
|
|
25
26
|
* - tabWidth?: number = 200 作用于 tab
|
|
@@ -30,11 +31,11 @@ const static_preference_listview_1 = require("./static-preference-listview");
|
|
|
30
31
|
* - cview.sections = sections 可以写入新的 sections
|
|
31
32
|
*/
|
|
32
33
|
class DynamicPreferenceListView extends base_1.Base {
|
|
33
|
-
constructor({ sections, props, layout, events = {} }) {
|
|
34
|
+
constructor({ sections, props, layout, events = {}, }) {
|
|
34
35
|
super();
|
|
35
|
-
this._sections = sections.map(n => ({
|
|
36
|
+
this._sections = sections.map((n) => ({
|
|
36
37
|
title: n.title,
|
|
37
|
-
rows: n.rows.map(r => (Object.assign({}, r)))
|
|
38
|
+
rows: n.rows.map((r) => (Object.assign({}, r))),
|
|
38
39
|
}));
|
|
39
40
|
this._props = Object.assign({ stringLeftInset: 120, infoAndLinkLeftInset: 120, sliderWidth: 200, tabWidth: 200 }, props);
|
|
40
41
|
this._layout = layout;
|
|
@@ -47,20 +48,20 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
47
48
|
type: "view",
|
|
48
49
|
props: {
|
|
49
50
|
id: "bgview",
|
|
50
|
-
bgcolor: $color("secondarySurface")
|
|
51
|
+
bgcolor: $color("secondarySurface"),
|
|
51
52
|
},
|
|
52
|
-
layout: $layout.fill
|
|
53
|
+
layout: $layout.fill,
|
|
53
54
|
},
|
|
54
55
|
{
|
|
55
56
|
type: "label",
|
|
56
57
|
props: {
|
|
57
58
|
id: "title",
|
|
58
|
-
font: $font(17)
|
|
59
|
+
font: $font(17),
|
|
59
60
|
},
|
|
60
61
|
layout: (make, view) => {
|
|
61
62
|
make.top.bottom.inset(0);
|
|
62
63
|
make.left.right.inset(15);
|
|
63
|
-
}
|
|
64
|
+
},
|
|
64
65
|
},
|
|
65
66
|
{
|
|
66
67
|
type: "view",
|
|
@@ -73,7 +74,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
73
74
|
{
|
|
74
75
|
type: "view",
|
|
75
76
|
props: {
|
|
76
|
-
id: "label_and_chevron"
|
|
77
|
+
id: "label_and_chevron",
|
|
77
78
|
},
|
|
78
79
|
layout: $layout.fill,
|
|
79
80
|
views: [
|
|
@@ -82,74 +83,75 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
82
83
|
props: {
|
|
83
84
|
symbol: "chevron.right",
|
|
84
85
|
tintColor: $color("lightGray", "darkGray"),
|
|
85
|
-
contentMode: 1
|
|
86
|
+
contentMode: 1,
|
|
86
87
|
},
|
|
87
88
|
layout: (make, view) => {
|
|
88
89
|
make.centerY.equalTo(view.super);
|
|
89
90
|
make.size.equalTo($size(17, 17));
|
|
90
91
|
make.right.inset(0);
|
|
91
|
-
}
|
|
92
|
+
},
|
|
92
93
|
},
|
|
93
94
|
{
|
|
94
95
|
type: "label",
|
|
95
96
|
props: {
|
|
96
97
|
id: "label_before_chevron",
|
|
97
98
|
align: $align.right,
|
|
98
|
-
font: $font(17)
|
|
99
|
+
font: $font(17),
|
|
99
100
|
},
|
|
100
101
|
layout: (make, view) => {
|
|
101
102
|
make.centerY.equalTo(view.super);
|
|
102
103
|
make.left.inset(this._props.stringLeftInset - 15);
|
|
103
104
|
make.right.equalTo(view.prev.left).inset(5);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
]
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
],
|
|
107
108
|
},
|
|
108
109
|
{
|
|
109
110
|
type: "view",
|
|
110
111
|
props: {
|
|
111
|
-
id: "number_and_stepper"
|
|
112
|
+
id: "number_and_stepper",
|
|
112
113
|
},
|
|
113
114
|
layout: $layout.fill,
|
|
114
115
|
views: [
|
|
115
116
|
{
|
|
116
117
|
type: "stepper",
|
|
117
118
|
props: {
|
|
118
|
-
id: "stepper"
|
|
119
|
+
id: "stepper",
|
|
119
120
|
},
|
|
120
121
|
layout: (make, view) => {
|
|
121
122
|
make.centerY.equalTo(view.super);
|
|
122
123
|
make.right.inset(0);
|
|
123
124
|
},
|
|
124
125
|
events: {
|
|
125
|
-
changed: sender => {
|
|
126
|
+
changed: (sender) => {
|
|
126
127
|
const { section, row } = sender.info;
|
|
127
|
-
this._sections[section].rows[row].value =
|
|
128
|
+
this._sections[section].rows[row].value =
|
|
129
|
+
sender.value;
|
|
128
130
|
const label = sender.next;
|
|
129
131
|
label.text = sender.value.toString();
|
|
130
132
|
if (events.changed)
|
|
131
133
|
events.changed(this.values);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
+
},
|
|
135
|
+
},
|
|
134
136
|
},
|
|
135
137
|
{
|
|
136
138
|
type: "label",
|
|
137
139
|
props: {
|
|
138
140
|
id: "label_stepper",
|
|
139
|
-
align: $align.right
|
|
141
|
+
align: $align.right,
|
|
140
142
|
},
|
|
141
143
|
layout: (make, view) => {
|
|
142
144
|
make.top.bottom.inset(0);
|
|
143
145
|
make.right.equalTo(view.prev.left).inset(10);
|
|
144
146
|
make.width.equalTo(100);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
]
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
],
|
|
148
150
|
},
|
|
149
151
|
{
|
|
150
152
|
type: "view",
|
|
151
153
|
props: {
|
|
152
|
-
id: "slider_and_number"
|
|
154
|
+
id: "slider_and_number",
|
|
153
155
|
},
|
|
154
156
|
layout: $layout.fill,
|
|
155
157
|
views: [
|
|
@@ -158,7 +160,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
158
160
|
props: {
|
|
159
161
|
id: "slider",
|
|
160
162
|
min: 0,
|
|
161
|
-
max: 1
|
|
163
|
+
max: 1,
|
|
162
164
|
},
|
|
163
165
|
layout: (make, view) => {
|
|
164
166
|
make.centerY.equalTo(view.super);
|
|
@@ -166,59 +168,60 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
166
168
|
make.width.equalTo(this._props.sliderWidth - 40);
|
|
167
169
|
},
|
|
168
170
|
events: {
|
|
169
|
-
changed: sender => {
|
|
171
|
+
changed: (sender) => {
|
|
170
172
|
var _a;
|
|
171
173
|
const { section, row } = sender.info;
|
|
172
174
|
const options = this._sections[section].rows[row];
|
|
173
175
|
const label = sender.next;
|
|
174
176
|
label.text = this._handleSliderValue(sender.value * ((_a = options.max) !== null && _a !== void 0 ? _a : 1), options.decimal, options.min, options.max).toString();
|
|
175
177
|
},
|
|
176
|
-
touchesEnded: sender => {
|
|
178
|
+
touchesEnded: (sender) => {
|
|
177
179
|
var _a;
|
|
178
180
|
const { section, row } = sender.info;
|
|
179
181
|
const options = this._sections[section].rows[row];
|
|
180
|
-
this._sections[section].rows[row].value =
|
|
182
|
+
this._sections[section].rows[row].value =
|
|
183
|
+
this._handleSliderValue(sender.value * ((_a = options.max) !== null && _a !== void 0 ? _a : 1), options.decimal, options.min, options.max);
|
|
181
184
|
if (events.changed)
|
|
182
185
|
events.changed(this.values);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
186
|
+
},
|
|
187
|
+
},
|
|
185
188
|
},
|
|
186
189
|
{
|
|
187
190
|
type: "label",
|
|
188
191
|
props: {
|
|
189
192
|
id: "label_slider",
|
|
190
|
-
align: $align.center
|
|
193
|
+
align: $align.center,
|
|
191
194
|
},
|
|
192
195
|
layout: (make, view) => {
|
|
193
196
|
make.top.bottom.inset(0);
|
|
194
197
|
make.right.inset(0);
|
|
195
198
|
make.width.equalTo(44);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
]
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
],
|
|
199
202
|
},
|
|
200
203
|
{
|
|
201
204
|
type: "switch",
|
|
202
205
|
props: {
|
|
203
|
-
id: "switch"
|
|
206
|
+
id: "switch",
|
|
204
207
|
},
|
|
205
208
|
layout: (make, view) => {
|
|
206
209
|
make.centerY.equalTo(view.super);
|
|
207
210
|
make.right.inset(0);
|
|
208
211
|
},
|
|
209
212
|
events: {
|
|
210
|
-
changed: sender => {
|
|
213
|
+
changed: (sender) => {
|
|
211
214
|
const { section, row } = sender.info;
|
|
212
215
|
this._sections[section].rows[row].value = sender.on;
|
|
213
216
|
if (events.changed)
|
|
214
217
|
events.changed(this.values);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
218
|
+
},
|
|
219
|
+
},
|
|
217
220
|
},
|
|
218
221
|
{
|
|
219
222
|
type: "tab",
|
|
220
223
|
props: {
|
|
221
|
-
id: "tab"
|
|
224
|
+
id: "tab",
|
|
222
225
|
},
|
|
223
226
|
layout: (make, view) => {
|
|
224
227
|
make.centerY.equalTo(view.super);
|
|
@@ -227,29 +230,29 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
227
230
|
make.right.inset(0);
|
|
228
231
|
},
|
|
229
232
|
events: {
|
|
230
|
-
changed: sender => {
|
|
233
|
+
changed: (sender) => {
|
|
231
234
|
const { section, row } = sender.info;
|
|
232
235
|
this._sections[section].rows[row].value = sender.index;
|
|
233
236
|
if (events.changed)
|
|
234
237
|
events.changed(this.values);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
238
|
+
},
|
|
239
|
+
},
|
|
237
240
|
},
|
|
238
241
|
{
|
|
239
242
|
type: "label",
|
|
240
243
|
props: {
|
|
241
244
|
id: "label_info_link",
|
|
242
|
-
align: $align.right
|
|
245
|
+
align: $align.right,
|
|
243
246
|
},
|
|
244
247
|
layout: (make, view) => {
|
|
245
248
|
make.top.bottom.inset(0);
|
|
246
249
|
make.left.inset(this._props.infoAndLinkLeftInset);
|
|
247
250
|
make.right.inset(0);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
]
|
|
251
|
-
}
|
|
252
|
-
]
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
},
|
|
255
|
+
],
|
|
253
256
|
}, data: this._map(this._sections) }),
|
|
254
257
|
layout: this._layout,
|
|
255
258
|
events: {
|
|
@@ -264,12 +267,12 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
264
267
|
text: row.value,
|
|
265
268
|
type: $kbType.default,
|
|
266
269
|
placeholder: row.placeholder,
|
|
267
|
-
handler: text => {
|
|
270
|
+
handler: (text) => {
|
|
268
271
|
row.value = text;
|
|
269
272
|
sender.data = this._map(this._sections);
|
|
270
273
|
if (events.changed)
|
|
271
274
|
events.changed(this.values);
|
|
272
|
-
}
|
|
275
|
+
},
|
|
273
276
|
});
|
|
274
277
|
break;
|
|
275
278
|
}
|
|
@@ -278,7 +281,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
278
281
|
text: (_a = row.value) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
279
282
|
type: $kbType.decimal,
|
|
280
283
|
placeholder: row.placeholder,
|
|
281
|
-
handler: text => {
|
|
284
|
+
handler: (text) => {
|
|
282
285
|
let num = this._handleText(text, row.type);
|
|
283
286
|
if (num === undefined)
|
|
284
287
|
return;
|
|
@@ -290,7 +293,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
290
293
|
sender.data = this._map(this._sections);
|
|
291
294
|
if (events.changed)
|
|
292
295
|
events.changed(this.values);
|
|
293
|
-
}
|
|
296
|
+
},
|
|
294
297
|
});
|
|
295
298
|
break;
|
|
296
299
|
}
|
|
@@ -299,7 +302,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
299
302
|
text: (_b = row.value) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
300
303
|
type: $kbType.number,
|
|
301
304
|
placeholder: row.placeholder,
|
|
302
|
-
handler: text => {
|
|
305
|
+
handler: (text) => {
|
|
303
306
|
let num = this._handleText(text, row.type);
|
|
304
307
|
if (num === undefined)
|
|
305
308
|
return;
|
|
@@ -311,7 +314,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
311
314
|
sender.data = this._map(this._sections);
|
|
312
315
|
if (events.changed)
|
|
313
316
|
events.changed(this.values);
|
|
314
|
-
}
|
|
317
|
+
},
|
|
315
318
|
});
|
|
316
319
|
break;
|
|
317
320
|
}
|
|
@@ -323,7 +326,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
323
326
|
sender.data = this._map(this._sections);
|
|
324
327
|
if (events.changed)
|
|
325
328
|
events.changed(this.values);
|
|
326
|
-
}
|
|
329
|
+
},
|
|
327
330
|
});
|
|
328
331
|
break;
|
|
329
332
|
}
|
|
@@ -346,7 +349,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
346
349
|
sender.data = this._map(this._sections);
|
|
347
350
|
if (events.changed)
|
|
348
351
|
events.changed(this.values);
|
|
349
|
-
}
|
|
352
|
+
},
|
|
350
353
|
});
|
|
351
354
|
break;
|
|
352
355
|
}
|
|
@@ -357,21 +360,21 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
357
360
|
message: row.value,
|
|
358
361
|
actions: [
|
|
359
362
|
{
|
|
360
|
-
title: "取消"
|
|
363
|
+
title: "取消",
|
|
361
364
|
},
|
|
362
365
|
{
|
|
363
366
|
title: "复制",
|
|
364
367
|
handler: () => {
|
|
365
368
|
$clipboard.text = row.value || "";
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
]
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
],
|
|
369
372
|
});
|
|
370
373
|
}
|
|
371
374
|
else {
|
|
372
375
|
$ui.alert({
|
|
373
376
|
title: row.title,
|
|
374
|
-
message: row.value
|
|
377
|
+
message: row.value,
|
|
375
378
|
});
|
|
376
379
|
}
|
|
377
380
|
break;
|
|
@@ -389,8 +392,8 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
389
392
|
default:
|
|
390
393
|
break;
|
|
391
394
|
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
395
|
+
},
|
|
396
|
+
},
|
|
394
397
|
};
|
|
395
398
|
};
|
|
396
399
|
}
|
|
@@ -435,17 +438,19 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
435
438
|
_map(sections) {
|
|
436
439
|
function generateDefaultRow(options) {
|
|
437
440
|
return {
|
|
438
|
-
bgview: { hidden: static_preference_listview_1.selectableTypes.includes(options.type) },
|
|
441
|
+
bgview: { hidden: static_preference_listview_1.selectableTypes.includes(options.type) },
|
|
442
|
+
// bgview其实是用于调整selectable, 显示此视图就没有highlight效果
|
|
439
443
|
title: {
|
|
440
444
|
text: options.title,
|
|
441
|
-
textColor: options.titleColor || $color("primaryText")
|
|
445
|
+
textColor: options.titleColor || $color("primaryText"),
|
|
442
446
|
}, // 标题, 同时用于action
|
|
443
|
-
label_and_chevron: { hidden: true },
|
|
447
|
+
label_and_chevron: { hidden: true },
|
|
448
|
+
// 用于string, number, integer, list, date
|
|
444
449
|
number_and_stepper: { hidden: true }, // 用于stepper
|
|
445
450
|
slider_and_number: { hidden: true }, // 用于slider
|
|
446
451
|
switch: { hidden: true }, // 用于boolean
|
|
447
452
|
tab: { hidden: true }, // 用于tab
|
|
448
|
-
label_info_link: { hidden: true } // 用于info, link
|
|
453
|
+
label_info_link: { hidden: true }, // 用于info, link
|
|
449
454
|
};
|
|
450
455
|
}
|
|
451
456
|
return sections.map((section, sectionIndex) => ({
|
|
@@ -458,7 +463,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
458
463
|
data.label_and_chevron.hidden = false;
|
|
459
464
|
data.label_before_chevron = {
|
|
460
465
|
textColor: n.textColor || $color("primaryText"),
|
|
461
|
-
text: n.value === undefined ? "" : n.value
|
|
466
|
+
text: n.value === undefined ? "" : n.value,
|
|
462
467
|
};
|
|
463
468
|
break;
|
|
464
469
|
}
|
|
@@ -466,7 +471,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
466
471
|
data.label_and_chevron.hidden = false;
|
|
467
472
|
data.label_before_chevron = {
|
|
468
473
|
textColor: n.textColor || $color("primaryText"),
|
|
469
|
-
text: n.value === undefined ? "" : n.value
|
|
474
|
+
text: n.value === undefined ? "" : n.value,
|
|
470
475
|
};
|
|
471
476
|
break;
|
|
472
477
|
}
|
|
@@ -474,7 +479,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
474
479
|
data.label_and_chevron.hidden = false;
|
|
475
480
|
data.label_before_chevron = {
|
|
476
481
|
textColor: n.textColor || $color("primaryText"),
|
|
477
|
-
text: n.value === undefined ? "" : n.value
|
|
482
|
+
text: n.value === undefined ? "" : n.value,
|
|
478
483
|
};
|
|
479
484
|
break;
|
|
480
485
|
}
|
|
@@ -482,13 +487,13 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
482
487
|
data.number_and_stepper.hidden = false;
|
|
483
488
|
data.label_stepper = {
|
|
484
489
|
textColor: $color("primaryText"),
|
|
485
|
-
text: n.value === undefined ? "" : n.value
|
|
490
|
+
text: n.value === undefined ? "" : n.value,
|
|
486
491
|
};
|
|
487
492
|
data.stepper = {
|
|
488
493
|
min: n.min,
|
|
489
494
|
max: n.max,
|
|
490
495
|
value: n.value,
|
|
491
|
-
info: { section: sectionIndex, row: rowIndex, key: n.key }
|
|
496
|
+
info: { section: sectionIndex, row: rowIndex, key: n.key },
|
|
492
497
|
};
|
|
493
498
|
break;
|
|
494
499
|
}
|
|
@@ -498,7 +503,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
498
503
|
on: n.value,
|
|
499
504
|
onColor: n.onColor || $color("#34C85A"),
|
|
500
505
|
thumbColor: n.thumbColor,
|
|
501
|
-
info: { section: sectionIndex, row: rowIndex, key: n.key }
|
|
506
|
+
info: { section: sectionIndex, row: rowIndex, key: n.key },
|
|
502
507
|
};
|
|
503
508
|
break;
|
|
504
509
|
}
|
|
@@ -507,7 +512,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
507
512
|
const adjustedValue = this._handleSliderValue(n.value, n.decimal, n.min, n.max);
|
|
508
513
|
data.label_slider = {
|
|
509
514
|
textColor: $color("primaryText"),
|
|
510
|
-
text: adjustedValue
|
|
515
|
+
text: adjustedValue,
|
|
511
516
|
};
|
|
512
517
|
data.slider = {
|
|
513
518
|
value: adjustedValue / ((_a = n.max) !== null && _a !== void 0 ? _a : 1),
|
|
@@ -516,7 +521,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
516
521
|
//max: n.max,
|
|
517
522
|
minColor: n.minColor || $color("systemLink"),
|
|
518
523
|
maxColor: n.maxColor,
|
|
519
|
-
thumbColor: n.thumbColor
|
|
524
|
+
thumbColor: n.thumbColor,
|
|
520
525
|
};
|
|
521
526
|
break;
|
|
522
527
|
}
|
|
@@ -524,7 +529,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
524
529
|
data.label_and_chevron.hidden = false;
|
|
525
530
|
data.label_before_chevron = {
|
|
526
531
|
textColor: $color("secondaryText"),
|
|
527
|
-
text: n.items[n.value || 0]
|
|
532
|
+
text: n.items[n.value || 0],
|
|
528
533
|
};
|
|
529
534
|
break;
|
|
530
535
|
}
|
|
@@ -533,7 +538,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
533
538
|
hidden: false,
|
|
534
539
|
items: n.items,
|
|
535
540
|
index: n.value,
|
|
536
|
-
info: { section: sectionIndex, row: rowIndex, key: n.key }
|
|
541
|
+
info: { section: sectionIndex, row: rowIndex, key: n.key },
|
|
537
542
|
};
|
|
538
543
|
break;
|
|
539
544
|
}
|
|
@@ -542,7 +547,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
542
547
|
data.label_before_chevron = {
|
|
543
548
|
hidden: false,
|
|
544
549
|
textColor: $color("secondaryText"),
|
|
545
|
-
text: (0, static_preference_listview_1.dateToString)(n.mode || 2, n.value)
|
|
550
|
+
text: (0, static_preference_listview_1.dateToString)(n.mode || 2, n.value),
|
|
546
551
|
};
|
|
547
552
|
break;
|
|
548
553
|
}
|
|
@@ -550,7 +555,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
550
555
|
data.label_info_link = {
|
|
551
556
|
hidden: false,
|
|
552
557
|
textColor: $color("secondaryText"),
|
|
553
|
-
text: n.value
|
|
558
|
+
text: n.value,
|
|
554
559
|
};
|
|
555
560
|
break;
|
|
556
561
|
}
|
|
@@ -558,14 +563,14 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
558
563
|
data.label_info_link = {
|
|
559
564
|
hidden: false,
|
|
560
565
|
textColor: $color("secondaryText"),
|
|
561
|
-
text: n.value
|
|
566
|
+
text: n.value,
|
|
562
567
|
};
|
|
563
568
|
break;
|
|
564
569
|
}
|
|
565
570
|
case "link": {
|
|
566
571
|
data.label_info_link = {
|
|
567
572
|
hidden: false,
|
|
568
|
-
styledText: `[${n.value}]()
|
|
573
|
+
styledText: `[${n.value}]()`,
|
|
569
574
|
};
|
|
570
575
|
break;
|
|
571
576
|
}
|
|
@@ -579,23 +584,23 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
579
584
|
break;
|
|
580
585
|
}
|
|
581
586
|
return data;
|
|
582
|
-
})
|
|
587
|
+
}),
|
|
583
588
|
}));
|
|
584
589
|
}
|
|
585
590
|
get sections() {
|
|
586
591
|
return this._sections;
|
|
587
592
|
}
|
|
588
593
|
set sections(sections) {
|
|
589
|
-
this._sections = sections.map(n => ({
|
|
594
|
+
this._sections = sections.map((n) => ({
|
|
590
595
|
title: n.title,
|
|
591
|
-
rows: n.rows.map(r => (Object.assign({}, r)))
|
|
596
|
+
rows: n.rows.map((r) => (Object.assign({}, r))),
|
|
592
597
|
}));
|
|
593
598
|
this.view.data = this._map(this._sections);
|
|
594
599
|
}
|
|
595
600
|
get values() {
|
|
596
601
|
const values = {};
|
|
597
|
-
this._sections.forEach(section => {
|
|
598
|
-
section.rows.forEach(row => {
|
|
602
|
+
this._sections.forEach((section) => {
|
|
603
|
+
section.rows.forEach((row) => {
|
|
599
604
|
if (row.key && !static_preference_listview_1.excludedTypes.includes(row.type)) {
|
|
600
605
|
values[row.key] = row.value;
|
|
601
606
|
}
|
|
@@ -604,8 +609,8 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
604
609
|
return values;
|
|
605
610
|
}
|
|
606
611
|
set(key, value) {
|
|
607
|
-
this._sections.forEach(section => {
|
|
608
|
-
section.rows.forEach(row => {
|
|
612
|
+
this._sections.forEach((section) => {
|
|
613
|
+
section.rows.forEach((row) => {
|
|
609
614
|
if (row.key === key)
|
|
610
615
|
row.value = value;
|
|
611
616
|
});
|