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