jsbox-cview 1.2.1 → 1.2.3

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.
@@ -52,7 +52,7 @@
52
52
  */
53
53
 
54
54
  import { Base } from "./base";
55
- import { ContentView, Label, Button } from "./single-views";
55
+ import { ContentView, Label, Button, Blur } from "./single-views";
56
56
  import { SymbolButton } from "./symbol-button";
57
57
  import { getTextWidth } from "../utils/uitools";
58
58
 
@@ -122,6 +122,8 @@ interface NavigationBarCViews {
122
122
  titleViewWrapper?: ContentView | Label;
123
123
  contentView?: ContentView;
124
124
  toolViewWrapper?: ContentView;
125
+ bgview?: ContentView | Blur;
126
+ separator?: ContentView;
125
127
  }
126
128
 
127
129
  export class CustomNavigationBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTypes.BlurOptions> {
@@ -318,19 +320,41 @@ export class CustomNavigationBar extends Base<UIView | UIBlurView, UiTypes.ViewO
318
320
  },
319
321
  views: this._props.toolView && [this._props.toolView.definition]
320
322
  });
321
-
323
+ if (this._props.bgcolor) {
324
+ this.cviews.bgview = new ContentView({
325
+ props: {
326
+ bgcolor: this._props.bgcolor
327
+ },
328
+ layout: $layout.fill
329
+ });
330
+ } else {
331
+ this.cviews.bgview = new Blur({
332
+ props: {
333
+ style: 10
334
+ },
335
+ layout: $layout.fill
336
+ });
337
+ }
338
+ this.cviews.separator = new ContentView({
339
+ props: {
340
+ bgcolor: $color("separatorColor")
341
+ },
342
+ layout: (make, view) => {
343
+ make.bottom.left.right.inset(0);
344
+ make.height.equalTo(0.5);
345
+ }
346
+ });
322
347
  return {
323
- type: this._props.bgcolor ? "view" : "blur",
348
+ type: "view",
324
349
  props: {
325
350
  id: this.id,
326
- style: this._props.bgcolor ? undefined : 10,
327
- bgcolor: this._props.bgcolor
328
351
  },
329
352
  layout: navBarLayouts[this._props.style],
330
353
  events: {
331
354
  ready: () => (this.style = this.style)
332
355
  },
333
356
  views: [
357
+ this.cviews.bgview.definition,
334
358
  {
335
359
  type: "view",
336
360
  props: {},
@@ -340,16 +364,7 @@ export class CustomNavigationBar extends Base<UIView | UIBlurView, UiTypes.ViewO
340
364
  this.cviews.toolViewWrapper.definition
341
365
  ]
342
366
  },
343
- {
344
- type: "view",
345
- props: {
346
- bgcolor: $color("separatorColor")
347
- },
348
- layout: (make, view) => {
349
- make.bottom.left.right.inset(0);
350
- make.height.equalTo(0.5);
351
- }
352
- }
367
+ this.cviews.separator.definition
353
368
  ]
354
369
  };
355
370
  }
