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
package/components/searchbar.ts
CHANGED
|
@@ -15,7 +15,7 @@ interface SearchBarProps {
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* 搜索框
|
|
18
|
-
*
|
|
18
|
+
*
|
|
19
19
|
* 有三种样式可供选择,通过 style 属性设置
|
|
20
20
|
*
|
|
21
21
|
* @method focus() 聚焦
|
|
@@ -47,13 +47,14 @@ export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
47
47
|
_focused: boolean;
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
*
|
|
51
51
|
* @param props 属性
|
|
52
52
|
* - text: string
|
|
53
53
|
* - style: number 搜索框的样式
|
|
54
54
|
* - 0: 取消按钮在输入框内,聚焦时显示取消按钮
|
|
55
55
|
* - 1: 取消按钮在输入框右侧,聚焦时会有左右移动的动画
|
|
56
|
-
* - 2: 取消按钮布局同 1,但是 placeholder
|
|
56
|
+
* - 2: 取消按钮布局同 1,但是 placeholder 平时显示在中间,聚焦时才会移动到左边。
|
|
57
|
+
* 如果使用此样式,建议每次 blur 的时候都清除 text。
|
|
57
58
|
* - accessoryCview: cview 请通过下面的事件来和 SearchBar 互相操作
|
|
58
59
|
* - placeholder: string
|
|
59
60
|
* - cancelText: string
|
|
@@ -66,7 +67,11 @@ export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
66
67
|
* - changed: cview => void
|
|
67
68
|
* - returned: cview => void
|
|
68
69
|
*/
|
|
69
|
-
constructor({
|
|
70
|
+
constructor({
|
|
71
|
+
props,
|
|
72
|
+
layout,
|
|
73
|
+
events = {},
|
|
74
|
+
}: {
|
|
70
75
|
props: Partial<SearchBarProps>;
|
|
71
76
|
layout: (make: MASConstraintMaker, view: UIView) => void;
|
|
72
77
|
events?: {
|
|
@@ -83,10 +88,14 @@ export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
83
88
|
tintColor: $color("systemLink"),
|
|
84
89
|
bgcolor: searchBarBgcolor,
|
|
85
90
|
style: 0,
|
|
86
|
-
...props
|
|
91
|
+
...props,
|
|
87
92
|
};
|
|
88
|
-
const cancelButtonWidth = getTextWidth(this._props.cancelText, {
|
|
89
|
-
|
|
93
|
+
const cancelButtonWidth = getTextWidth(this._props.cancelText, {
|
|
94
|
+
inset: 20,
|
|
95
|
+
});
|
|
96
|
+
const placeholderWidth = getTextWidth(this._props.placeholder, {
|
|
97
|
+
inset: 20,
|
|
98
|
+
});
|
|
90
99
|
this._focused = false;
|
|
91
100
|
this._layouts = this._defineLayouts(cancelButtonWidth, placeholderWidth);
|
|
92
101
|
this.cviews = {} as {
|
|
@@ -102,32 +111,32 @@ export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
102
111
|
bgcolor: $color("clear"),
|
|
103
112
|
radius: 0,
|
|
104
113
|
accessoryView:
|
|
105
|
-
this._props.accessoryCview && this._props.accessoryCview.definition
|
|
114
|
+
this._props.accessoryCview && this._props.accessoryCview.definition,
|
|
106
115
|
},
|
|
107
116
|
layout: (make, view) => {
|
|
108
117
|
make.left.equalTo(view.prev.right);
|
|
109
118
|
make.top.bottom.right.inset(0);
|
|
110
119
|
},
|
|
111
120
|
events: {
|
|
112
|
-
changed: sender => {
|
|
121
|
+
changed: (sender) => {
|
|
113
122
|
if (events.changed) events.changed(this);
|
|
114
123
|
},
|
|
115
|
-
didBeginEditing: sender => {
|
|
124
|
+
didBeginEditing: (sender) => {
|
|
116
125
|
this._onFocused();
|
|
117
126
|
if (events.didBeginEditing) events.didBeginEditing(this);
|
|
118
127
|
},
|
|
119
|
-
didEndEditing: sender => {
|
|
128
|
+
didEndEditing: (sender) => {
|
|
120
129
|
if (events.didEndEditing) events.didEndEditing(this);
|
|
121
130
|
},
|
|
122
|
-
returned: sender => {
|
|
131
|
+
returned: (sender) => {
|
|
123
132
|
this.blur();
|
|
124
133
|
if (events.returned) events.returned(this);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
})
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
});
|
|
128
137
|
this.cviews.iconInput = new ContentView({
|
|
129
138
|
props: {
|
|
130
|
-
bgcolor: undefined
|
|
139
|
+
bgcolor: undefined,
|
|
131
140
|
},
|
|
132
141
|
layout: this._layouts.iconInput.normal,
|
|
133
142
|
views: [
|
|
@@ -140,23 +149,23 @@ export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
140
149
|
props: {
|
|
141
150
|
//tintColor: searchBarSymbolColor,
|
|
142
151
|
tintColor: $color("systemPlaceholderText"),
|
|
143
|
-
symbol: "magnifyingglass"
|
|
152
|
+
symbol: "magnifyingglass",
|
|
144
153
|
},
|
|
145
154
|
layout: (make, view) => {
|
|
146
155
|
make.size.equalTo($size(20, 20));
|
|
147
156
|
make.center.equalTo(view.super);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
157
|
+
},
|
|
158
|
+
},
|
|
150
159
|
],
|
|
151
160
|
layout: (make, view) => {
|
|
152
161
|
make.top.bottom.inset(0);
|
|
153
162
|
make.width.equalTo(20);
|
|
154
163
|
make.left.inset(6);
|
|
155
|
-
}
|
|
164
|
+
},
|
|
156
165
|
},
|
|
157
|
-
this.cviews.input.definition
|
|
158
|
-
]
|
|
159
|
-
})
|
|
166
|
+
this.cviews.input.definition,
|
|
167
|
+
],
|
|
168
|
+
});
|
|
160
169
|
this.cviews.cancelButton = new Label({
|
|
161
170
|
props: {
|
|
162
171
|
text: this._props.cancelText,
|
|
@@ -164,61 +173,69 @@ export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
164
173
|
font: $font(17),
|
|
165
174
|
align: $align.center,
|
|
166
175
|
userInteractionEnabled: true,
|
|
167
|
-
alpha: 0
|
|
176
|
+
alpha: 0,
|
|
168
177
|
},
|
|
169
178
|
layout: this._layouts.cancelButton.normal,
|
|
170
179
|
events: {
|
|
171
|
-
tapped: sender => this.blur()
|
|
172
|
-
}
|
|
173
|
-
})
|
|
180
|
+
tapped: (sender) => this.blur(),
|
|
181
|
+
},
|
|
182
|
+
});
|
|
174
183
|
this.cviews.bgview = new ContentView({
|
|
175
184
|
props: {
|
|
176
185
|
bgcolor: this._props.bgcolor,
|
|
177
186
|
radius: 8,
|
|
178
|
-
userInteractionEnabled: true
|
|
187
|
+
userInteractionEnabled: true,
|
|
179
188
|
},
|
|
180
189
|
layout: this._layouts.bgview.normal,
|
|
181
190
|
events: {
|
|
182
|
-
tapped: sender => {
|
|
191
|
+
tapped: (sender) => {
|
|
183
192
|
if (!this._focused) this.focus();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
})
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
});
|
|
187
196
|
this._defineView = () => {
|
|
188
197
|
return {
|
|
189
198
|
type: "view",
|
|
190
199
|
props: {
|
|
191
200
|
id: this.id,
|
|
192
|
-
clipsToBounds: true
|
|
201
|
+
clipsToBounds: true,
|
|
193
202
|
},
|
|
194
203
|
layout,
|
|
195
204
|
views: [
|
|
196
205
|
this.cviews.bgview.definition,
|
|
197
206
|
this.cviews.iconInput.definition,
|
|
198
|
-
this.cviews.cancelButton.definition
|
|
199
|
-
]
|
|
207
|
+
this.cviews.cancelButton.definition,
|
|
208
|
+
],
|
|
200
209
|
};
|
|
201
|
-
}
|
|
210
|
+
};
|
|
202
211
|
}
|
|
203
212
|
|
|
204
|
-
|
|
205
213
|
_defineLayouts(cancelButtonWidth: number, placeholderWidth: number) {
|
|
206
214
|
switch (this._props.style) {
|
|
207
215
|
case 0: {
|
|
208
216
|
const IconInputLayout = $layout.fill;
|
|
209
|
-
const IconInputLayoutFocused = (
|
|
217
|
+
const IconInputLayoutFocused = (
|
|
218
|
+
make: MASConstraintMaker,
|
|
219
|
+
view: AllUIView
|
|
220
|
+
) => {
|
|
210
221
|
make.left.top.bottom.inset(0);
|
|
211
222
|
make.right.inset(cancelButtonWidth);
|
|
212
|
-
}
|
|
213
|
-
const cancelButtonLayout = (
|
|
223
|
+
};
|
|
224
|
+
const cancelButtonLayout = (
|
|
225
|
+
make: MASConstraintMaker,
|
|
226
|
+
view: AllUIView
|
|
227
|
+
) => {
|
|
214
228
|
make.right.top.bottom.inset(0);
|
|
215
229
|
make.width.equalTo(cancelButtonWidth);
|
|
216
230
|
};
|
|
217
231
|
const bgviewLayout = $layout.fill;
|
|
218
232
|
return {
|
|
219
|
-
iconInput: {
|
|
233
|
+
iconInput: {
|
|
234
|
+
normal: IconInputLayout,
|
|
235
|
+
focused: IconInputLayoutFocused,
|
|
236
|
+
},
|
|
220
237
|
cancelButton: { normal: cancelButtonLayout },
|
|
221
|
-
bgview: { normal: bgviewLayout }
|
|
238
|
+
bgview: { normal: bgviewLayout },
|
|
222
239
|
};
|
|
223
240
|
}
|
|
224
241
|
case 1: {
|
|
@@ -226,49 +243,67 @@ export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
226
243
|
make.left.top.bottom.inset(0);
|
|
227
244
|
make.right.equalTo(view.prev);
|
|
228
245
|
};
|
|
229
|
-
const cancelButtonLayout = (
|
|
246
|
+
const cancelButtonLayout = (
|
|
247
|
+
make: MASConstraintMaker,
|
|
248
|
+
view: AllUIView
|
|
249
|
+
) => {
|
|
230
250
|
make.top.bottom.inset(0);
|
|
231
251
|
make.left.equalTo(view.prev.prev.right);
|
|
232
252
|
make.width.equalTo(cancelButtonWidth);
|
|
233
253
|
};
|
|
234
254
|
const bgviewLayoutNormal = $layout.fill;
|
|
235
|
-
const bgviewLayoutFocused = (
|
|
255
|
+
const bgviewLayoutFocused = (
|
|
256
|
+
make: MASConstraintMaker,
|
|
257
|
+
view: AllUIView
|
|
258
|
+
) => {
|
|
236
259
|
make.left.top.bottom.inset(0);
|
|
237
260
|
make.right.inset(cancelButtonWidth);
|
|
238
261
|
};
|
|
239
262
|
return {
|
|
240
263
|
iconInput: { normal: IconInputLayout },
|
|
241
264
|
cancelButton: { normal: cancelButtonLayout },
|
|
242
|
-
bgview: { normal: bgviewLayoutNormal, focused: bgviewLayoutFocused }
|
|
265
|
+
bgview: { normal: bgviewLayoutNormal, focused: bgviewLayoutFocused },
|
|
243
266
|
};
|
|
244
267
|
}
|
|
245
268
|
case 2: {
|
|
246
|
-
const IconInputLayoutNormal = (
|
|
269
|
+
const IconInputLayoutNormal = (
|
|
270
|
+
make: MASConstraintMaker,
|
|
271
|
+
view: AllUIView
|
|
272
|
+
) => {
|
|
247
273
|
make.center.equalTo(view.super);
|
|
248
274
|
make.top.bottom.inset(0);
|
|
249
275
|
make.width.equalTo(placeholderWidth + 50);
|
|
250
276
|
};
|
|
251
|
-
const IconInputLayoutFocused = (
|
|
277
|
+
const IconInputLayoutFocused = (
|
|
278
|
+
make: MASConstraintMaker,
|
|
279
|
+
view: AllUIView
|
|
280
|
+
) => {
|
|
252
281
|
make.left.top.bottom.inset(0);
|
|
253
282
|
make.right.inset(cancelButtonWidth);
|
|
254
283
|
};
|
|
255
|
-
const cancelButtonLayout = (
|
|
284
|
+
const cancelButtonLayout = (
|
|
285
|
+
make: MASConstraintMaker,
|
|
286
|
+
view: AllUIView
|
|
287
|
+
) => {
|
|
256
288
|
make.right.top.bottom.inset(0);
|
|
257
289
|
make.left.equalTo(view.prev.prev.right);
|
|
258
290
|
make.width.equalTo(cancelButtonWidth);
|
|
259
291
|
};
|
|
260
292
|
const bgviewLayoutNormal = $layout.fill;
|
|
261
|
-
const bgviewLayoutFocused = (
|
|
293
|
+
const bgviewLayoutFocused = (
|
|
294
|
+
make: MASConstraintMaker,
|
|
295
|
+
view: AllUIView
|
|
296
|
+
) => {
|
|
262
297
|
make.left.top.bottom.inset(0);
|
|
263
298
|
make.right.inset(cancelButtonWidth);
|
|
264
299
|
};
|
|
265
300
|
return {
|
|
266
301
|
iconInput: {
|
|
267
302
|
normal: IconInputLayoutNormal,
|
|
268
|
-
focused: IconInputLayoutFocused
|
|
303
|
+
focused: IconInputLayoutFocused,
|
|
269
304
|
},
|
|
270
305
|
cancelButton: { normal: cancelButtonLayout },
|
|
271
|
-
bgview: { normal: bgviewLayoutNormal, focused: bgviewLayoutFocused }
|
|
306
|
+
bgview: { normal: bgviewLayoutNormal, focused: bgviewLayoutFocused },
|
|
272
307
|
};
|
|
273
308
|
}
|
|
274
309
|
default:
|
|
@@ -278,7 +313,8 @@ export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
278
313
|
|
|
279
314
|
_onFocused() {
|
|
280
315
|
this._focused = true;
|
|
281
|
-
if (this._layouts.iconInput.focused)
|
|
316
|
+
if (this._layouts.iconInput.focused)
|
|
317
|
+
this.cviews.iconInput.view.remakeLayout(this._layouts.iconInput.focused);
|
|
282
318
|
switch (this._props.style) {
|
|
283
319
|
case 0: {
|
|
284
320
|
$ui.animate({
|
|
@@ -286,31 +322,36 @@ export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
286
322
|
animation: () => {
|
|
287
323
|
this.cviews.iconInput.view.relayout();
|
|
288
324
|
this.cviews.cancelButton.view.alpha = 1;
|
|
289
|
-
}
|
|
325
|
+
},
|
|
290
326
|
});
|
|
291
327
|
break;
|
|
292
328
|
}
|
|
293
329
|
case 1: {
|
|
294
|
-
if (this._layouts.bgview.focused)
|
|
330
|
+
if (this._layouts.bgview.focused)
|
|
331
|
+
this.cviews.bgview.view.remakeLayout(this._layouts.bgview.focused);
|
|
295
332
|
$ui.animate({
|
|
296
333
|
duration: 0.2,
|
|
297
334
|
animation: () => {
|
|
298
335
|
this.cviews.bgview.view.relayout();
|
|
299
336
|
this.cviews.cancelButton.view.alpha = 1;
|
|
300
|
-
}
|
|
337
|
+
},
|
|
301
338
|
});
|
|
302
339
|
break;
|
|
303
340
|
}
|
|
304
341
|
case 2: {
|
|
305
|
-
if (this._layouts.iconInput.focused)
|
|
306
|
-
|
|
342
|
+
if (this._layouts.iconInput.focused)
|
|
343
|
+
this.cviews.iconInput.view.remakeLayout(
|
|
344
|
+
this._layouts.iconInput.focused
|
|
345
|
+
);
|
|
346
|
+
if (this._layouts.bgview.focused)
|
|
347
|
+
this.cviews.bgview.view.remakeLayout(this._layouts.bgview.focused);
|
|
307
348
|
$ui.animate({
|
|
308
349
|
duration: 0.2,
|
|
309
350
|
animation: () => {
|
|
310
351
|
this.cviews.iconInput.view.relayout();
|
|
311
352
|
this.cviews.bgview.view.relayout();
|
|
312
353
|
this.cviews.cancelButton.view.alpha = 1;
|
|
313
|
-
}
|
|
354
|
+
},
|
|
314
355
|
});
|
|
315
356
|
break;
|
|
316
357
|
}
|
|
@@ -329,7 +370,7 @@ export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
329
370
|
animation: () => {
|
|
330
371
|
this.cviews.iconInput.view.relayout();
|
|
331
372
|
this.cviews.cancelButton.view.alpha = 0;
|
|
332
|
-
}
|
|
373
|
+
},
|
|
333
374
|
});
|
|
334
375
|
break;
|
|
335
376
|
}
|
|
@@ -340,19 +381,26 @@ export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
340
381
|
animation: () => {
|
|
341
382
|
this.cviews.bgview.view.relayout();
|
|
342
383
|
this.cviews.cancelButton.view.alpha = 0;
|
|
343
|
-
}
|
|
384
|
+
},
|
|
344
385
|
});
|
|
345
386
|
break;
|
|
346
387
|
}
|
|
347
388
|
case 2: {
|
|
348
|
-
const placeholderWidth = getTextWidth(this._props.placeholder, {
|
|
389
|
+
const placeholderWidth = getTextWidth(this._props.placeholder, {
|
|
390
|
+
inset: 20,
|
|
391
|
+
});
|
|
349
392
|
const textWidth = getTextWidth(this.text, { inset: 20 });
|
|
350
|
-
const IconInputLayoutInputing = (
|
|
393
|
+
const IconInputLayoutInputing = (
|
|
394
|
+
make: MASConstraintMaker,
|
|
395
|
+
view: AllUIView
|
|
396
|
+
) => {
|
|
351
397
|
make.center.equalTo(view.super);
|
|
352
398
|
make.top.bottom.inset(0);
|
|
353
|
-
make.width
|
|
399
|
+
make.width
|
|
400
|
+
.equalTo(Math.max(textWidth, placeholderWidth) + 50)
|
|
401
|
+
.priority(999);
|
|
354
402
|
make.width.lessThanOrEqualTo(view.super).priority(1000);
|
|
355
|
-
}
|
|
403
|
+
};
|
|
356
404
|
this.cviews.iconInput.view.remakeLayout(IconInputLayoutInputing);
|
|
357
405
|
this.cviews.bgview.view.remakeLayout(this._layouts.bgview.normal);
|
|
358
406
|
$ui.animate({
|
|
@@ -361,7 +409,7 @@ export class SearchBar extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
361
409
|
this.cviews.iconInput.view.relayout();
|
|
362
410
|
this.cviews.bgview.view.relayout();
|
|
363
411
|
this.cviews.cancelButton.view.alpha = 0;
|
|
364
|
-
}
|
|
412
|
+
},
|
|
365
413
|
});
|
|
366
414
|
break;
|
|
367
415
|
}
|
package/components/sheet.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {cvid} from "../utils/cvid";
|
|
2
|
-
import {Base} from "./base";
|
|
1
|
+
import { cvid } from "../utils/cvid";
|
|
2
|
+
import { Base } from "./base";
|
|
3
3
|
|
|
4
4
|
const UIModalPresentationStyle = {
|
|
5
5
|
automatic: -2,
|
|
@@ -11,13 +11,13 @@ const UIModalPresentationStyle = {
|
|
|
11
11
|
overFullScreen: 5,
|
|
12
12
|
overCurrentContext: 6,
|
|
13
13
|
popover: 7,
|
|
14
|
-
none: -1
|
|
14
|
+
none: -1,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
*
|
|
19
19
|
* 创建新的 UIViewController,主要用于 formSheet 和 pageSheet
|
|
20
|
-
*
|
|
20
|
+
*
|
|
21
21
|
* ## 参数:
|
|
22
22
|
* - presentMode: number, default: 1, pageSheet: 1, formSheet: 2
|
|
23
23
|
* - animated: boolean = true 是否启用动画效果
|
|
@@ -25,13 +25,17 @@ const UIModalPresentationStyle = {
|
|
|
25
25
|
* - bgcolor: $color $color("secondarySurface")
|
|
26
26
|
* - cview: Cview
|
|
27
27
|
* - dismissalHandler: function 退出时的回调
|
|
28
|
-
*
|
|
28
|
+
*
|
|
29
29
|
* ## 方法:
|
|
30
30
|
* - present()
|
|
31
31
|
* - dismiss()
|
|
32
|
-
*
|
|
32
|
+
*
|
|
33
33
|
*/
|
|
34
|
-
export class Sheet<
|
|
34
|
+
export class Sheet<
|
|
35
|
+
T extends Base<U, R>,
|
|
36
|
+
U extends AllUIView,
|
|
37
|
+
R extends UiTypes.AllViewOptions
|
|
38
|
+
> {
|
|
35
39
|
id: string;
|
|
36
40
|
_animated: boolean;
|
|
37
41
|
_presentMode: number;
|
|
@@ -48,7 +52,7 @@ export class Sheet<T extends Base<U, R>, U extends AllUIView, R extends UiTypes.
|
|
|
48
52
|
interactiveDismissalDisabled = false,
|
|
49
53
|
bgcolor = $color("secondarySurface"),
|
|
50
54
|
cview,
|
|
51
|
-
dismissalHandler
|
|
55
|
+
dismissalHandler,
|
|
52
56
|
}: {
|
|
53
57
|
presentMode?: number;
|
|
54
58
|
animated?: boolean;
|
|
@@ -56,7 +60,7 @@ export class Sheet<T extends Base<U, R>, U extends AllUIView, R extends UiTypes.
|
|
|
56
60
|
bgcolor?: UIColor;
|
|
57
61
|
cview?: T;
|
|
58
62
|
dismissalHandler?: () => void;
|
|
59
|
-
|
|
63
|
+
}) {
|
|
60
64
|
this._animated = animated;
|
|
61
65
|
this._presentMode = presentMode;
|
|
62
66
|
this._interactiveDismissalDisabled = interactiveDismissalDisabled;
|
|
@@ -64,7 +68,6 @@ export class Sheet<T extends Base<U, R>, U extends AllUIView, R extends UiTypes.
|
|
|
64
68
|
this._cview = cview;
|
|
65
69
|
this._dismissalHandler = dismissalHandler;
|
|
66
70
|
this.id = cvid.newId;
|
|
67
|
-
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
_create() {
|
|
@@ -84,19 +87,19 @@ export class Sheet<T extends Base<U, R>, U extends AllUIView, R extends UiTypes.
|
|
|
84
87
|
events: {
|
|
85
88
|
"viewDidDisappear:": () => {
|
|
86
89
|
if (this._dismissalHandler) this._dismissalHandler();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
90
|
+
},
|
|
91
|
+
},
|
|
89
92
|
});
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
_add(cview: T) {
|
|
93
|
-
const definition = cview.definition
|
|
94
|
-
definition.layout = $layout.fill
|
|
96
|
+
const definition = cview.definition;
|
|
97
|
+
definition.layout = $layout.fill;
|
|
95
98
|
this._PSViewControllerView.jsValue().add(definition);
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
present() {
|
|
99
|
-
this._create()
|
|
102
|
+
this._create();
|
|
100
103
|
$ui.controller
|
|
101
104
|
.ocValue()
|
|
102
105
|
.invoke(
|
|
@@ -107,6 +110,9 @@ export class Sheet<T extends Base<U, R>, U extends AllUIView, R extends UiTypes.
|
|
|
107
110
|
}
|
|
108
111
|
|
|
109
112
|
dismiss() {
|
|
110
|
-
this._PSViewController.invoke(
|
|
113
|
+
this._PSViewController.invoke(
|
|
114
|
+
"dismissModalViewControllerAnimated",
|
|
115
|
+
this._animated
|
|
116
|
+
);
|
|
111
117
|
}
|
|
112
118
|
}
|