jsbox-cview 1.1.1 → 1.2.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/components/custom-navigation-bar.ts +1 -1
- package/components/dynamic-preference-listview.ts +51 -105
- package/components/static-preference-listview.ts +104 -25
- package/dist/components/dynamic-preference-listview.js +38 -13
- package/dist/components/static-preference-listview.js +82 -14
- package/dist/test/dynamic-preference-listview.js +130 -0
- package/dist/test/static-preference-listview.js +129 -0
- package/package.json +2 -2
- package/test/dynamic-preference-listview.ts +131 -0
- package/test/static-preference-listview.ts +129 -0
- package/tsconfig.json +2 -2
- package/dist/test.js +0 -1
- package/test.ts +0 -0
|
@@ -26,111 +26,25 @@
|
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
import { Base } from "./base";
|
|
29
|
+
import {
|
|
30
|
+
PreferenceSection,
|
|
31
|
+
PrefsRow,
|
|
32
|
+
PrefsRowString,
|
|
33
|
+
PrefsRowNumber,
|
|
34
|
+
PrefsRowInteger,
|
|
35
|
+
PrefsRowStepper,
|
|
36
|
+
PrefsRowBoolean,
|
|
37
|
+
PrefsRowSlider,
|
|
38
|
+
PrefsRowList,
|
|
39
|
+
PrefsRowTab,
|
|
40
|
+
PrefsRowInfo,
|
|
41
|
+
PrefsRowInteractiveInfo,
|
|
42
|
+
PrefsRowLink,
|
|
43
|
+
PrefsRowAction,
|
|
44
|
+
selectableTypes,
|
|
45
|
+
excludedTypes
|
|
46
|
+
} from "./static-preference-listview";
|
|
29
47
|
|
|
30
|
-
interface PreferenceSection {
|
|
31
|
-
title: string;
|
|
32
|
-
rows: PrefsRow[]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type PreferenceCellTypes = "string" | "number" | "integer" | "stepper" | "boolean" | "slider" | "list" | "tab" | "info" | "link" | "action";
|
|
36
|
-
|
|
37
|
-
type PrefsRow = PrefsRowString | PrefsRowNumber | PrefsRowInteger | PrefsRowStepper | PrefsRowBoolean | PrefsRowSlider | PrefsRowList | PrefsRowTab | PrefsRowInfo | PrefsRowLink | PrefsRowAction;
|
|
38
|
-
|
|
39
|
-
interface PrefsRowBase {
|
|
40
|
-
type: PreferenceCellTypes;
|
|
41
|
-
key?: string;
|
|
42
|
-
title?: string;
|
|
43
|
-
titleColor?: UIColor;
|
|
44
|
-
changedEvent?: () => void;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface PrefsRowString extends PrefsRowBase {
|
|
48
|
-
type: "string";
|
|
49
|
-
value?: string;
|
|
50
|
-
placeholder?: string;
|
|
51
|
-
textColor?: UIColor;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
interface PrefsRowNumber extends PrefsRowBase {
|
|
55
|
-
type: "number";
|
|
56
|
-
value?: number;
|
|
57
|
-
placeholder?: string;
|
|
58
|
-
textColor?: UIColor;
|
|
59
|
-
min?: number;
|
|
60
|
-
max?: number;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
interface PrefsRowInteger extends PrefsRowBase {
|
|
64
|
-
type: "integer";
|
|
65
|
-
value?: number;
|
|
66
|
-
placeholder?: string;
|
|
67
|
-
textColor?: UIColor;
|
|
68
|
-
min?: number;
|
|
69
|
-
max?: number;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
interface PrefsRowStepper extends PrefsRowBase {
|
|
73
|
-
type: "stepper";
|
|
74
|
-
value?: number;
|
|
75
|
-
min?: number;
|
|
76
|
-
max?: number;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
interface PrefsRowBoolean extends PrefsRowBase {
|
|
80
|
-
type: "boolean";
|
|
81
|
-
value?: boolean;
|
|
82
|
-
onColor?: UIColor;
|
|
83
|
-
thumbColor?: UIColor;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
interface PrefsRowSlider extends PrefsRowBase {
|
|
87
|
-
type: "slider";
|
|
88
|
-
value?: number;
|
|
89
|
-
min?: number;
|
|
90
|
-
max?: number;
|
|
91
|
-
decimal?: number;
|
|
92
|
-
minColor?: UIColor;
|
|
93
|
-
maxColor?: UIColor;
|
|
94
|
-
thumbColor?: UIColor;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
interface PrefsRowList extends PrefsRowBase {
|
|
98
|
-
type: "list";
|
|
99
|
-
value?: number;
|
|
100
|
-
items: string[];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
interface PrefsRowTab extends PrefsRowBase {
|
|
104
|
-
type: "tab";
|
|
105
|
-
value?: number;
|
|
106
|
-
items: string[];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
interface PrefsRowInfo extends PrefsRowBase {
|
|
110
|
-
type: "info";
|
|
111
|
-
value?: string;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
interface PrefsRowLink extends PrefsRowBase {
|
|
115
|
-
type: "link";
|
|
116
|
-
value?: string;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
interface PrefsRowAction extends PrefsRowBase {
|
|
120
|
-
type: "action";
|
|
121
|
-
value?: () => void;
|
|
122
|
-
destructive?: boolean;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const selectableTypes = [
|
|
126
|
-
"string",
|
|
127
|
-
"number",
|
|
128
|
-
"integer",
|
|
129
|
-
"stepper",
|
|
130
|
-
"list",
|
|
131
|
-
"link",
|
|
132
|
-
"action"
|
|
133
|
-
];
|
|
134
48
|
|
|
135
49
|
interface CunstomProps extends UiTypes.ListProps {
|
|
136
50
|
stringLeftInset?: number;
|
|
@@ -468,6 +382,31 @@ export class DynamicPreferenceListView extends Base<UIListView, UiTypes.ListOpti
|
|
|
468
382
|
});
|
|
469
383
|
break;
|
|
470
384
|
}
|
|
385
|
+
case "interactive-info": {
|
|
386
|
+
if (row.copyable) {
|
|
387
|
+
$ui.alert({
|
|
388
|
+
title: row.title,
|
|
389
|
+
message: row.value,
|
|
390
|
+
actions: [
|
|
391
|
+
{
|
|
392
|
+
title: "取消"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
title: "复制",
|
|
396
|
+
handler: () => {
|
|
397
|
+
$clipboard.text = row.value || "";
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
]
|
|
401
|
+
})
|
|
402
|
+
} else {
|
|
403
|
+
$ui.alert({
|
|
404
|
+
title: row.title,
|
|
405
|
+
message: row.value
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
471
410
|
case "link": {
|
|
472
411
|
if (row.value) $safari.open({ url: row.value });
|
|
473
412
|
break;
|
|
@@ -634,6 +573,14 @@ export class DynamicPreferenceListView extends Base<UIListView, UiTypes.ListOpti
|
|
|
634
573
|
};
|
|
635
574
|
break;
|
|
636
575
|
}
|
|
576
|
+
case "interactive-info": {
|
|
577
|
+
data.label_info_link = {
|
|
578
|
+
hidden: false,
|
|
579
|
+
textColor: $color("secondaryText"),
|
|
580
|
+
text: n.value
|
|
581
|
+
};
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
637
584
|
case "link": {
|
|
638
585
|
data.label_info_link = {
|
|
639
586
|
hidden: false,
|
|
@@ -669,7 +616,6 @@ export class DynamicPreferenceListView extends Base<UIListView, UiTypes.ListOpti
|
|
|
669
616
|
|
|
670
617
|
get values() {
|
|
671
618
|
const values: { [key: string]: any } = {};
|
|
672
|
-
const excludedTypes = ["action", "info", "link"];
|
|
673
619
|
this._sections.forEach(section => {
|
|
674
620
|
section.rows.forEach(row => {
|
|
675
621
|
if (row.key && !excludedTypes.includes(row.type)) {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* - 通用:
|
|
14
14
|
*
|
|
15
|
-
* - type: string 类型. 包括'string', 'number', 'integer', 'stepper','boolean', 'slider', 'list', 'tab','info', 'link', 'action'
|
|
15
|
+
* - type: string 类型. 包括'string', 'number', 'integer', 'stepper','boolean', 'slider', 'list', 'tab', 'interactive-info', 'info', 'link', 'action'
|
|
16
16
|
* - key?: string 键. 如没有则不会返回其值.
|
|
17
17
|
* - title?: string 标题
|
|
18
18
|
* - value?: any 在下面专项里详解.
|
|
@@ -69,6 +69,11 @@
|
|
|
69
69
|
*
|
|
70
70
|
* - value?: string
|
|
71
71
|
*
|
|
72
|
+
* - interactive-info:
|
|
73
|
+
*
|
|
74
|
+
* - value?: string
|
|
75
|
+
* - copyable?: boolean = false
|
|
76
|
+
*
|
|
72
77
|
* - link:
|
|
73
78
|
*
|
|
74
79
|
* - value?: string url
|
|
@@ -91,14 +96,14 @@
|
|
|
91
96
|
import { Base } from "./base";
|
|
92
97
|
import { getTextWidth } from "../utils/uitools";
|
|
93
98
|
|
|
94
|
-
type PreferenceCellTypes = "string" | "number" | "integer" | "stepper" | "boolean" | "slider" | "list" | "tab" | "info" | "link" | "action";
|
|
99
|
+
type PreferenceCellTypes = "string" | "number" | "integer" | "stepper" | "boolean" | "slider" | "list" | "tab" | "info" | "interactive-info" | "link" | "action";
|
|
95
100
|
|
|
96
101
|
export interface PreferenceSection {
|
|
97
102
|
title: string;
|
|
98
103
|
rows: PrefsRow[]
|
|
99
104
|
}
|
|
100
105
|
|
|
101
|
-
type PrefsRow = PrefsRowString | PrefsRowNumber | PrefsRowInteger | PrefsRowStepper | PrefsRowBoolean | PrefsRowSlider | PrefsRowList | PrefsRowTab | PrefsRowInfo | PrefsRowLink | PrefsRowAction;
|
|
106
|
+
export type PrefsRow = PrefsRowString | PrefsRowNumber | PrefsRowInteger | PrefsRowStepper | PrefsRowBoolean | PrefsRowSlider | PrefsRowList | PrefsRowTab | PrefsRowInfo | PrefsRowInteractiveInfo | PrefsRowLink | PrefsRowAction;
|
|
102
107
|
|
|
103
108
|
interface PrefsRowBase {
|
|
104
109
|
type: PreferenceCellTypes;
|
|
@@ -108,14 +113,14 @@ interface PrefsRowBase {
|
|
|
108
113
|
changedEvent?: () => void;
|
|
109
114
|
}
|
|
110
115
|
|
|
111
|
-
interface PrefsRowString extends PrefsRowBase {
|
|
116
|
+
export interface PrefsRowString extends PrefsRowBase {
|
|
112
117
|
type: "string";
|
|
113
118
|
value?: string;
|
|
114
119
|
placeholder?: string;
|
|
115
120
|
textColor?: UIColor;
|
|
116
121
|
}
|
|
117
122
|
|
|
118
|
-
interface PrefsRowNumber extends PrefsRowBase {
|
|
123
|
+
export interface PrefsRowNumber extends PrefsRowBase {
|
|
119
124
|
type: "number";
|
|
120
125
|
value?: number;
|
|
121
126
|
placeholder?: string;
|
|
@@ -124,7 +129,7 @@ interface PrefsRowNumber extends PrefsRowBase {
|
|
|
124
129
|
max?: number;
|
|
125
130
|
}
|
|
126
131
|
|
|
127
|
-
interface PrefsRowInteger extends PrefsRowBase {
|
|
132
|
+
export interface PrefsRowInteger extends PrefsRowBase {
|
|
128
133
|
type: "integer";
|
|
129
134
|
value?: number;
|
|
130
135
|
placeholder?: string;
|
|
@@ -133,21 +138,21 @@ interface PrefsRowInteger extends PrefsRowBase {
|
|
|
133
138
|
max?: number;
|
|
134
139
|
}
|
|
135
140
|
|
|
136
|
-
interface PrefsRowStepper extends PrefsRowBase {
|
|
141
|
+
export interface PrefsRowStepper extends PrefsRowBase {
|
|
137
142
|
type: "stepper";
|
|
138
143
|
value?: number;
|
|
139
144
|
min?: number;
|
|
140
145
|
max?: number;
|
|
141
146
|
}
|
|
142
147
|
|
|
143
|
-
interface PrefsRowBoolean extends PrefsRowBase {
|
|
148
|
+
export interface PrefsRowBoolean extends PrefsRowBase {
|
|
144
149
|
type: "boolean";
|
|
145
150
|
value?: boolean;
|
|
146
151
|
onColor?: UIColor;
|
|
147
152
|
thumbColor?: UIColor;
|
|
148
153
|
}
|
|
149
154
|
|
|
150
|
-
interface PrefsRowSlider extends PrefsRowBase {
|
|
155
|
+
export interface PrefsRowSlider extends PrefsRowBase {
|
|
151
156
|
type: "slider";
|
|
152
157
|
value?: number;
|
|
153
158
|
min?: number;
|
|
@@ -158,37 +163,61 @@ interface PrefsRowSlider extends PrefsRowBase {
|
|
|
158
163
|
thumbColor?: UIColor;
|
|
159
164
|
}
|
|
160
165
|
|
|
161
|
-
interface PrefsRowList extends PrefsRowBase {
|
|
166
|
+
export interface PrefsRowList extends PrefsRowBase {
|
|
162
167
|
type: "list";
|
|
163
168
|
value?: number;
|
|
164
169
|
items: string[];
|
|
165
170
|
}
|
|
166
171
|
|
|
167
|
-
interface PrefsRowTab extends PrefsRowBase {
|
|
172
|
+
export interface PrefsRowTab extends PrefsRowBase {
|
|
168
173
|
type: "tab";
|
|
169
174
|
value?: number;
|
|
170
175
|
items: string[];
|
|
171
176
|
}
|
|
172
177
|
|
|
173
|
-
interface PrefsRowInfo extends PrefsRowBase {
|
|
178
|
+
export interface PrefsRowInfo extends PrefsRowBase {
|
|
174
179
|
type: "info";
|
|
175
180
|
value?: string;
|
|
176
181
|
}
|
|
177
182
|
|
|
178
|
-
interface
|
|
183
|
+
export interface PrefsRowInteractiveInfo extends PrefsRowBase {
|
|
184
|
+
type: "interactive-info";
|
|
185
|
+
value?: string;
|
|
186
|
+
copyable?: boolean;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface PrefsRowLink extends PrefsRowBase {
|
|
179
190
|
type: "link";
|
|
180
191
|
value?: string;
|
|
181
192
|
}
|
|
182
193
|
|
|
183
|
-
interface PrefsRowAction extends PrefsRowBase {
|
|
194
|
+
export interface PrefsRowAction extends PrefsRowBase {
|
|
184
195
|
type: "action";
|
|
185
196
|
value?: () => void;
|
|
186
197
|
destructive?: boolean;
|
|
187
198
|
}
|
|
188
199
|
|
|
200
|
+
export const selectableTypes = [
|
|
201
|
+
"string",
|
|
202
|
+
"number",
|
|
203
|
+
"integer",
|
|
204
|
+
"stepper",
|
|
205
|
+
"list",
|
|
206
|
+
"interactive-info",
|
|
207
|
+
"link",
|
|
208
|
+
"action"
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
export const excludedTypes = [
|
|
212
|
+
"info",
|
|
213
|
+
"interactive-info",
|
|
214
|
+
"link",
|
|
215
|
+
"action"
|
|
216
|
+
];
|
|
217
|
+
|
|
189
218
|
type PreferenceValues = { [key: string]: any };
|
|
190
219
|
|
|
191
|
-
type AllCells = StringCell | NumberCell | IntegerCell | StepperCell | BooleanCell | SliderCell | ListCell | TabCell | InfoCell | LinkCell | ActionCell;
|
|
220
|
+
type AllCells = StringCell | NumberCell | IntegerCell | StepperCell | BooleanCell | SliderCell | ListCell | TabCell | InteractiveInfoCell | InfoCell | LinkCell | ActionCell;
|
|
192
221
|
|
|
193
222
|
abstract class Cell extends Base<UIView, UiTypes.ViewOptions> {
|
|
194
223
|
abstract _type: string;
|
|
@@ -221,15 +250,6 @@ abstract class Cell extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
221
250
|
this._titleColor = titleColor;
|
|
222
251
|
this._changedEvent = changedEvent;
|
|
223
252
|
this._values = values;
|
|
224
|
-
const selectableTypes = [
|
|
225
|
-
"string",
|
|
226
|
-
"number",
|
|
227
|
-
"integer",
|
|
228
|
-
"stepper",
|
|
229
|
-
"list",
|
|
230
|
-
"link",
|
|
231
|
-
"action"
|
|
232
|
-
];
|
|
233
253
|
this._defineView = () => {
|
|
234
254
|
return {
|
|
235
255
|
type: "view",
|
|
@@ -743,6 +763,39 @@ class InfoCell extends Cell {
|
|
|
743
763
|
}
|
|
744
764
|
}
|
|
745
765
|
|
|
766
|
+
class InteractiveInfoCell extends Cell {
|
|
767
|
+
readonly _type = "interactive-info";
|
|
768
|
+
_copyable: boolean;
|
|
769
|
+
constructor(props: PrefsRowInteractiveInfo, values: PreferenceValues) {
|
|
770
|
+
super(props, values);
|
|
771
|
+
const { copyable = false } = props;
|
|
772
|
+
this._copyable = copyable;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
_defineValueView(): UiTypes.LabelOptions {
|
|
776
|
+
return {
|
|
777
|
+
type: "label",
|
|
778
|
+
props: {
|
|
779
|
+
id: "label",
|
|
780
|
+
text: this._value,
|
|
781
|
+
textColor: $color("secondaryText"),
|
|
782
|
+
align: $align.right
|
|
783
|
+
},
|
|
784
|
+
layout: (make, view) => {
|
|
785
|
+
make.top.bottom.inset(0);
|
|
786
|
+
make.left.equalTo(view.prev.right).inset(10);
|
|
787
|
+
make.right.inset(15);
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
_handleValue(text: string) {
|
|
793
|
+
const label = this.view.get("label") as UILabelView;
|
|
794
|
+
label.text = text;
|
|
795
|
+
return text;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
746
799
|
class LinkCell extends Cell {
|
|
747
800
|
readonly _type = "link";
|
|
748
801
|
constructor(props: PrefsRowLink, values: PreferenceValues) {
|
|
@@ -850,7 +903,6 @@ export class PreferenceListView extends Base<UIListView, UiTypes.ListOptions> {
|
|
|
850
903
|
super();
|
|
851
904
|
this._sections = sections;
|
|
852
905
|
this._values = {};
|
|
853
|
-
const excludedTypes = ["action", "info", "link"];
|
|
854
906
|
sections.forEach(section => {
|
|
855
907
|
section.rows.forEach(row => {
|
|
856
908
|
if (row.key && !excludedTypes.includes(row.type)) {
|
|
@@ -931,6 +983,31 @@ export class PreferenceListView extends Base<UIListView, UiTypes.ListOptions> {
|
|
|
931
983
|
});
|
|
932
984
|
break;
|
|
933
985
|
}
|
|
986
|
+
case "interactive-info": {
|
|
987
|
+
if (cell._copyable) {
|
|
988
|
+
$ui.alert({
|
|
989
|
+
title: cell._title,
|
|
990
|
+
message: cell.value,
|
|
991
|
+
actions: [
|
|
992
|
+
{
|
|
993
|
+
title: "取消"
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
title: "复制",
|
|
997
|
+
handler: () => {
|
|
998
|
+
$clipboard.text = cell.value;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
]
|
|
1002
|
+
})
|
|
1003
|
+
} else {
|
|
1004
|
+
$ui.alert({
|
|
1005
|
+
title: cell._title,
|
|
1006
|
+
message: cell.value
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
break;
|
|
1010
|
+
}
|
|
934
1011
|
case "link": {
|
|
935
1012
|
$safari.open({ url: cell.value });
|
|
936
1013
|
break;
|
|
@@ -968,6 +1045,8 @@ export class PreferenceListView extends Base<UIListView, UiTypes.ListOptions> {
|
|
|
968
1045
|
return new TabCell(props, this._values);
|
|
969
1046
|
case "info":
|
|
970
1047
|
return new InfoCell(props, this._values);
|
|
1048
|
+
case "interactive-info":
|
|
1049
|
+
return new InteractiveInfoCell(props, this._values);
|
|
971
1050
|
case "link":
|
|
972
1051
|
return new LinkCell(props, this._values);
|
|
973
1052
|
case "action":
|
|
@@ -28,15 +28,7 @@
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.DynamicPreferenceListView = void 0;
|
|
30
30
|
const base_1 = require("./base");
|
|
31
|
-
const
|
|
32
|
-
"string",
|
|
33
|
-
"number",
|
|
34
|
-
"integer",
|
|
35
|
-
"stepper",
|
|
36
|
-
"list",
|
|
37
|
-
"link",
|
|
38
|
-
"action"
|
|
39
|
-
];
|
|
31
|
+
const static_preference_listview_1 = require("./static-preference-listview");
|
|
40
32
|
class DynamicPreferenceListView extends base_1.Base {
|
|
41
33
|
constructor({ sections, props, layout, events = {} }) {
|
|
42
34
|
super();
|
|
@@ -266,7 +258,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
266
258
|
events: {
|
|
267
259
|
didSelect: (sender, indexPath, data) => {
|
|
268
260
|
const row = this._sections[indexPath.section].rows[indexPath.row];
|
|
269
|
-
if (!selectableTypes.includes(row.type))
|
|
261
|
+
if (!static_preference_listview_1.selectableTypes.includes(row.type))
|
|
270
262
|
return;
|
|
271
263
|
switch (row.type) {
|
|
272
264
|
case "string": {
|
|
@@ -334,6 +326,32 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
334
326
|
});
|
|
335
327
|
break;
|
|
336
328
|
}
|
|
329
|
+
case "interactive-info": {
|
|
330
|
+
if (row.copyable) {
|
|
331
|
+
$ui.alert({
|
|
332
|
+
title: row.title,
|
|
333
|
+
message: row.value,
|
|
334
|
+
actions: [
|
|
335
|
+
{
|
|
336
|
+
title: "取消"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
title: "复制",
|
|
340
|
+
handler: () => {
|
|
341
|
+
$clipboard.text = row.value || "";
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
]
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
$ui.alert({
|
|
349
|
+
title: row.title,
|
|
350
|
+
message: row.value
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
337
355
|
case "link": {
|
|
338
356
|
if (row.value)
|
|
339
357
|
$safari.open({ url: row.value });
|
|
@@ -393,7 +411,7 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
393
411
|
_map(sections) {
|
|
394
412
|
function generateDefaultRow(options) {
|
|
395
413
|
return {
|
|
396
|
-
bgview: { hidden: selectableTypes.includes(options.type) }, // bgview其实是用于调整selectable, 显示此视图就没有highlight效果
|
|
414
|
+
bgview: { hidden: static_preference_listview_1.selectableTypes.includes(options.type) }, // bgview其实是用于调整selectable, 显示此视图就没有highlight效果
|
|
397
415
|
title: {
|
|
398
416
|
text: options.title,
|
|
399
417
|
textColor: options.titleColor || $color("primaryText")
|
|
@@ -502,6 +520,14 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
502
520
|
};
|
|
503
521
|
break;
|
|
504
522
|
}
|
|
523
|
+
case "interactive-info": {
|
|
524
|
+
data.label_info_link = {
|
|
525
|
+
hidden: false,
|
|
526
|
+
textColor: $color("secondaryText"),
|
|
527
|
+
text: n.value
|
|
528
|
+
};
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
505
531
|
case "link": {
|
|
506
532
|
data.label_info_link = {
|
|
507
533
|
hidden: false,
|
|
@@ -534,10 +560,9 @@ class DynamicPreferenceListView extends base_1.Base {
|
|
|
534
560
|
}
|
|
535
561
|
get values() {
|
|
536
562
|
const values = {};
|
|
537
|
-
const excludedTypes = ["action", "info", "link"];
|
|
538
563
|
this._sections.forEach(section => {
|
|
539
564
|
section.rows.forEach(row => {
|
|
540
|
-
if (row.key && !excludedTypes.includes(row.type)) {
|
|
565
|
+
if (row.key && !static_preference_listview_1.excludedTypes.includes(row.type)) {
|
|
541
566
|
values[row.key] = row.value;
|
|
542
567
|
}
|
|
543
568
|
});
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* - 通用:
|
|
15
15
|
*
|
|
16
|
-
* - type: string 类型. 包括'string', 'number', 'integer', 'stepper','boolean', 'slider', 'list', 'tab','info', 'link', 'action'
|
|
16
|
+
* - type: string 类型. 包括'string', 'number', 'integer', 'stepper','boolean', 'slider', 'list', 'tab', 'interactive-info', 'info', 'link', 'action'
|
|
17
17
|
* - key?: string 键. 如没有则不会返回其值.
|
|
18
18
|
* - title?: string 标题
|
|
19
19
|
* - value?: any 在下面专项里详解.
|
|
@@ -70,6 +70,11 @@
|
|
|
70
70
|
*
|
|
71
71
|
* - value?: string
|
|
72
72
|
*
|
|
73
|
+
* - interactive-info:
|
|
74
|
+
*
|
|
75
|
+
* - value?: string
|
|
76
|
+
* - copyable?: boolean = false
|
|
77
|
+
*
|
|
73
78
|
* - link:
|
|
74
79
|
*
|
|
75
80
|
* - value?: string url
|
|
@@ -89,9 +94,25 @@
|
|
|
89
94
|
* - changed: values => {}
|
|
90
95
|
*/
|
|
91
96
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
92
|
-
exports.PreferenceListView = void 0;
|
|
97
|
+
exports.PreferenceListView = exports.excludedTypes = exports.selectableTypes = void 0;
|
|
93
98
|
const base_1 = require("./base");
|
|
94
99
|
const uitools_1 = require("../utils/uitools");
|
|
100
|
+
exports.selectableTypes = [
|
|
101
|
+
"string",
|
|
102
|
+
"number",
|
|
103
|
+
"integer",
|
|
104
|
+
"stepper",
|
|
105
|
+
"list",
|
|
106
|
+
"interactive-info",
|
|
107
|
+
"link",
|
|
108
|
+
"action"
|
|
109
|
+
];
|
|
110
|
+
exports.excludedTypes = [
|
|
111
|
+
"info",
|
|
112
|
+
"interactive-info",
|
|
113
|
+
"link",
|
|
114
|
+
"action"
|
|
115
|
+
];
|
|
95
116
|
class Cell extends base_1.Base {
|
|
96
117
|
constructor({ key, title, value, titleColor = $color("primaryText"), changedEvent }, values) {
|
|
97
118
|
super();
|
|
@@ -101,20 +122,11 @@ class Cell extends base_1.Base {
|
|
|
101
122
|
this._titleColor = titleColor;
|
|
102
123
|
this._changedEvent = changedEvent;
|
|
103
124
|
this._values = values;
|
|
104
|
-
const selectableTypes = [
|
|
105
|
-
"string",
|
|
106
|
-
"number",
|
|
107
|
-
"integer",
|
|
108
|
-
"stepper",
|
|
109
|
-
"list",
|
|
110
|
-
"link",
|
|
111
|
-
"action"
|
|
112
|
-
];
|
|
113
125
|
this._defineView = () => {
|
|
114
126
|
return {
|
|
115
127
|
type: "view",
|
|
116
128
|
props: {
|
|
117
|
-
selectable: selectableTypes.includes(this._type),
|
|
129
|
+
selectable: exports.selectableTypes.includes(this._type),
|
|
118
130
|
id: this.id
|
|
119
131
|
},
|
|
120
132
|
layout: $layout.fill,
|
|
@@ -577,6 +589,35 @@ class InfoCell extends Cell {
|
|
|
577
589
|
return text;
|
|
578
590
|
}
|
|
579
591
|
}
|
|
592
|
+
class InteractiveInfoCell extends Cell {
|
|
593
|
+
constructor(props, values) {
|
|
594
|
+
super(props, values);
|
|
595
|
+
this._type = "interactive-info";
|
|
596
|
+
const { copyable = false } = props;
|
|
597
|
+
this._copyable = copyable;
|
|
598
|
+
}
|
|
599
|
+
_defineValueView() {
|
|
600
|
+
return {
|
|
601
|
+
type: "label",
|
|
602
|
+
props: {
|
|
603
|
+
id: "label",
|
|
604
|
+
text: this._value,
|
|
605
|
+
textColor: $color("secondaryText"),
|
|
606
|
+
align: $align.right
|
|
607
|
+
},
|
|
608
|
+
layout: (make, view) => {
|
|
609
|
+
make.top.bottom.inset(0);
|
|
610
|
+
make.left.equalTo(view.prev.right).inset(10);
|
|
611
|
+
make.right.inset(15);
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
_handleValue(text) {
|
|
616
|
+
const label = this.view.get("label");
|
|
617
|
+
label.text = text;
|
|
618
|
+
return text;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
580
621
|
class LinkCell extends Cell {
|
|
581
622
|
constructor(props, values) {
|
|
582
623
|
super(props, values);
|
|
@@ -659,10 +700,9 @@ class PreferenceListView extends base_1.Base {
|
|
|
659
700
|
super();
|
|
660
701
|
this._sections = sections;
|
|
661
702
|
this._values = {};
|
|
662
|
-
const excludedTypes = ["action", "info", "link"];
|
|
663
703
|
sections.forEach(section => {
|
|
664
704
|
section.rows.forEach(row => {
|
|
665
|
-
if (row.key && !excludedTypes.includes(row.type)) {
|
|
705
|
+
if (row.key && !exports.excludedTypes.includes(row.type)) {
|
|
666
706
|
this._values[row.key] = row.value;
|
|
667
707
|
}
|
|
668
708
|
});
|
|
@@ -739,6 +779,32 @@ class PreferenceListView extends base_1.Base {
|
|
|
739
779
|
});
|
|
740
780
|
break;
|
|
741
781
|
}
|
|
782
|
+
case "interactive-info": {
|
|
783
|
+
if (cell._copyable) {
|
|
784
|
+
$ui.alert({
|
|
785
|
+
title: cell._title,
|
|
786
|
+
message: cell.value,
|
|
787
|
+
actions: [
|
|
788
|
+
{
|
|
789
|
+
title: "取消"
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
title: "复制",
|
|
793
|
+
handler: () => {
|
|
794
|
+
$clipboard.text = cell.value;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
]
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
else {
|
|
801
|
+
$ui.alert({
|
|
802
|
+
title: cell._title,
|
|
803
|
+
message: cell.value
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
break;
|
|
807
|
+
}
|
|
742
808
|
case "link": {
|
|
743
809
|
$safari.open({ url: cell.value });
|
|
744
810
|
break;
|
|
@@ -775,6 +841,8 @@ class PreferenceListView extends base_1.Base {
|
|
|
775
841
|
return new TabCell(props, this._values);
|
|
776
842
|
case "info":
|
|
777
843
|
return new InfoCell(props, this._values);
|
|
844
|
+
case "interactive-info":
|
|
845
|
+
return new InteractiveInfoCell(props, this._values);
|
|
778
846
|
case "link":
|
|
779
847
|
return new LinkCell(props, this._values);
|
|
780
848
|
case "action":
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const dynamic_preference_listview_1 = require("../components/dynamic-preference-listview");
|
|
4
|
+
const sections = [
|
|
5
|
+
{
|
|
6
|
+
title: "Section 1",
|
|
7
|
+
rows: [
|
|
8
|
+
{
|
|
9
|
+
type: "string",
|
|
10
|
+
title: "string",
|
|
11
|
+
key: "string",
|
|
12
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: "number",
|
|
16
|
+
title: "number",
|
|
17
|
+
key: "number",
|
|
18
|
+
value: 1111.1
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: "integer",
|
|
22
|
+
title: "integer",
|
|
23
|
+
key: "integer",
|
|
24
|
+
value: 1111
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: "stepper",
|
|
28
|
+
title: "stepper",
|
|
29
|
+
key: "stepper",
|
|
30
|
+
value: 2,
|
|
31
|
+
min: 2,
|
|
32
|
+
max: 5
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
title: "Section 2",
|
|
38
|
+
rows: [
|
|
39
|
+
{
|
|
40
|
+
type: "boolean",
|
|
41
|
+
title: "boolean",
|
|
42
|
+
key: "boolean",
|
|
43
|
+
value: true
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "slider",
|
|
47
|
+
title: "slider",
|
|
48
|
+
key: "slider",
|
|
49
|
+
value: 1,
|
|
50
|
+
decimal: 0,
|
|
51
|
+
min: 0,
|
|
52
|
+
max: 100
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: "list",
|
|
56
|
+
title: "list",
|
|
57
|
+
key: "list",
|
|
58
|
+
items: ["测试一号", "测试bbb"],
|
|
59
|
+
value: 0
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: "tab",
|
|
63
|
+
title: "tab",
|
|
64
|
+
key: "tab",
|
|
65
|
+
items: ["测试aaa", "测试bbb"],
|
|
66
|
+
value: 0
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
title: "Section 3",
|
|
72
|
+
rows: [
|
|
73
|
+
{
|
|
74
|
+
type: "info",
|
|
75
|
+
title: "info",
|
|
76
|
+
value: "this is info"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: "link",
|
|
80
|
+
title: "link",
|
|
81
|
+
value: "https://apple.com"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: "action",
|
|
85
|
+
title: "action",
|
|
86
|
+
value: () => console.info(0)
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
const v = new dynamic_preference_listview_1.DynamicPreferenceListView({
|
|
92
|
+
props: { data: [] },
|
|
93
|
+
sections: sections,
|
|
94
|
+
layout: $layout.fill,
|
|
95
|
+
events: {
|
|
96
|
+
changed: (values) => console.info(values)
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
$ui.render({
|
|
100
|
+
props: {
|
|
101
|
+
title: "",
|
|
102
|
+
navButtons: [
|
|
103
|
+
{
|
|
104
|
+
symbol: "plus",
|
|
105
|
+
handler: () => {
|
|
106
|
+
sections.push({
|
|
107
|
+
title: "Section " + (sections.length + 1),
|
|
108
|
+
rows: [
|
|
109
|
+
{
|
|
110
|
+
type: "interactive-info",
|
|
111
|
+
title: "interactive-info",
|
|
112
|
+
key: "interactive-info",
|
|
113
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
type: "interactive-info",
|
|
117
|
+
title: "interactive-info2",
|
|
118
|
+
key: "interactive-info2",
|
|
119
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号",
|
|
120
|
+
copyable: true
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
});
|
|
124
|
+
v.sections = sections;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
views: [v.definition]
|
|
130
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const static_preference_listview_1 = require("../components/static-preference-listview");
|
|
4
|
+
const sections = [
|
|
5
|
+
{
|
|
6
|
+
title: "Section 1",
|
|
7
|
+
rows: [
|
|
8
|
+
{
|
|
9
|
+
type: "string",
|
|
10
|
+
title: "string",
|
|
11
|
+
key: "string",
|
|
12
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: "number",
|
|
16
|
+
title: "number",
|
|
17
|
+
key: "number",
|
|
18
|
+
value: 1111.1
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: "integer",
|
|
22
|
+
title: "integer",
|
|
23
|
+
key: "integer",
|
|
24
|
+
value: 1111
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: "stepper",
|
|
28
|
+
title: "stepper",
|
|
29
|
+
key: "stepper",
|
|
30
|
+
value: 2,
|
|
31
|
+
min: 2,
|
|
32
|
+
max: 5
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
title: "Section 2",
|
|
38
|
+
rows: [
|
|
39
|
+
{
|
|
40
|
+
type: "boolean",
|
|
41
|
+
title: "boolean",
|
|
42
|
+
key: "boolean",
|
|
43
|
+
value: true
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "slider",
|
|
47
|
+
title: "slider",
|
|
48
|
+
key: "slider",
|
|
49
|
+
value: 1,
|
|
50
|
+
decimal: 0,
|
|
51
|
+
min: 0,
|
|
52
|
+
max: 100
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: "list",
|
|
56
|
+
title: "list",
|
|
57
|
+
key: "list",
|
|
58
|
+
items: ["测试一号", "测试bbb"],
|
|
59
|
+
value: 0
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: "tab",
|
|
63
|
+
title: "tab",
|
|
64
|
+
key: "tab",
|
|
65
|
+
items: ["测试aaa", "测试bbb"],
|
|
66
|
+
value: 0
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
title: "Section 3",
|
|
72
|
+
rows: [
|
|
73
|
+
{
|
|
74
|
+
type: "info",
|
|
75
|
+
title: "info",
|
|
76
|
+
value: "this is info"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: "link",
|
|
80
|
+
title: "link",
|
|
81
|
+
value: "https://apple.com"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: "action",
|
|
85
|
+
title: "action",
|
|
86
|
+
value: () => console.info(0)
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
title: "Section 4",
|
|
92
|
+
rows: [
|
|
93
|
+
{
|
|
94
|
+
type: "interactive-info",
|
|
95
|
+
title: "interactive-info",
|
|
96
|
+
key: "interactive-info",
|
|
97
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: "interactive-info",
|
|
101
|
+
title: "interactive-info2",
|
|
102
|
+
key: "interactive-info2",
|
|
103
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号",
|
|
104
|
+
copyable: true
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
];
|
|
109
|
+
const v = new static_preference_listview_1.PreferenceListView({
|
|
110
|
+
props: { data: [] },
|
|
111
|
+
sections: sections,
|
|
112
|
+
layout: $layout.fill,
|
|
113
|
+
events: {
|
|
114
|
+
changed: (values) => console.info(values)
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
$ui.render({
|
|
118
|
+
props: {
|
|
119
|
+
title: "",
|
|
120
|
+
navButtons: [
|
|
121
|
+
{
|
|
122
|
+
symbol: "plus",
|
|
123
|
+
handler: () => {
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
views: [v.definition]
|
|
129
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsbox-cview",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "为 JSBox 设计的微型框架",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "^20.11.17",
|
|
21
|
-
"
|
|
21
|
+
"browserify": "^17.0.0",
|
|
22
22
|
"jsbox-types": "^1.0.19"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { DynamicPreferenceListView } from "../components/dynamic-preference-listview";
|
|
2
|
+
import { PreferenceSection } from "../components/static-preference-listview";
|
|
3
|
+
|
|
4
|
+
const sections: PreferenceSection[] = [
|
|
5
|
+
{
|
|
6
|
+
title: "Section 1",
|
|
7
|
+
rows: [
|
|
8
|
+
{
|
|
9
|
+
type: "string",
|
|
10
|
+
title: "string",
|
|
11
|
+
key: "string",
|
|
12
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: "number",
|
|
16
|
+
title: "number",
|
|
17
|
+
key: "number",
|
|
18
|
+
value: 1111.1
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: "integer",
|
|
22
|
+
title: "integer",
|
|
23
|
+
key: "integer",
|
|
24
|
+
value: 1111
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: "stepper",
|
|
28
|
+
title: "stepper",
|
|
29
|
+
key: "stepper",
|
|
30
|
+
value: 2,
|
|
31
|
+
min: 2,
|
|
32
|
+
max: 5
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
title: "Section 2",
|
|
38
|
+
rows: [
|
|
39
|
+
{
|
|
40
|
+
type: "boolean",
|
|
41
|
+
title: "boolean",
|
|
42
|
+
key: "boolean",
|
|
43
|
+
value: true
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "slider",
|
|
47
|
+
title: "slider",
|
|
48
|
+
key: "slider",
|
|
49
|
+
value: 1,
|
|
50
|
+
decimal: 0,
|
|
51
|
+
min: 0,
|
|
52
|
+
max: 100
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: "list",
|
|
56
|
+
title: "list",
|
|
57
|
+
key: "list",
|
|
58
|
+
items: ["测试一号", "测试bbb"],
|
|
59
|
+
value: 0
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: "tab",
|
|
63
|
+
title: "tab",
|
|
64
|
+
key: "tab",
|
|
65
|
+
items: ["测试aaa", "测试bbb"],
|
|
66
|
+
value: 0
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
title: "Section 3",
|
|
72
|
+
rows: [
|
|
73
|
+
{
|
|
74
|
+
type: "info",
|
|
75
|
+
title: "info",
|
|
76
|
+
value: "this is info"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: "link",
|
|
80
|
+
title: "link",
|
|
81
|
+
value: "https://apple.com"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: "action",
|
|
85
|
+
title: "action",
|
|
86
|
+
value: () => console.info(0)
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
const v = new DynamicPreferenceListView({
|
|
92
|
+
props: {data: []},
|
|
93
|
+
sections: sections,
|
|
94
|
+
layout: $layout.fill,
|
|
95
|
+
events: {
|
|
96
|
+
changed: (values: any) => console.info(values)
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
$ui.render({
|
|
101
|
+
props: {
|
|
102
|
+
title: "",
|
|
103
|
+
navButtons: [
|
|
104
|
+
{
|
|
105
|
+
symbol: "plus",
|
|
106
|
+
handler: () => {
|
|
107
|
+
sections.push({
|
|
108
|
+
title: "Section " + (sections.length + 1),
|
|
109
|
+
rows: [
|
|
110
|
+
{
|
|
111
|
+
type: "interactive-info",
|
|
112
|
+
title: "interactive-info",
|
|
113
|
+
key: "interactive-info",
|
|
114
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: "interactive-info",
|
|
118
|
+
title: "interactive-info2",
|
|
119
|
+
key: "interactive-info2",
|
|
120
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号",
|
|
121
|
+
copyable: true
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
})
|
|
125
|
+
v.sections = sections
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
views: [v.definition]
|
|
131
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { PreferenceListView, PreferenceSection } from "../components/static-preference-listview";
|
|
2
|
+
const sections: PreferenceSection[] = [
|
|
3
|
+
{
|
|
4
|
+
title: "Section 1",
|
|
5
|
+
rows: [
|
|
6
|
+
{
|
|
7
|
+
type: "string",
|
|
8
|
+
title: "string",
|
|
9
|
+
key: "string",
|
|
10
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
type: "number",
|
|
14
|
+
title: "number",
|
|
15
|
+
key: "number",
|
|
16
|
+
value: 1111.1
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: "integer",
|
|
20
|
+
title: "integer",
|
|
21
|
+
key: "integer",
|
|
22
|
+
value: 1111
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: "stepper",
|
|
26
|
+
title: "stepper",
|
|
27
|
+
key: "stepper",
|
|
28
|
+
value: 2,
|
|
29
|
+
min: 2,
|
|
30
|
+
max: 5
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: "Section 2",
|
|
36
|
+
rows: [
|
|
37
|
+
{
|
|
38
|
+
type: "boolean",
|
|
39
|
+
title: "boolean",
|
|
40
|
+
key: "boolean",
|
|
41
|
+
value: true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: "slider",
|
|
45
|
+
title: "slider",
|
|
46
|
+
key: "slider",
|
|
47
|
+
value: 1,
|
|
48
|
+
decimal: 0,
|
|
49
|
+
min: 0,
|
|
50
|
+
max: 100
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: "list",
|
|
54
|
+
title: "list",
|
|
55
|
+
key: "list",
|
|
56
|
+
items: ["测试一号", "测试bbb"],
|
|
57
|
+
value: 0
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: "tab",
|
|
61
|
+
title: "tab",
|
|
62
|
+
key: "tab",
|
|
63
|
+
items: ["测试aaa", "测试bbb"],
|
|
64
|
+
value: 0
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
title: "Section 3",
|
|
70
|
+
rows: [
|
|
71
|
+
{
|
|
72
|
+
type: "info",
|
|
73
|
+
title: "info",
|
|
74
|
+
value: "this is info"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: "link",
|
|
78
|
+
title: "link",
|
|
79
|
+
value: "https://apple.com"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: "action",
|
|
83
|
+
title: "action",
|
|
84
|
+
value: () => console.info(0)
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
title: "Section 4",
|
|
90
|
+
rows: [
|
|
91
|
+
{
|
|
92
|
+
type: "interactive-info",
|
|
93
|
+
title: "interactive-info",
|
|
94
|
+
key: "interactive-info",
|
|
95
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: "interactive-info",
|
|
99
|
+
title: "interactive-info2",
|
|
100
|
+
key: "interactive-info2",
|
|
101
|
+
value: "测试一号测试二号测试三号测试四号测试五号测试六号",
|
|
102
|
+
copyable: true
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
const v = new PreferenceListView({
|
|
108
|
+
props: {data: []},
|
|
109
|
+
sections: sections,
|
|
110
|
+
layout: $layout.fill,
|
|
111
|
+
events: {
|
|
112
|
+
changed: (values: any) => console.info(values)
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
$ui.render({
|
|
117
|
+
props: {
|
|
118
|
+
title: "",
|
|
119
|
+
navButtons: [
|
|
120
|
+
{
|
|
121
|
+
symbol: "plus",
|
|
122
|
+
handler: () => {
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
views: [v.definition]
|
|
129
|
+
});
|
package/tsconfig.json
CHANGED
package/dist/test.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/test.ts
DELETED
|
File without changes
|