@@ -329,6 +329,7 @@ export class DynamicPreferenceListView extends Base<UIListView, UiTypes.ListOpti
329
329
  switch (row.type) {
330
330
  case "string": {
331
331
  $input.text({
332
+ text: row.value,
332
333
  type: $kbType.default,
333
334
  placeholder: row.placeholder,
334
335
  handler: text => {
@@ -341,6 +342,7 @@ export class DynamicPreferenceListView extends Base<UIListView, UiTypes.ListOpti
341
342
  }
342
343
  case "number": {
343
344
  $input.text({
345
+ text: row.value?.toString(),
344
346
  type: $kbType.decimal,
345
347
  placeholder: row.placeholder,
346
348
  handler: text => {
@@ -357,6 +359,7 @@ export class DynamicPreferenceListView extends Base<UIListView, UiTypes.ListOpti
357
359
  }
358
360
  case "integer": {
359
361
  $input.text({
362
+ text: row.value?.toString(),
360
363
  type: $kbType.number,
361
364
  placeholder: row.placeholder,
362
365
  handler: text => {
@@ -942,6 +942,7 @@ export class PreferenceListView extends Base<UIListView, UiTypes.ListOptions> {
942
942
  switch (cell._type) {
943
943
  case "string": {
944
944
  $input.text({
945
+ text: cell.value,
945
946
  type: $kbType.default,
946
947
  placeholder: cell._placeholder,
947
948
  handler: text => {
@@ -953,6 +954,7 @@ export class PreferenceListView extends Base<UIListView, UiTypes.ListOptions> {
953
954
  }
954
955
  case "number": {
955
956
  $input.text({
957
+ text: cell.value,
956
958
  type: $kbType.decimal,
957
959
  placeholder: cell._placeholder,
958
960
  handler: text => {
@@ -964,6 +966,7 @@ export class PreferenceListView extends Base<UIListView, UiTypes.ListOptions> {
964
966
  }
965
967
  case "integer": {
966
968
  $input.text({
969
+ text: cell.value,
967
970
  type: $kbType.number,
968
971
  placeholder: cell._placeholder,
969
972
  handler: text => {
@@ -256,18 +256,42 @@ class CustomNavigationBar extends base_1.Base {
256
256
  },
257
257
  views: this._props.toolView && [this._props.toolView.definition]
258
258
  });
259
+ if (this._props.bgcolor) {
260
+ this.cviews.bgview = new single_views_1.ContentView({
261
+ props: {
262
+ bgcolor: this._props.bgcolor
263
+ },
264
+ layout: $layout.fill
265
+ });
266
+ }
267
+ else {
268
+ this.cviews.bgview = new single_views_1.Blur({
269
+ props: {
270
+ style: 10
271
+ },
272
+ layout: $layout.fill
273
+ });
274
+ }
275
+ this.cviews.separator = new single_views_1.ContentView({
276
+ props: {
277
+ bgcolor: $color("separatorColor")
278
+ },
279
+ layout: (make, view) => {
280
+ make.bottom.left.right.inset(0);
281
+ make.height.equalTo(0.5);
282
+ }
283
+ });
259
284
  return {
260
- type: this._props.bgcolor ? "view" : "blur",
285
+ type: "view",
261
286
  props: {
262
287
  id: this.id,
263
- style: this._props.bgcolor ? undefined : 10,
264
- bgcolor: this._props.bgcolor
265
288
  },
266
289
  layout: navBarLayouts[this._props.style],
267
290
  events: {
268
291
  ready: () => (this.style = this.style)
269
292
  },
270
293
  views: [
294
+ this.cviews.bgview.definition,
271
295
  {
272
296
  type: "view",
273
297
  props: {},
@@ -277,16 +301,7 @@ class CustomNavigationBar extends base_1.Base {
277
301
  this.cviews.toolViewWrapper.definition
278
302
  ]
279
303
  },
280
- {
281
- type: "view",
282
- props: {
283
- bgcolor: $color("separatorColor")
284
- },
285
- layout: (make, view) => {
286
- make.bottom.left.right.inset(0);
287
- make.height.equalTo(0.5);
288
- }
289
- }
304
+ this.cviews.separator.definition
290
305
  ]
291
306
  };
292
307
  };
@@ -257,12 +257,14 @@ class DynamicPreferenceListView extends base_1.Base {
257
257
  layout: this._layout,
258
258
  events: {
259
259
  didSelect: (sender, indexPath, data) => {
260
+ var _a, _b;
260
261
  const row = this._sections[indexPath.section].rows[indexPath.row];
261
262
  if (!static_preference_listview_1.selectableTypes.includes(row.type))
262
263
  return;
263
264
  switch (row.type) {
264
265
  case "string": {
265
266
  $input.text({
267
+ text: row.value,
266
268
  type: $kbType.default,
267
269
  placeholder: row.placeholder,
268
270
  handler: text => {
@@ -276,6 +278,7 @@ class DynamicPreferenceListView extends base_1.Base {
276
278
  }
277
279
  case "number": {
278
280
  $input.text({
281
+ text: (_a = row.value) === null || _a === void 0 ? void 0 : _a.toString(),
279
282
  type: $kbType.decimal,
280
283
  placeholder: row.placeholder,
281
284
  handler: text => {
@@ -296,6 +299,7 @@ class DynamicPreferenceListView extends base_1.Base {
296
299
  }
297
300
  case "integer": {
298
301
  $input.text({
302
+ text: (_b = row.value) === null || _b === void 0 ? void 0 : _b.toString(),
299
303
  type: $kbType.number,
300
304
  placeholder: row.placeholder,
301
305
  handler: text => {
@@ -734,6 +734,7 @@ class PreferenceListView extends base_1.Base {
734
734
  switch (cell._type) {
735
735
  case "string": {
736
736
  $input.text({
737
+ text: cell.value,
737
738
  type: $kbType.default,
738
739
  placeholder: cell._placeholder,
739
740
  handler: text => {
@@ -746,6 +747,7 @@ class PreferenceListView extends base_1.Base {
746
747
  }
747
748
  case "number": {
748
749
  $input.text({
750
+ text: cell.value,
749
751
  type: $kbType.decimal,
750
752
  placeholder: cell._placeholder,
751
753
  handler: text => {
@@ -758,6 +760,7 @@ class PreferenceListView extends base_1.Base {
758
760
  }
759
761
  case "integer": {
760
762
  $input.text({
763
+ text: cell.value,
761
764
  type: $kbType.number,
762
765
  placeholder: cell._placeholder,
763
766
  handler: text => {
@@ -6,6 +6,11 @@ const navbar = new custom_navigation_bar_1.CustomNavigationBar({
6
6
  title: "Custom Navigation Bar",
7
7
  popButtonEnabled: true,
8
8
  popButtonTitle: "Back",
9
+ rightBarButtonItems: [
10
+ {
11
+ symbol: "gear",
12
+ }
13
+ ]
9
14
  }
10
15
  });
11
16
  $ui.render({
@@ -18,6 +23,14 @@ $ui.render({
18
23
  $ui.push({
19
24
  views: [navbar.definition]
20
25
  });
26
+ $delay(1, () => {
27
+ navbar.cviews.bgview.view.alpha = 0.5;
28
+ navbar.cviews.separator.view.alpha = 0.5;
29
+ });
30
+ $delay(2, () => {
31
+ navbar.cviews.bgview.view.alpha = 0;
32
+ navbar.cviews.separator.view.alpha = 0;
33
+ });
21
34
  }
22
35
  }
23
36
  }]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsbox-cview",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "为 JSBox 设计的微型框架",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,6 +19,6 @@
19
19
  "devDependencies": {
20
20
  "@types/node": "^20.11.17",
21
21
  "browserify": "^17.0.0",
22
- "jsbox-types": "^1.0.19"
22
+ "jsbox-types": "^1.0.23"
23
23
  }
24
24
  }
@@ -5,6 +5,11 @@ const navbar = new CustomNavigationBar({
5
5
  title: "Custom Navigation Bar",
6
6
  popButtonEnabled: true,
7
7
  popButtonTitle: "Back",
8
+ rightBarButtonItems: [
9
+ {
10
+ symbol: "gear",
11
+ }
12
+ ]
8
13
  }
9
14
  })
10
15
 
@@ -20,6 +25,14 @@ $ui.render({
20
25
  $ui.push({
21
26
  views: [navbar.definition]
22
27
  })
28
+ $delay(1, () => {
29
+ navbar.cviews.bgview.view.alpha = 0.5
30
+ navbar.cviews.separator.view.alpha = 0.5
31
+ })
32
+ $delay(2, () => {
33
+ navbar.cviews.bgview.view.alpha = 0
34
+ navbar.cviews.separator.view.alpha = 0
35
+ })
23
36
  }
24
37
  }
25
38
  }]