jsbox-cview 1.6.6 → 1.6.7

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.
Files changed (136) hide show
  1. package/README.md +4 -0
  2. package/dist/components/alert/input-alert.d.ts +22 -0
  3. package/dist/components/alert/login-alert.d.ts +21 -0
  4. package/dist/components/alert/plain-alert.d.ts +15 -0
  5. package/dist/components/alert/uialert.d.ts +29 -0
  6. package/{components/base.ts → dist/components/base.d.ts} +9 -28
  7. package/dist/components/custom-navigation-bar.d.ts +117 -0
  8. package/dist/components/dialogs/dialog-sheet.d.ts +46 -0
  9. package/dist/components/dialogs/dialog-sheet.js +3 -1
  10. package/dist/components/dialogs/form-dialog.d.ts +15 -0
  11. package/dist/components/dialogs/list-dialog.d.ts +23 -0
  12. package/dist/components/dialogs/list-dialog.js +1 -1
  13. package/dist/components/dialogs/text-dialog.d.ts +13 -0
  14. package/dist/components/dynamic-contextmenu-view.d.ts +40 -0
  15. package/dist/components/dynamic-itemsize-matrix.d.ts +79 -0
  16. package/dist/components/dynamic-itemsize-matrix.js +1 -0
  17. package/dist/components/dynamic-itemsize-section-matrix.d.ts +115 -0
  18. package/dist/components/dynamic-preference-listview.d.ts +63 -0
  19. package/dist/components/dynamic-rowheight-list.d.ts +38 -0
  20. package/dist/components/enhanced-imageview.d.ts +41 -0
  21. package/dist/components/flowlayout.d.ts +63 -0
  22. package/dist/components/image-pager.d.ts +49 -0
  23. package/dist/components/oc-webview.d.ts +64 -0
  24. package/dist/components/page-control.d.ts +45 -0
  25. package/dist/components/pageviewer-titlebar.d.ts +48 -0
  26. package/dist/components/pageviewer.d.ts +41 -0
  27. package/dist/components/refresh-button.d.ts +25 -0
  28. package/dist/components/rotating-view.d.ts +45 -0
  29. package/dist/components/searchbar.d.ts +118 -0
  30. package/dist/components/sheet.d.ts +42 -0
  31. package/dist/components/single-views.d.ts +289 -0
  32. package/dist/components/spinners/loading-dual-ring.d.ts +18 -0
  33. package/dist/components/spinners/loading-wedges.d.ts +15 -0
  34. package/dist/components/spinners/spinner-androidstyle.d.ts +30 -0
  35. package/dist/components/static-preference-listview.d.ts +389 -0
  36. package/dist/components/symbol-button.d.ts +39 -0
  37. package/dist/components/tabbar.d.ts +140 -0
  38. package/dist/controller/base-controller.d.ts +125 -0
  39. package/dist/controller/base-controller.js +11 -11
  40. package/dist/controller/controller-router.d.ts +48 -0
  41. package/dist/controller/pageviewer-controller.d.ts +38 -0
  42. package/dist/controller/presented-page-controller.d.ts +41 -0
  43. package/dist/controller/splitview-controller.d.ts +90 -0
  44. package/dist/controller/splitview-controller.js +4 -0
  45. package/dist/controller/tabbar-controller.d.ts +49 -0
  46. package/dist/controller/tabbar-controller.js +0 -2
  47. package/{index.ts → dist/index.d.ts} +1 -0
  48. package/dist/index.js +1 -0
  49. package/dist/utils/colors.d.ts +7 -0
  50. package/dist/utils/cvid.d.ts +11 -0
  51. package/dist/utils/l10n.d.ts +1 -0
  52. package/dist/utils/path.d.ts +8 -0
  53. package/dist/utils/rect.d.ts +38 -0
  54. package/dist/utils/uitools.d.ts +75 -0
  55. package/package.json +20 -6
  56. package/.prettierignore +0 -6
  57. package/.prettierrc +0 -3
  58. package/components/alert/input-alert.ts +0 -64
  59. package/components/alert/login-alert.ts +0 -66
  60. package/components/alert/plain-alert.ts +0 -39
  61. package/components/alert/uialert.ts +0 -107
  62. package/components/custom-navigation-bar.ts +0 -579
  63. package/components/dialogs/dialog-sheet.ts +0 -111
  64. package/components/dialogs/form-dialog.ts +0 -63
  65. package/components/dialogs/list-dialog.ts +0 -119
  66. package/components/dialogs/text-dialog.ts +0 -44
  67. package/components/dynamic-contextmenu-view.ts +0 -115
  68. package/components/dynamic-itemsize-matrix.ts +0 -206
  69. package/components/dynamic-itemsize-section-matrix.ts +0 -363
  70. package/components/dynamic-preference-listview.ts +0 -684
  71. package/components/dynamic-rowheight-list.ts +0 -77
  72. package/components/enhanced-imageview.ts +0 -132
  73. package/components/flowlayout.ts +0 -248
  74. package/components/image-pager.ts +0 -180
  75. package/components/oc-webview.ts +0 -177
  76. package/components/page-control.ts +0 -93
  77. package/components/pageviewer-titlebar.ts +0 -166
  78. package/components/pageviewer.ts +0 -125
  79. package/components/refresh-button.ts +0 -83
  80. package/components/rotating-view.ts +0 -133
  81. package/components/searchbar.ts +0 -398
  82. package/components/sheet.ts +0 -104
  83. package/components/single-views.ts +0 -956
  84. package/components/spinners/loading-dual-ring.ts +0 -97
  85. package/components/spinners/loading-wedges.ts +0 -106
  86. package/components/spinners/spinner-androidstyle.ts +0 -269
  87. package/components/static-preference-listview.ts +0 -1282
  88. package/components/symbol-button.ts +0 -108
  89. package/components/tabbar.ts +0 -453
  90. package/controller/base-controller.ts +0 -214
  91. package/controller/controller-router.ts +0 -73
  92. package/controller/pageviewer-controller.ts +0 -93
  93. package/controller/presented-page-controller.ts +0 -76
  94. package/controller/splitview-controller.ts +0 -359
  95. package/controller/tabbar-controller.ts +0 -131
  96. package/dist/test/custom-navigation-bar.js +0 -40
  97. package/dist/test/dialog-sheet.js +0 -40
  98. package/dist/test/dynamic-contextmenu-view.js +0 -66
  99. package/dist/test/dynamic-itemsize-matrix.js +0 -74
  100. package/dist/test/dynamic-itemsize-section-matrix.js +0 -138
  101. package/dist/test/dynamic-preference-listview.js +0 -150
  102. package/dist/test/flowlayout.js +0 -76
  103. package/dist/test/form-dialog.js +0 -51
  104. package/dist/test/oc-webview.js +0 -195
  105. package/dist/test/pageviewer-controller.js +0 -20
  106. package/dist/test/pageviewer-titlebar.js +0 -18
  107. package/dist/test/pageviewer.js +0 -32
  108. package/dist/test/refresh-button.js +0 -26
  109. package/dist/test/searchbar.js +0 -36
  110. package/dist/test/splitview-controller.js +0 -41
  111. package/dist/test/static-preference-listview.js +0 -143
  112. package/dist/test/tabbar-controller.js +0 -48
  113. package/test/custom-navigation-bar.ts +0 -40
  114. package/test/dialog-sheet.ts +0 -40
  115. package/test/dynamic-contextmenu-view.ts +0 -67
  116. package/test/dynamic-itemsize-matrix.ts +0 -74
  117. package/test/dynamic-itemsize-section-matrix.ts +0 -142
  118. package/test/dynamic-preference-listview.ts +0 -151
  119. package/test/flowlayout.ts +0 -79
  120. package/test/form-dialog.ts +0 -48
  121. package/test/oc-webview.ts +0 -197
  122. package/test/pageviewer-controller.ts +0 -21
  123. package/test/pageviewer-titlebar.ts +0 -18
  124. package/test/pageviewer.ts +0 -31
  125. package/test/refresh-button.ts +0 -26
  126. package/test/searchbar.ts +0 -38
  127. package/test/splitview-controller.ts +0 -42
  128. package/test/static-preference-listview.ts +0 -142
  129. package/test/tabbar-controller.ts +0 -49
  130. package/tsconfig.json +0 -122
  131. package/utils/colors.ts +0 -17
  132. package/utils/cvid.ts +0 -32
  133. package/utils/l10n.ts +0 -42
  134. package/utils/path.ts +0 -97
  135. package/utils/rect.ts +0 -90
  136. package/utils/uitools.ts +0 -122
