• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit ArkUI
19 */
20
21/**
22 * The refresh status of the drop-down refresh.
23 *
24 * @enum { number }
25 * @syscap SystemCapability.ArkUI.ArkUI.Full
26 * @since 8
27 */
28/**
29 * The refresh status of the drop-down refresh.
30 *
31 * @enum { number }
32 * @syscap SystemCapability.ArkUI.ArkUI.Full
33 * @crossplatform
34 * @since 10
35 */
36/**
37 * The refresh status of the drop-down refresh.
38 *
39 * @enum { number }
40 * @syscap SystemCapability.ArkUI.ArkUI.Full
41 * @crossplatform
42 * @atomicservice
43 * @since 11
44 */
45declare enum RefreshStatus {
46  /**
47   * The refresh status of the drop-down refresh.
48   *
49   * @syscap SystemCapability.ArkUI.ArkUI.Full
50   * @since 8
51   */
52  /**
53   * The refresh status of the drop-down refresh.
54   *
55   * @syscap SystemCapability.ArkUI.ArkUI.Full
56   * @crossplatform
57   * @since 10
58   */
59  /**
60   * The refresh status of the drop-down refresh.
61   *
62   * @syscap SystemCapability.ArkUI.ArkUI.Full
63   * @crossplatform
64   * @atomicservice
65   * @since 11
66   */
67  Inactive,
68
69  /**
70   * Drop down, but the drop-down distance is less than the refresh distance.
71   *
72   * @syscap SystemCapability.ArkUI.ArkUI.Full
73   * @since 8
74   */
75  /**
76   * Drop down, but the drop-down distance is less than the refresh distance.
77   *
78   * @syscap SystemCapability.ArkUI.ArkUI.Full
79   * @crossplatform
80   * @since 10
81   */
82  /**
83   * Drop down, but the drop-down distance is less than the refresh distance.
84   *
85   * @syscap SystemCapability.ArkUI.ArkUI.Full
86   * @crossplatform
87   * @atomicservice
88   * @since 11
89   */
90  Drag,
91
92  /**
93   * The pull-down exceeds the refresh distance.
94   *
95   * @syscap SystemCapability.ArkUI.ArkUI.Full
96   * @since 8
97   */
98  /**
99   * The pull-down exceeds the refresh distance.
100   *
101   * @syscap SystemCapability.ArkUI.ArkUI.Full
102   * @crossplatform
103   * @since 10
104   */
105  /**
106   * The pull-down exceeds the refresh distance.
107   *
108   * @syscap SystemCapability.ArkUI.ArkUI.Full
109   * @crossplatform
110   * @atomicservice
111   * @since 11
112   */
113  OverDrag,
114
115  /**
116   * After the pull-down, it rebounds to the refresh distance and enters the refresh state.
117   *
118   * @syscap SystemCapability.ArkUI.ArkUI.Full
119   * @since 8
120   */
121  /**
122   * After the pull-down, it rebounds to the refresh distance and enters the refresh state.
123   *
124   * @syscap SystemCapability.ArkUI.ArkUI.Full
125   * @crossplatform
126   * @since 10
127   */
128  /**
129   * After the pull-down, it rebounds to the refresh distance and enters the refresh state.
130   *
131   * @syscap SystemCapability.ArkUI.ArkUI.Full
132   * @crossplatform
133   * @atomicservice
134   * @since 11
135   */
136  Refresh,
137
138  /**
139   * After refresh, return to the initial state.
140   *
141   * @syscap SystemCapability.ArkUI.ArkUI.Full
142   * @since 8
143   */
144  /**
145   * After refresh, return to the initial state.
146   *
147   * @syscap SystemCapability.ArkUI.ArkUI.Full
148   * @crossplatform
149   * @since 10
150   */
151  /**
152   * After refresh, return to the initial state.
153   *
154   * @syscap SystemCapability.ArkUI.ArkUI.Full
155   * @crossplatform
156   * @atomicservice
157   * @since 11
158   */
159  Done,
160}
161
162/**
163 * Defines the options of refresh component.
164 *
165 * @interface RefreshOptions
166 * @syscap SystemCapability.ArkUI.ArkUI.Full
167 * @since 8
168 */
169/**
170 * Defines the options of refresh component.
171 *
172 * @interface RefreshOptions
173 * @syscap SystemCapability.ArkUI.ArkUI.Full
174 * @crossplatform
175 * @since 10
176 */
177/**
178 * Defines the options of refresh component.
179 *
180 * @interface RefreshOptions
181 * @syscap SystemCapability.ArkUI.ArkUI.Full
182 * @crossplatform
183 * @atomicservice
184 * @since 11
185 */
186interface RefreshOptions {
187  /**
188   * Whether the current component is being refreshed.
189   * This parameter supports $$ for two-way binding of variables.
190   *
191   * @type { boolean }
192   * @syscap SystemCapability.ArkUI.ArkUI.Full
193   * @since 8
194   */
195  /**
196   * Whether the current component is being refreshed.
197   * This parameter supports $$ for two-way binding of variables.
198   *
199   * @type { boolean }
200   * @syscap SystemCapability.ArkUI.ArkUI.Full
201   * @crossplatform
202   * @since 10
203   */
204  /**
205   * Whether the current component is being refreshed.
206   * This parameter supports $$ for two-way binding of variables.
207   *
208   * @type { boolean }
209   * @syscap SystemCapability.ArkUI.ArkUI.Full
210   * @crossplatform
211   * @atomicservice
212   * @since 11
213   */
214  refreshing: boolean;
215
216  /**
217   * Distance to the top of the parent component from the component that
218   * comes to rest after a successful pull-down gesture. Default value: 16, in vp
219   *
220   * @type { ?(number | string) }
221   * @syscap SystemCapability.ArkUI.ArkUI.Full
222   * @since 8
223   */
224  /**
225   * Distance to the top of the parent component from the component that
226   * comes to rest after a successful pull-down gesture. Default value: 16, in vp
227   *
228   * @type { ?(number | string) }
229   * @syscap SystemCapability.ArkUI.ArkUI.Full
230   * @crossplatform
231   * @since 10
232   * @deprecated since 11
233   */
234  offset?: number | string;
235
236  /**
237   * Coefficient of friction, which indicates the component's sensitivity to the pull-down gesture.
238   * The value ranges from 0 to 100. Default value: 62
239   *   - 0 indicates that the component is not sensitive to the pull-down gesture.
240   *   - 100 indicates that the component is highly sensitive to the pull-down gesture.
241   *   - A larger value indicates a more sensitive response of the component to the pull-down gesture.
242   *
243   * @type { ?(number | string) }
244   * @syscap SystemCapability.ArkUI.ArkUI.Full
245   * @since 8
246   */
247  /**
248   * Coefficient of friction, which indicates the component's sensitivity to the pull-down gesture.
249   * The value ranges from 0 to 100. Default value: 62
250   *   - 0 indicates that the component is not sensitive to the pull-down gesture.
251   *   - 100 indicates that the component is highly sensitive to the pull-down gesture.
252   *   - A larger value indicates a more sensitive response of the component to the pull-down gesture.
253   *
254   * @type { ?(number | string) }
255   * @syscap SystemCapability.ArkUI.ArkUI.Full
256   * @crossplatform
257   * @since 10
258   * @deprecated since 11
259   */
260  friction?: number | string;
261
262  /**
263   * The text displayed during refreshing
264   *
265   * @type { ?ResourceStr }
266   * @syscap SystemCapability.ArkUI.ArkUI.Full
267   * @crossplatform
268   * @atomicservice
269   * @since 12
270   */
271  promptText?: ResourceStr;
272
273  /**
274   * Custom component to display during dragging.
275   *
276   * @type { ?CustomBuilder }
277   * @syscap SystemCapability.ArkUI.ArkUI.Full
278   * @crossplatform
279   * @since 10
280   */
281  /**
282   * Custom component to display during dragging.
283   *
284   * @type { ?CustomBuilder }
285   * @syscap SystemCapability.ArkUI.ArkUI.Full
286   * @crossplatform
287   * @atomicservice
288   * @since 11
289   */
290  builder?: CustomBuilder;
291
292  /**
293   * Custom component to display during dragging.
294   *
295   * @type { ?ComponentContent }
296   * @syscap SystemCapability.ArkUI.ArkUI.Full
297   * @crossplatform
298   * @atomicservice
299   * @since 12
300   */
301  refreshingContent?: ComponentContent;
302}
303
304/**
305 * Provides a pull-down refresh interface.
306 *
307 * @interface RefreshInterface
308 * @syscap SystemCapability.ArkUI.ArkUI.Full
309 * @since 8
310 */
311/**
312 * Provides a pull-down refresh interface.
313 *
314 * @interface RefreshInterface
315 * @syscap SystemCapability.ArkUI.ArkUI.Full
316 * @crossplatform
317 * @since 10
318 */
319/**
320 * Provides a pull-down refresh interface.
321 *
322 * @interface RefreshInterface
323 * @syscap SystemCapability.ArkUI.ArkUI.Full
324 * @crossplatform
325 * @atomicservice
326 * @since 11
327 */
328interface RefreshInterface {
329  /**
330   * Called when the drop-down refresh is set.
331   *
332   * @param { RefreshOptions } value - The options of refresh component.
333   * @returns { RefreshAttribute }
334   * @syscap SystemCapability.ArkUI.ArkUI.Full
335   * @since 8
336   */
337  /**
338   * Called when the drop-down refresh is set.
339   *
340   * @param { RefreshOptions } value - The options of refresh component.
341   * @returns { RefreshAttribute }
342   * @syscap SystemCapability.ArkUI.ArkUI.Full
343   * @crossplatform
344   * @since 10
345   */
346  /**
347   * Called when the drop-down refresh is set.
348   *
349   * @param { RefreshOptions } value - The options of refresh component.
350   * @returns { RefreshAttribute }
351   * @syscap SystemCapability.ArkUI.ArkUI.Full
352   * @crossplatform
353   * @atomicservice
354   * @since 11
355   */
356  (value: RefreshOptions): RefreshAttribute;
357}
358
359/**
360 * Defines the refresh attribute functions.
361 *
362 * @extends CommonMethod<RefreshAttribute>
363 * @syscap SystemCapability.ArkUI.ArkUI.Full
364 * @since 8
365 */
366/**
367 * Defines the refresh attribute functions.
368 *
369 * @extends CommonMethod<RefreshAttribute>
370 * @syscap SystemCapability.ArkUI.ArkUI.Full
371 * @crossplatform
372 * @since 10
373 */
374/**
375 * Defines the refresh attribute functions.
376 *
377 * @extends CommonMethod<RefreshAttribute>
378 * @syscap SystemCapability.ArkUI.ArkUI.Full
379 * @crossplatform
380 * @atomicservice
381 * @since 11
382 */
383declare class RefreshAttribute extends CommonMethod<RefreshAttribute> {
384  /**
385   * Called when the refresh state changes.
386   *
387   * @param { function } callback
388   * @returns { RefreshAttribute }
389   * @syscap SystemCapability.ArkUI.ArkUI.Full
390   * @since 8
391   */
392  /**
393   * Called when the refresh state changes.
394   *
395   * @param { function } callback
396   * @returns { RefreshAttribute }
397   * @syscap SystemCapability.ArkUI.ArkUI.Full
398   * @crossplatform
399   * @since 10
400   */
401  /**
402   * Called when the refresh state changes.
403   *
404   * @param { function } callback
405   * @returns { RefreshAttribute }
406   * @syscap SystemCapability.ArkUI.ArkUI.Full
407   * @crossplatform
408   * @atomicservice
409   * @since 11
410   */
411  onStateChange(callback: (state: RefreshStatus) => void): RefreshAttribute;
412
413  /**
414   * Called when the refresh state is entered.
415   *
416   * @param { function } callback
417   * @returns { RefreshAttribute }
418   * @syscap SystemCapability.ArkUI.ArkUI.Full
419   * @since 8
420   */
421  /**
422   * Called when the refresh state is entered.
423   *
424   * @param { function } callback
425   * @returns { RefreshAttribute }
426   * @syscap SystemCapability.ArkUI.ArkUI.Full
427   * @crossplatform
428   * @since 10
429   */
430  /**
431   * Called when the refresh state is entered.
432   *
433   * @param { function } callback
434   * @returns { RefreshAttribute }
435   * @syscap SystemCapability.ArkUI.ArkUI.Full
436   * @crossplatform
437   * @atomicservice
438   * @since 11
439   */
440  onRefreshing(callback: () => void): RefreshAttribute;
441
442  /**
443   * The pull-down offset to trigger refresh.
444   *
445   * @param { number } value
446   * @returns { RefreshAttribute }
447   * @syscap SystemCapability.ArkUI.ArkUI.Full
448   * @crossplatform
449   * @atomicservice
450   * @since 12
451   */
452  refreshOffset(value: number): RefreshAttribute;
453
454  /**
455   * Sets whether to trigger refresh when the pull-down distance exceeds the refreshOffset.
456   *
457   * @param { boolean } value
458   * @returns { RefreshAttribute }
459   * @syscap SystemCapability.ArkUI.ArkUI.Full
460   * @crossplatform
461   * @atomicservice
462   * @since 12
463   */
464  pullToRefresh(value: boolean): RefreshAttribute;
465
466  /**
467   * Called when the refresh offset changed.
468   * The unit is vp.
469   *
470   * @param { Callback<number> } callback
471   * @returns { RefreshAttribute }
472   * @syscap SystemCapability.ArkUI.ArkUI.Full
473   * @crossplatform
474   * @atomicservice
475   * @since 12
476   */
477  onOffsetChange(callback: Callback<number>): RefreshAttribute;
478
479  /**
480   * Pull-down follow ratio for Refresh.
481   *
482   * @param { Optional<number> } ratio - Pull-down follow ratio for Refresh.
483   * @returns { RefreshAttribute } The attribute of the Refresh.
484   * @syscap SystemCapability.ArkUI.ArkUI.Full
485   * @crossplatform
486   * @atomicservice
487   * @since 12
488   */
489  pullDownRatio(ratio: Optional<number>): RefreshAttribute;
490}
491
492/**
493 * Defines Refresh Component.
494 *
495 * @syscap SystemCapability.ArkUI.ArkUI.Full
496 * @since 8
497 */
498/**
499 * Defines Refresh Component.
500 *
501 * @syscap SystemCapability.ArkUI.ArkUI.Full
502 * @crossplatform
503 * @since 10
504 */
505/**
506 * Defines Refresh Component.
507 *
508 * @syscap SystemCapability.ArkUI.ArkUI.Full
509 * @crossplatform
510 * @atomicservice
511 * @since 11
512 */
513declare const Refresh: RefreshInterface;
514
515/**
516 * Defines Refresh Component instance.
517 *
518 * @syscap SystemCapability.ArkUI.ArkUI.Full
519 * @since 8
520 */
521/**
522 * Defines Refresh Component instance.
523 *
524 * @syscap SystemCapability.ArkUI.ArkUI.Full
525 * @crossplatform
526 * @since 10
527 */
528/**
529 * Defines Refresh Component instance.
530 *
531 * @syscap SystemCapability.ArkUI.ArkUI.Full
532 * @crossplatform
533 * @atomicservice
534 * @since 11
535 */
536declare const RefreshInstance: RefreshAttribute;