jsbox-cview 1.5.26 → 1.5.27

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.
@@ -14,6 +14,7 @@ import {
14
14
  PrefsRowInfo,
15
15
  PrefsRowInteractiveInfo,
16
16
  PrefsRowLink,
17
+ PrefsRowSymbolAction,
17
18
  PrefsRowAction,
18
19
  selectableTypes,
19
20
  excludedTypes,
@@ -25,6 +26,7 @@ interface CunstomProps extends UiTypes.ListProps {
25
26
  infoAndLinkLeftInset?: number;
26
27
  sliderWidth?: number;
27
28
  tabWidth?: number;
29
+ symbolSizeForSymbolAction?: JBSize;
28
30
  }
29
31
 
30
32
  interface RequiredCunstomProps extends UiTypes.ListProps {
@@ -32,6 +34,7 @@ interface RequiredCunstomProps extends UiTypes.ListProps {
32
34
  infoAndLinkLeftInset: number;
33
35
  sliderWidth: number;
34
36
  tabWidth: number;
37
+ symbolSizeForSymbolAction: JBSize;
35
38
  }
36
39
 
37
40
  /**
@@ -55,6 +58,7 @@ interface RequiredCunstomProps extends UiTypes.ListProps {
55
58
  * - infoAndLinkLeftInset?: number = 120 作用于 info, link
56
59
  * - sliderWidth?: number = 200 作用于 slider
57
60
  * - tabWidth?: number = 200 作用于 tab
61
+ * - symbolSizeForSymbolAction?: size = $size(24, 24) 作用于symbol-action
58
62
  * 注意以上的修改是应用于 template, 而不是应用于单个 cell 的
59
63
  *
60
64
  * 独特方法:
@@ -91,6 +95,7 @@ export class DynamicPreferenceListView extends Base<
91
95
  infoAndLinkLeftInset: 120,
92
96
  sliderWidth: 200,
93
97
  tabWidth: 200,
98
+ symbolSizeForSymbolAction: $size(24, 24),
94
99
  ...props,
95
100
  };
96
101
  this._layout = layout;
@@ -317,6 +322,17 @@ export class DynamicPreferenceListView extends Base<
317
322
  make.right.inset(0);
318
323
  },
319
324
  },
325
+ {
326
+ type: "image",
327
+ props: {
328
+ id: "symbol",
329
+ },
330
+ layout: (make, view) => {
331
+ make.centerY.equalTo(view.super);
332
+ make.size.equalTo(this._props.symbolSizeForSymbolAction);
333
+ make.right.inset(0);
334
+ },
335
+ },
320
336
  ],
321
337
  },
322
338
  ],
@@ -433,6 +449,10 @@ export class DynamicPreferenceListView extends Base<
433
449
  if (row.value) $safari.open({ url: row.value });
434
450
  break;
435
451
  }
452
+ case "symbol-action": {
453
+ if (row.value) row.value();
454
+ break;
455
+ }
436
456
  case "action": {
437
457
  if (row.value) row.value();
438
458
  break;
@@ -499,6 +519,7 @@ export class DynamicPreferenceListView extends Base<
499
519
  switch: { hidden: true }, // 用于boolean
500
520
  tab: { hidden: true }, // 用于tab
501
521
  label_info_link: { hidden: true }, // 用于info, link
522
+ symbol: { hidden: true },
502
523
  };
503
524
  }
504
525
  return sections.map((section, sectionIndex) => ({
@@ -626,6 +647,15 @@ export class DynamicPreferenceListView extends Base<
626
647
  };
627
648
  break;
628
649
  }
650
+ case "symbol-action": {
651
+ data.symbol = {
652
+ hidden: false,
653
+ symbol: n.symbol,
654
+ tintColor: n.tintColor ?? $color("primaryText"),
655
+ contentMode: n.contentMode ?? 1,
656
+ };
657
+ break;
658
+ }
629
659
  case "action": {
630
660
  data.title.textColor = n.destructive
631
661
  ? $color("red")
@@ -14,6 +14,7 @@ type PreferenceCellTypes =
14
14
  | "info"
15
15
  | "interactive-info"
16
16
  | "link"
17
+ | "symbol-action"
17
18
  | "action";
18
19
 
19
20
  export interface PreferenceSection {
@@ -34,6 +35,7 @@ export type PrefsRow =
34
35
  | PrefsRowInfo
35
36
  | PrefsRowInteractiveInfo
36
37
  | PrefsRowLink
38
+ | PrefsRowSymbolAction
37
39
  | PrefsRowAction;
38
40
 
39
41
  interface PrefsRowBase {
@@ -131,6 +133,15 @@ export interface PrefsRowLink extends PrefsRowBase {
131
133
  value?: string;
132
134
  }
133
135
 
136
+ export interface PrefsRowSymbolAction extends PrefsRowBase {
137
+ type: "symbol-action";
138
+ symbol?: string;
139
+ tintColor?: UIColor;
140
+ contentMode?: number;
141
+ symbolSize?: JBSize;
142
+ value?: () => void;
143
+ }
144
+
134
145
  export interface PrefsRowAction extends PrefsRowBase {
135
146
  type: "action";
136
147
  value?: () => void;
@@ -146,10 +157,17 @@ export const selectableTypes = [
146
157
  "date",
147
158
  "interactive-info",
148
159
  "link",
160
+ "symbol-action",
149
161
  "action",
150
162
  ];
151
163
 
152
- export const excludedTypes = ["info", "interactive-info", "link", "action"];
164
+ export const excludedTypes = [
165
+ "info",
166
+ "interactive-info",
167
+ "link",
168
+ "symbol-action",
169
+ "action",
170
+ ];
153
171
 
154
172
  type PreferenceValues = { [key: string]: any };
155
173
 
@@ -166,6 +184,7 @@ type AllCells =
166
184
  | InteractiveInfoCell
167
185
  | InfoCell
168
186
  | LinkCell
187
+ | SymbolActionCell
169
188
  | ActionCell;
170
189
 
171
190
  abstract class Cell extends Base<UIView, UiTypes.ViewOptions> {
@@ -875,6 +894,42 @@ class LinkCell extends Cell {
875
894
  }
876
895
  }
877
896
 
897
+ class SymbolActionCell extends Cell {
898
+ readonly _type = "symbol-action";
899
+ _symbol: string;
900
+ _tintColor: UIColor;
901
+ _contentMode: number;
902
+ _symbolSize: JBSize;
903
+ constructor(props: PrefsRowSymbolAction, values: PreferenceValues) {
904
+ super(props, values);
905
+ this._symbol = props.symbol || "";
906
+ this._tintColor = props.tintColor ?? $color("primaryText");
907
+ this._contentMode = props.contentMode ?? 1;
908
+ this._symbolSize = props.symbolSize ?? $size(24, 24);
909
+ }
910
+
911
+ _defineValueView(): UiTypes.ImageOptions {
912
+ return {
913
+ type: "image",
914
+ props: {
915
+ id: "image",
916
+ symbol: this._symbol,
917
+ tintColor: this._tintColor,
918
+ contentMode: this._contentMode,
919
+ },
920
+ layout: (make, view) => {
921
+ make.centerY.equalTo(view.super);
922
+ make.size.equalTo(this._symbolSize);
923
+ make.right.inset(15);
924
+ },
925
+ };
926
+ }
927
+
928
+ _handleValue() {
929
+ return;
930
+ }
931
+ }
932
+
878
933
  class ActionCell extends Cell {
879
934
  readonly _type = "action";
880
935
  _destructive: boolean;
@@ -1005,6 +1060,14 @@ class ActionCell extends Cell {
1005
1060
  *
1006
1061
  * - value?: string url
1007
1062
  *
1063
+ * - symbol-action:
1064
+ *
1065
+ * - symbol?: string;
1066
+ * - tintColor?: UIColor;
1067
+ * - contentMode?: number;
1068
+ * - symbolSize?: JBSize;
1069
+ * - value?: function 点击后会执行的函数
1070
+ *
1008
1071
  * - action:
1009
1072
  *
1010
1073
  * - value?: function 点击后会执行的函数
@@ -1173,8 +1236,12 @@ export class PreferenceListView extends Base<UIListView, UiTypes.ListOptions> {
1173
1236
  $safari.open({ url: cell.value });
1174
1237
  break;
1175
1238
  }
1239
+ case "symbol-action": {
1240
+ if (cell.value) cell.value();
1241
+ break;
1242
+ }
1176
1243
  case "action": {
1177
- cell.value();
1244
+ if (cell.value) cell.value();
1178
1245
  break;
1179
1246
  }
1180
1247
  default:
@@ -1212,6 +1279,8 @@ export class PreferenceListView extends Base<UIListView, UiTypes.ListOptions> {
1212
1279
  return new InteractiveInfoCell(props, this._values);
1213
1280
  case "link":
1214
1281
  return new LinkCell(props, this._values);
1282
+ case "symbol-action":
1283
+ return new SymbolActionCell(props, this._values);
1215
1284
  case "action":
1216
1285
  return new ActionCell(props, this._values);
1217
1286
  default:
@@ -24,6 +24,7 @@ const static_preference_listview_1 = require("./static-preference-listview");
24
24
  * - infoAndLinkLeftInset?: number = 120 作用于 info, link
25
25
  * - sliderWidth?: number = 200 作用于 slider
26
26
  * - tabWidth?: number = 200 作用于 tab
27
+ * - symbolSizeForSymbolAction?: size = $size(24, 24) 作用于symbol-action
27
28
  * 注意以上的修改是应用于 template, 而不是应用于单个 cell 的
28
29
  *
29
30
  * 独特方法:
@@ -37,7 +38,7 @@ class DynamicPreferenceListView extends base_1.Base {
37
38
  title: n.title,
38
39
  rows: n.rows.map((r) => (Object.assign({}, r))),
39
40
  }));
40
- this._props = Object.assign({ stringLeftInset: 120, infoAndLinkLeftInset: 120, sliderWidth: 200, tabWidth: 200 }, props);
41
+ this._props = Object.assign({ stringLeftInset: 120, infoAndLinkLeftInset: 120, sliderWidth: 200, tabWidth: 200, symbolSizeForSymbolAction: $size(24, 24) }, props);
41
42
  this._layout = layout;
42
43
  this._defineView = () => {
43
44
  return {
@@ -250,6 +251,17 @@ class DynamicPreferenceListView extends base_1.Base {
250
251
  make.right.inset(0);
251
252
  },
252
253
  },
254
+ {
255
+ type: "image",
256
+ props: {
257
+ id: "symbol",
258
+ },
259
+ layout: (make, view) => {
260
+ make.centerY.equalTo(view.super);
261
+ make.size.equalTo(this._props.symbolSizeForSymbolAction);
262
+ make.right.inset(0);
263
+ },
264
+ },
253
265
  ],
254
266
  },
255
267
  ],
@@ -384,6 +396,11 @@ class DynamicPreferenceListView extends base_1.Base {
384
396
  $safari.open({ url: row.value });
385
397
  break;
386
398
  }
399
+ case "symbol-action": {
400
+ if (row.value)
401
+ row.value();
402
+ break;
403
+ }
387
404
  case "action": {
388
405
  if (row.value)
389
406
  row.value();
@@ -451,12 +468,13 @@ class DynamicPreferenceListView extends base_1.Base {
451
468
  switch: { hidden: true }, // 用于boolean
452
469
  tab: { hidden: true }, // 用于tab
453
470
  label_info_link: { hidden: true }, // 用于info, link
471
+ symbol: { hidden: true },
454
472
  };
455
473
  }
456
474
  return sections.map((section, sectionIndex) => ({
457
475
  title: section.title,
458
476
  rows: section.rows.map((n, rowIndex) => {
459
- var _a;
477
+ var _a, _b, _c;
460
478
  const data = generateDefaultRow(n);
461
479
  switch (n.type) {
462
480
  case "string": {
@@ -574,6 +592,15 @@ class DynamicPreferenceListView extends base_1.Base {
574
592
  };
575
593
  break;
576
594
  }
595
+ case "symbol-action": {
596
+ data.symbol = {
597
+ hidden: false,
598
+ symbol: n.symbol,
599
+ tintColor: (_b = n.tintColor) !== null && _b !== void 0 ? _b : $color("primaryText"),
600
+ contentMode: (_c = n.contentMode) !== null && _c !== void 0 ? _c : 1,
601
+ };
602
+ break;
603
+ }
577
604
  case "action": {
578
605
  data.title.textColor = n.destructive
579
606
  ? $color("red")
@@ -12,9 +12,16 @@ exports.selectableTypes = [
12
12
  "date",
13
13
  "interactive-info",
14
14
  "link",
15
+ "symbol-action",
16
+ "action",
17
+ ];
18
+ exports.excludedTypes = [
19
+ "info",
20
+ "interactive-info",
21
+ "link",
22
+ "symbol-action",
15
23
  "action",
16
24
  ];
17
- exports.excludedTypes = ["info", "interactive-info", "link", "action"];
18
25
  class Cell extends base_1.Base {
19
26
  constructor({ key, title, value, titleColor = $color("primaryText"), changedEvent, }, values) {
20
27
  super();
@@ -639,6 +646,36 @@ class LinkCell extends Cell {
639
646
  return text;
640
647
  }
641
648
  }
649
+ class SymbolActionCell extends Cell {
650
+ constructor(props, values) {
651
+ var _a, _b, _c;
652
+ super(props, values);
653
+ this._type = "symbol-action";
654
+ this._symbol = props.symbol || "";
655
+ this._tintColor = (_a = props.tintColor) !== null && _a !== void 0 ? _a : $color("primaryText");
656
+ this._contentMode = (_b = props.contentMode) !== null && _b !== void 0 ? _b : 1;
657
+ this._symbolSize = (_c = props.symbolSize) !== null && _c !== void 0 ? _c : $size(24, 24);
658
+ }
659
+ _defineValueView() {
660
+ return {
661
+ type: "image",
662
+ props: {
663
+ id: "image",
664
+ symbol: this._symbol,
665
+ tintColor: this._tintColor,
666
+ contentMode: this._contentMode,
667
+ },
668
+ layout: (make, view) => {
669
+ make.centerY.equalTo(view.super);
670
+ make.size.equalTo(this._symbolSize);
671
+ make.right.inset(15);
672
+ },
673
+ };
674
+ }
675
+ _handleValue() {
676
+ return;
677
+ }
678
+ }
642
679
  class ActionCell extends Cell {
643
680
  constructor(props, values) {
644
681
  super(props, values);
@@ -764,6 +801,14 @@ class ActionCell extends Cell {
764
801
  *
765
802
  * - value?: string url
766
803
  *
804
+ * - symbol-action:
805
+ *
806
+ * - symbol?: string;
807
+ * - tintColor?: UIColor;
808
+ * - contentMode?: number;
809
+ * - symbolSize?: JBSize;
810
+ * - value?: function 点击后会执行的函数
811
+ *
767
812
  * - action:
768
813
  *
769
814
  * - value?: function 点击后会执行的函数
@@ -917,8 +962,14 @@ class PreferenceListView extends base_1.Base {
917
962
  $safari.open({ url: cell.value });
918
963
  break;
919
964
  }
965
+ case "symbol-action": {
966
+ if (cell.value)
967
+ cell.value();
968
+ break;
969
+ }
920
970
  case "action": {
921
- cell.value();
971
+ if (cell.value)
972
+ cell.value();
922
973
  break;
923
974
  }
924
975
  default:
@@ -955,6 +1006,8 @@ class PreferenceListView extends base_1.Base {
955
1006
  return new InteractiveInfoCell(props, this._values);
956
1007
  case "link":
957
1008
  return new LinkCell(props, this._values);
1009
+ case "symbol-action":
1010
+ return new SymbolActionCell(props, this._values);
958
1011
  case "action":
959
1012
  return new ActionCell(props, this._values);
960
1013
  default:
@@ -86,6 +86,14 @@ const sections = [
86
86
  title: "link",
87
87
  value: "https://apple.com",
88
88
  },
89
+ {
90
+ type: "symbol-action",
91
+ title: "种类1",
92
+ symbol: "checkmark",
93
+ tintColor: $color("systemLink"),
94
+ titleColor: $color("systemLink"),
95
+ value: () => console.info(0),
96
+ },
89
97
  {
90
98
  type: "action",
91
99
  title: "action",
@@ -95,7 +103,10 @@ const sections = [
95
103
  },
96
104
  ];
97
105
  const v = new dynamic_preference_listview_1.DynamicPreferenceListView({
98
- props: { data: [] },
106
+ props: {
107
+ data: [],
108
+ //symbolSizeForSymbolAction: $size(40, 40)
109
+ },
99
110
  sections: sections,
100
111
  layout: $layout.fill,
101
112
  events: {
@@ -87,6 +87,14 @@ const sections = [
87
87
  title: "link",
88
88
  value: "https://apple.com",
89
89
  },
90
+ {
91
+ type: "symbol-action",
92
+ title: "种类1",
93
+ symbol: "checkmark",
94
+ tintColor: $color("systemLink"),
95
+ titleColor: $color("systemLink"),
96
+ value: () => console.info(0),
97
+ },
90
98
  {
91
99
  type: "action",
92
100
  title: "action",
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // 自定义的语义化颜色
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.sectionHeaderColor = exports.gold = exports.searchBarBgcolor = exports.searchBarSymbolColor = exports.footBarDefaultSegmentColor = exports.sheetNavBarColor = void 0;
4
+ exports.sliderMaxColor = exports.sectionHeaderColor = exports.gold = exports.searchBarBgcolor = exports.searchBarSymbolColor = exports.footBarDefaultSegmentColor = exports.sheetNavBarColor = void 0;
5
5
  exports.sheetNavBarColor = $color("tint", $color("tertiarySurface"));
6
6
  exports.footBarDefaultSegmentColor = $color("#b7bec6", "#6e6e6e");
7
7
  exports.searchBarSymbolColor = $color("#777", "#aaa");
@@ -12,3 +12,8 @@ exports.sectionHeaderColor = $color({
12
12
  dark: "#acacac",
13
13
  black: "#ababab",
14
14
  });
15
+ exports.sliderMaxColor = $color({
16
+ light: "#E4E4E6",
17
+ dark: "#38373B",
18
+ black: "#2B2A2E",
19
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsbox-cview",
3
- "version": "1.5.26",
3
+ "version": "1.5.27",
4
4
  "description": "为 JSBox 设计的微型框架",
5
5
  "repository": {
6
6
  "type": "git",
@@ -86,6 +86,14 @@ const sections: PreferenceSection[] = [
86
86
  title: "link",
87
87
  value: "https://apple.com",
88
88
  },
89
+ {
90
+ type: "symbol-action",
91
+ title: "种类1",
92
+ symbol: "checkmark",
93
+ tintColor: $color("systemLink"),
94
+ titleColor: $color("systemLink"),
95
+ value: () => console.info(0),
96
+ },
89
97
  {
90
98
  type: "action",
91
99
  title: "action",
@@ -95,7 +103,10 @@ const sections: PreferenceSection[] = [
95
103
  },
96
104
  ];
97
105
  const v = new DynamicPreferenceListView({
98
- props: { data: [] },
106
+ props: {
107
+ data: [],
108
+ //symbolSizeForSymbolAction: $size(40, 40)
109
+ },
99
110
  sections: sections,
100
111
  layout: $layout.fill,
101
112
  events: {
@@ -88,6 +88,14 @@ const sections: PreferenceSection[] = [
88
88
  title: "link",
89
89
  value: "https://apple.com",
90
90
  },
91
+ {
92
+ type: "symbol-action",
93
+ title: "种类1",
94
+ symbol: "checkmark",
95
+ tintColor: $color("systemLink"),
96
+ titleColor: $color("systemLink"),
97
+ value: () => console.info(0),
98
+ },
91
99
  {
92
100
  type: "action",
93
101
  title: "action",
package/utils/colors.ts CHANGED
@@ -10,3 +10,8 @@ export const sectionHeaderColor = $color({
10
10
  dark: "#acacac",
11
11
  black: "#ababab",
12
12
  });
13
+ export const sliderMaxColor = $color({
14
+ light: "#E4E4E6",
15
+ dark: "#38373B",
16
+ black: "#2B2A2E",
17
+ });