@@ -1,133 +0,0 @@
1
- import { Base } from "./base";
2
- import { Image } from "./single-views";
3
-
4
- interface RotatingViewProps {
5
- image?: UIImage;
6
- tintColor?: UIColor;
7
- contentMode?: number;
8
- cview?: Base<any, any>;
9
- rps?: number;
10
- clockwise?: boolean;
11
- }
12
-
13
- /**
14
- * 创建一个可以旋转的视图。理论上来说,这个视图的布局必须是方形的。
15
- *
16
- * @method startRotating() 开始旋转
17
- * @method stopRotating() 结束旋转,请注意旋转是不能立即结束的,必须等到动画归位
18
- */
19
- export class RotatingView extends Base<UIView, UiTypes.ViewOptions> {
20
- private _props: RotatingViewProps;
21
- private _rotatingFlag: boolean;
22
- private _innerView: Base<any, any>;
23
- _defineView: () => UiTypes.ViewOptions;
24
-
25
- /**
26
- *
27
- * @param props 属性
28
- * - image: UIImage
29
- * - tintColor: UIColor
30
- * - contentMode = 1
31
- * - cview 使用自定义的cview,如果设置上面三项将失效
32
- * - rps = 0.5 每秒转多少圈
33
- * - clockwise = true 是否顺时针旋转
34
- * @param layout 布局
35
- * @param events 事件
36
- * - ready?: (cview: RotatingView) => void 默认的ready事件是自动开始旋转;也可以手动指定其他效果
37
- */
38
- constructor({
39
- props,
40
- layout,
41
- events = {},
42
- }: {
43
- props: RotatingViewProps;
44
- layout: (make: MASConstraintMaker, view: UIView) => void;
45
- events: {
46
- ready?: (cview: RotatingView) => void;
47
- };
48
- }) {
49
- super();
50
- this._props = {
51
- contentMode: 1,
52
- rps: 0.5,
53
- clockwise: true,
54
- ...props,
55
- };
56
- this._rotatingFlag = false;
57
- if (this._props.cview) {
58
- this._innerView = this._props.cview;
59
- } else {
60
- if (!this._props.image) throw new Error("image is required");
61
- this._innerView = new Image({
62
- props: {
63
- image: this._props.tintColor ? this._props.image.alwaysTemplate : this._props.image,
64
- tintColor: this._props.tintColor,
65
- contentMode: this._props.contentMode,
66
- },
67
- layout: $layout.fill,
68
- });
69
- }
70
- this._defineView = () => {
71
- return {
72
- type: "view",
73
- props: {
74
- ...this._props,
75
- id: this.id,
76
- },
77
- layout,
78
- events: {
79
- ready: (sender) => {
80
- if (events.ready) {
81
- events.ready(this);
82
- } else {
83
- this.startRotating();
84
- }
85
- },
86
- },
87
- views: [this._innerView.definition],
88
- };
89
- };
90
- }
91
-
92
- startRotating() {
93
- this._rotatingFlag = true;
94
- this._rotateView(this._innerView.view);
95
- }
96
-
97
- stopRotating() {
98
- this._rotatingFlag = false;
99
- }
100
-
101
- _rotateView(view: AllUIView) {
102
- const clockwiseMultiplier = this._props.clockwise ? 1 : -1;
103
- const duration = 1 / 3 / (this._props.rps || 0.5);
104
- $ui.animate({
105
- duration,
106
- options: 3 << 16,
107
- animation: () => {
108
- view.rotate(((Math.PI * 2) / 3) * clockwiseMultiplier);
109
- },
110
- completion: () => {
111
- $ui.animate({
112
- duration,
113
- options: 3 << 16,
114
- animation: () => {
115
- view.rotate(((Math.PI * 4) / 3) * clockwiseMultiplier);
116
- },
117
- completion: () => {
118
- $ui.animate({
119
- duration,
120
- options: 3 << 16,
121
- animation: () => {
122
- view.rotate(Math.PI * 2 * clockwiseMultiplier);
123
- },
124
- completion: () => {
125
- if (this._rotatingFlag) this._rotateView(view);
126
- },
127
- });
128
- },
129
- });
130
- },
131
- });
132
- }
133
- }
@@ -1,398 +0,0 @@
1
- import { Base } from "./base";
2
- import { Input, Label, ContentView } from "./single-views";
3
- import { searchBarBgcolor } from "../utils/colors";
4
- import { l10n } from "../utils/l10n";
5
- import { getTextWidth } from "../utils/uitools";
6
-
7
- interface SearchBarProps {
8
- placeholder: string;
9
- cancelText: string;
10
- tintColor: UIColor;
11
- bgcolor: UIColor;
12
- style: 0 | 1 | 2;
13
- accessoryCview?: Base<any, any>;
14
- }
15
-
16
- /**
17
- * 搜索框
18
- *
19
- * 有三种样式可供选择,通过 style 属性设置
20
- *
21
- * @method focus() 聚焦
22
- * @method blur() 失焦
23
- * @property text: string 文本
24
- */
25
- export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
26
- _props: SearchBarProps;
27
- _defineView: () => UiTypes.ViewOptions;
28
- cviews: {
29
- input: Input;
30
- iconInput: ContentView;
31
- cancelButton: Label;
32
- bgview: ContentView;
33
- };
34
- _layouts: {
35
- iconInput: {
36
- normal: (make: MASConstraintMaker, view: AllUIView) => void;
37
- focused?: (make: MASConstraintMaker, view: AllUIView) => void;
38
- };
39
- cancelButton: {
40
- normal: (make: MASConstraintMaker, view: AllUIView) => void;
41
- };
42
- bgview: {
43
- normal: (make: MASConstraintMaker, view: AllUIView) => void;
44
- focused?: (make: MASConstraintMaker, view: AllUIView) => void;
45
- };
46
- };
47
- _focused: boolean;
48
-
49
- /**
50
- *
51
- * @param props 属性
52
- * - text: string
53
- * - style: number 搜索框的样式
54
- * - 0: 取消按钮在输入框内,聚焦时显示取消按钮
55
- * - 1: 取消按钮在输入框右侧,聚焦时会有左右移动的动画
56
- * - 2: 取消按钮布局同 1,但是 placeholder 平时显示在中间,聚焦时才会移动到左边。
57
- * 如果使用此样式,建议每次 blur 的时候都清除 text。
58
- * - accessoryCview: cview 请通过下面的事件来和 SearchBar 互相操作
59
- * - placeholder: string
60
- * - cancelText: string
61
- * - tintColor: \$color("systemLink")
62
- * - bgcolor: colors.searchBarBgcolor
63
- * @param layout 布局
64
- * @param events 事件
65
- * - didBeginEditing: cview => void
66
- * - didEndEditing: cview => void
67
- * - changed: cview => void
68
- * - returned: cview => void
69
- */
70
- constructor({
71
- props,
72
- layout,
73
- events = {},
74
- }: {
75
- props: Partial<SearchBarProps>;
76
- layout: (make: MASConstraintMaker, view: UIView) => void;
77
- events?: {
78
- didBeginEditing?: (cview: SearchBar) => void;
79
- didEndEditing?: (cview: SearchBar) => void;
80
- changed?: (cview: SearchBar) => void;
81
- returned?: (cview: SearchBar) => void;
82
- };
83
- }) {
84
- super();
85
- this._props = {
86
- placeholder: l10n("SEARCH"),
87
- cancelText: l10n("CANCEL"),
88
- tintColor: $color("systemLink"),
89
- bgcolor: searchBarBgcolor,
90
- style: 0,
91
- ...props,
92
- };
93
- const cancelButtonWidth = getTextWidth(this._props.cancelText, {
94
- inset: 20,
95
- });
96
- const placeholderWidth = getTextWidth(this._props.placeholder, {
97
- inset: 20,
98
- });
99
- this._focused = false;
100
- this._layouts = this._defineLayouts(cancelButtonWidth, placeholderWidth);
101
- this.cviews = {} as {
102
- input: Input;
103
- iconInput: ContentView;
104
- cancelButton: Label;
105
- bgview: ContentView;
106
- };
107
- this.cviews.input = new Input({
108
- props: {
109
- type: $kbType.search,
110
- placeholder: this._props.placeholder,
111
- bgcolor: $color("clear"),
112
- radius: 0,
113
- accessoryView: this._props.accessoryCview && this._props.accessoryCview.definition,
114
- },
115
- layout: (make, view) => {
116
- make.left.equalTo(view.prev.right);
117
- make.top.bottom.right.inset(0);
118
- },
119
- events: {
120
- changed: (sender) => {
121
- if (events.changed) events.changed(this);
122
- },
123
- didBeginEditing: (sender) => {
124
- this._onFocused();
125
- if (events.didBeginEditing) events.didBeginEditing(this);
126
- },
127
- didEndEditing: (sender) => {
128
- if (events.didEndEditing) events.didEndEditing(this);
129
- },
130
- returned: (sender) => {
131
- this.blur();
132
- if (events.returned) events.returned(this);
133
- },
134
- },
135
- });
136
- this.cviews.iconInput = new ContentView({
137
- props: {
138
- bgcolor: undefined,
139
- },
140
- layout: this._layouts.iconInput.normal,
141
- views: [
142
- {
143
- type: "view",
144
- props: {},
145
- views: [
146
- {
147
- type: "image",
148
- props: {
149
- //tintColor: searchBarSymbolColor,
150
- tintColor: $color("systemPlaceholderText"),
151
- symbol: "magnifyingglass",
152
- },
153
- layout: (make, view) => {
154
- make.size.equalTo($size(20, 20));
155
- make.center.equalTo(view.super);
156
- },
157
- },
158
- ],
159
- layout: (make, view) => {
160
- make.top.bottom.inset(0);
161
- make.width.equalTo(20);
162
- make.left.inset(6);
163
- },
164
- },
165
- this.cviews.input.definition,
166
- ],
167
- });
168
- this.cviews.cancelButton = new Label({
169
- props: {
170
- text: this._props.cancelText,
171
- textColor: this._props.tintColor,
172
- font: $font(17),
173
- align: $align.center,
174
- userInteractionEnabled: true,
175
- alpha: 0,
176
- },
177
- layout: this._layouts.cancelButton.normal,
178
- events: {
179
- tapped: (sender) => this.blur(),
180
- },
181
- });
182
- this.cviews.bgview = new ContentView({
183
- props: {
184
- bgcolor: this._props.bgcolor,
185
- radius: 8,
186
- userInteractionEnabled: true,
187
- },
188
- layout: this._layouts.bgview.normal,
189
- events: {
190
- tapped: (sender) => {
191
- if (!this._focused) this.focus();
192
- },
193
- },
194
- });
195
- this._defineView = () => {
196
- return {
197
- type: "view",
198
- props: {
199
- id: this.id,
200
- clipsToBounds: true,
201
- },
202
- layout,
203
- views: [this.cviews.bgview.definition, this.cviews.iconInput.definition, this.cviews.cancelButton.definition],
204
- };
205
- };
206
- }
207
-
208
- _defineLayouts(cancelButtonWidth: number, placeholderWidth: number) {
209
- switch (this._props.style) {
210
- case 0: {
211
- const IconInputLayout = $layout.fill;
212
- const IconInputLayoutFocused = (make: MASConstraintMaker, view: AllUIView) => {
213
- make.left.top.bottom.inset(0);
214
- make.right.inset(cancelButtonWidth);
215
- };
216
- const cancelButtonLayout = (make: MASConstraintMaker, view: AllUIView) => {
217
- make.right.top.bottom.inset(0);
218
- make.width.equalTo(cancelButtonWidth);
219
- };
220
- const bgviewLayout = $layout.fill;
221
- return {
222
- iconInput: {
223
- normal: IconInputLayout,
224
- focused: IconInputLayoutFocused,
225
- },
226
- cancelButton: { normal: cancelButtonLayout },
227
- bgview: { normal: bgviewLayout },
228
- };
229
- }
230
- case 1: {
231
- const IconInputLayout = (make: MASConstraintMaker, view: AllUIView) => {
232
- make.left.top.bottom.inset(0);
233
- make.right.equalTo(view.prev);
234
- };
235
- const cancelButtonLayout = (make: MASConstraintMaker, view: AllUIView) => {
236
- make.top.bottom.inset(0);
237
- make.left.equalTo(view.prev.prev.right);
238
- make.width.equalTo(cancelButtonWidth);
239
- };
240
- const bgviewLayoutNormal = $layout.fill;
241
- const bgviewLayoutFocused = (make: MASConstraintMaker, view: AllUIView) => {
242
- make.left.top.bottom.inset(0);
243
- make.right.inset(cancelButtonWidth);
244
- };
245
- return {
246
- iconInput: { normal: IconInputLayout },
247
- cancelButton: { normal: cancelButtonLayout },
248
- bgview: { normal: bgviewLayoutNormal, focused: bgviewLayoutFocused },
249
- };
250
- }
251
- case 2: {
252
- const IconInputLayoutNormal = (make: MASConstraintMaker, view: AllUIView) => {
253
- make.center.equalTo(view.super);
254
- make.top.bottom.inset(0);
255
- make.width.equalTo(placeholderWidth + 50);
256
- };
257
- const IconInputLayoutFocused = (make: MASConstraintMaker, view: AllUIView) => {
258
- make.left.top.bottom.inset(0);
259
- make.right.inset(cancelButtonWidth);
260
- };
261
- const cancelButtonLayout = (make: MASConstraintMaker, view: AllUIView) => {
262
- make.right.top.bottom.inset(0);
263
- make.left.equalTo(view.prev.prev.right);
264
- make.width.equalTo(cancelButtonWidth);
265
- };
266
- const bgviewLayoutNormal = $layout.fill;
267
- const bgviewLayoutFocused = (make: MASConstraintMaker, view: AllUIView) => {
268
- make.left.top.bottom.inset(0);
269
- make.right.inset(cancelButtonWidth);
270
- };
271
- return {
272
- iconInput: {
273
- normal: IconInputLayoutNormal,
274
- focused: IconInputLayoutFocused,
275
- },
276
- cancelButton: { normal: cancelButtonLayout },
277
- bgview: { normal: bgviewLayoutNormal, focused: bgviewLayoutFocused },
278
- };
279
- }
280
- default:
281
- throw new Error("style not supported");
282
- }
283
- }
284
-
285
- _onFocused() {
286
- this._focused = true;
287
- if (this._layouts.iconInput.focused) this.cviews.iconInput.view.remakeLayout(this._layouts.iconInput.focused);
288
- switch (this._props.style) {
289
- case 0: {
290
- $ui.animate({
291
- duration: 0.2,
292
- animation: () => {
293
- this.cviews.iconInput.view.relayout();
294
- this.cviews.cancelButton.view.alpha = 1;
295
- },
296
- });
297
- break;
298
- }
299
- case 1: {
300
- if (this._layouts.bgview.focused) this.cviews.bgview.view.remakeLayout(this._layouts.bgview.focused);
301
- $ui.animate({
302
- duration: 0.2,
303
- animation: () => {
304
- this.cviews.bgview.view.relayout();
305
- this.cviews.cancelButton.view.alpha = 1;
306
- },
307
- });
308
- break;
309
- }
310
- case 2: {
311
- if (this._layouts.iconInput.focused) this.cviews.iconInput.view.remakeLayout(this._layouts.iconInput.focused);
312
- if (this._layouts.bgview.focused) this.cviews.bgview.view.remakeLayout(this._layouts.bgview.focused);
313
- $ui.animate({
314
- duration: 0.2,
315
- animation: () => {
316
- this.cviews.iconInput.view.relayout();
317
- this.cviews.bgview.view.relayout();
318
- this.cviews.cancelButton.view.alpha = 1;
319
- },
320
- });
321
- break;
322
- }
323
- default:
324
- break;
325
- }
326
- }
327
-
328
- _onBlurred() {
329
- this._focused = false;
330
- this.cviews.iconInput.view.remakeLayout(this._layouts.iconInput.normal);
331
- switch (this._props.style) {
332
- case 0: {
333
- $ui.animate({
334
- duration: 0.2,
335
- animation: () => {
336
- this.cviews.iconInput.view.relayout();
337
- this.cviews.cancelButton.view.alpha = 0;
338
- },
339
- });
340
- break;
341
- }
342
- case 1: {
343
- this.cviews.bgview.view.remakeLayout(this._layouts.bgview.normal);
344
- $ui.animate({
345
- duration: 0.2,
346
- animation: () => {
347
- this.cviews.bgview.view.relayout();
348
- this.cviews.cancelButton.view.alpha = 0;
349
- },
350
- });
351
- break;
352
- }
353
- case 2: {
354
- const placeholderWidth = getTextWidth(this._props.placeholder, {
355
- inset: 20,
356
- });
357
- const textWidth = getTextWidth(this.text, { inset: 20 });
358
- const IconInputLayoutInputing = (make: MASConstraintMaker, view: AllUIView) => {
359
- make.center.equalTo(view.super);
360
- make.top.bottom.inset(0);
361
- make.width.equalTo(Math.max(textWidth, placeholderWidth) + 50).priority(999);
362
- make.width.lessThanOrEqualTo(view.super).priority(1000);
363
- };
364
- this.cviews.iconInput.view.remakeLayout(IconInputLayoutInputing);
365
- this.cviews.bgview.view.remakeLayout(this._layouts.bgview.normal);
366
- $ui.animate({
367
- duration: 0.2,
368
- animation: () => {
369
- this.cviews.iconInput.view.relayout();
370
- this.cviews.bgview.view.relayout();
371
- this.cviews.cancelButton.view.alpha = 0;
372
- },
373
- });
374
- break;
375
- }
376
- default:
377
- break;
378
- }
379
- }
380
-
381
- focus() {
382
- this.cviews.input.view.focus();
383
- this._onFocused();
384
- }
385
-
386
- blur() {
387
- this._onBlurred();
388
- this.cviews.input.view.blur();
389
- }
390
-
391
- set text(text) {
392
- this.cviews.input.view.text = text;
393
- }
394
-
395
- get text() {
396
- return this.cviews.input.view.text;
397
- }
398
- }
@@ -1,104 +0,0 @@
1
- import { cvid } from "../utils/cvid";
2
- import { Base } from "./base";
3
-
4
- const UIModalPresentationStyle = {
5
- automatic: -2,
6
- pageSheet: 1,
7
- formSheet: 2,
8
- fullScreen: 0,
9
- currentContext: 3,
10
- custom: 4,
11
- overFullScreen: 5,
12
- overCurrentContext: 6,
13
- popover: 7,
14
- none: -1,
15
- };
16
-
17
- /**
18
- *
19
- * 创建新的 UIViewController,主要用于 formSheet 和 pageSheet
20
- *
21
- * ## 参数:
22
- * - presentMode: number, default: 1, pageSheet: 1, formSheet: 2
23
- * - animated: boolean = true 是否启用动画效果
24
- * - interactiveDismissalDisabled: boolean = false 是否禁用下拉退出
25
- * - bgcolor: $color $color("secondarySurface")
26
- * - cview: Cview
27
- * - dismissalHandler: function 退出时的回调
28
- *
29
- * ## 方法:
30
- * - present()
31
- * - dismiss()
32
- *
33
- */
34
- export class Sheet<T extends Base<U, R>, U extends AllUIView, R extends UiTypes.AllViewOptions> {
35
- id: string;
36
- _animated: boolean;
37
- _presentMode: number;
38
- _interactiveDismissalDisabled: boolean;
39
- _bgcolor: UIColor;
40
- _cview?: T;
41
- _dismissalHandler?: () => void;
42
- _PSViewController: any;
43
- _PSViewControllerView: any;
44
-
45
- constructor({
46
- presentMode = UIModalPresentationStyle.pageSheet,
47
- animated = true,
48
- interactiveDismissalDisabled = false,
49
- bgcolor = $color("secondarySurface"),
50
- cview,
51
- dismissalHandler,
52
- }: {
53
- presentMode?: number;
54
- animated?: boolean;
55
- interactiveDismissalDisabled?: boolean;
56
- bgcolor?: UIColor;
57
- cview?: T;
58
- dismissalHandler?: () => void;
59
- }) {
60
- this._animated = animated;
61
- this._presentMode = presentMode;
62
- this._interactiveDismissalDisabled = interactiveDismissalDisabled;
63
- this._bgcolor = bgcolor;
64
- this._cview = cview;
65
- this._dismissalHandler = dismissalHandler;
66
- this.id = cvid.newId;
67
- }
68
-
69
- _create() {
70
- this._define();
71
- this._PSViewController = $objc(this.id).invoke("alloc.init");
72
- this._PSViewControllerView = this._PSViewController.$view();
73
- this._PSViewControllerView.$setBackgroundColor(this._bgcolor);
74
- this._PSViewController.$setModalPresentationStyle(this._presentMode);
75
- if (this._interactiveDismissalDisabled) this._PSViewController.$setModalInPresentation(true);
76
- if (this._cview) this._add(this._cview);
77
- }
78
-
79
- _define() {
80
- $define({
81
- type: this.id + ": UIViewController",
82
- events: {
83
- "viewDidDisappear:": () => {
84
- if (this._dismissalHandler) this._dismissalHandler();
85
- },
86
- },
87
- });
88
- }
89
-
90
- _add(cview: T) {
91
- const definition = cview.definition;
92
- definition.layout = $layout.fill;
93
- this._PSViewControllerView.jsValue().add(definition);
94
- }
95
-
96
- present() {
97
- this._create();
98
- $ui.controller.ocValue().invoke("presentModalViewController:animated", this._PSViewController, this._animated);
99
- }
100
-
101
- dismiss() {
102
- this._PSViewController.invoke("dismissModalViewControllerAnimated", this._animated);
103
- }
104
- }