• 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 * Declare the type of status button
23 *
24 * @enum { number }
25 * @syscap SystemCapability.ArkUI.ArkUI.Full
26 * @since 8
27 */
28/**
29 * Declare the type of status button
30 *
31 * @enum { number }
32 * @syscap SystemCapability.ArkUI.ArkUI.Full
33 * @form
34 * @since 9
35 */
36/**
37 * Declare the type of status button
38 *
39 * @enum { number }
40 * @syscap SystemCapability.ArkUI.ArkUI.Full
41 * @crossplatform
42 * @form
43 * @since 10
44 */
45/**
46 * Declare the type of status button
47 *
48 * @enum { number }
49 * @syscap SystemCapability.ArkUI.ArkUI.Full
50 * @crossplatform
51 * @form
52 * @atomicservice
53 * @since 11
54 */
55declare enum ToggleType {
56  /**
57   * Checkbox
58   *
59   * @syscap SystemCapability.ArkUI.ArkUI.Full
60   * @since 8
61   */
62  /**
63   * Checkbox
64   *
65   * @syscap SystemCapability.ArkUI.ArkUI.Full
66   * @form
67   * @since 9
68   */
69  /**
70   * Checkbox
71   *
72   * @syscap SystemCapability.ArkUI.ArkUI.Full
73   * @crossplatform
74   * @form
75   * @since 10
76   */
77  /**
78   * Checkbox
79   *
80   * @syscap SystemCapability.ArkUI.ArkUI.Full
81   * @crossplatform
82   * @form
83   * @atomicservice
84   * @since 11
85   */
86  Checkbox,
87
88  /**
89   * Switch
90   *
91   * @syscap SystemCapability.ArkUI.ArkUI.Full
92   * @since 8
93   */
94  /**
95   * Switch
96   *
97   * @syscap SystemCapability.ArkUI.ArkUI.Full
98   * @form
99   * @since 9
100   */
101  /**
102   * Switch
103   *
104   * @syscap SystemCapability.ArkUI.ArkUI.Full
105   * @crossplatform
106   * @form
107   * @since 10
108   */
109  /**
110   * Switch
111   *
112   * @syscap SystemCapability.ArkUI.ArkUI.Full
113   * @crossplatform
114   * @form
115   * @atomicservice
116   * @since 11
117   */
118  Switch,
119
120  /**
121   * Button
122   *
123   * @syscap SystemCapability.ArkUI.ArkUI.Full
124   * @since 8
125   */
126  /**
127   * Button
128   *
129   * @syscap SystemCapability.ArkUI.ArkUI.Full
130   * @form
131   * @since 9
132   */
133  /**
134   * Button
135   *
136   * @syscap SystemCapability.ArkUI.ArkUI.Full
137   * @crossplatform
138   * @form
139   * @since 10
140   */
141  /**
142   * Button
143   *
144   * @syscap SystemCapability.ArkUI.ArkUI.Full
145   * @crossplatform
146   * @form
147   * @atomicservice
148   * @since 11
149   */
150  Button,
151}
152
153/**
154 * Defines the switch style.
155 *
156 * @interface SwitchStyle
157 * @syscap SystemCapability.ArkUI.ArkUI.Full
158 * @crossplatform
159 * @atomicservice
160 * @since 12
161 */
162declare interface SwitchStyle {
163  /**
164   * Set the radius of the point of the switch.
165   *
166   * @type { ?(number | Resource) }
167   * @syscap SystemCapability.ArkUI.ArkUI.Full
168   * @crossplatform
169   * @atomicservice
170   * @since 12
171   */
172  pointRadius?: number | Resource;
173
174  /**
175   * Set the color of the unselected switch.
176   *
177   * @type { ?ResourceColor }
178   * @syscap SystemCapability.ArkUI.ArkUI.Full
179   * @crossplatform
180   * @atomicservice
181   * @since 12
182   */
183  unselectedColor?: ResourceColor;
184
185  /**
186   * Set the color of the point of the switch.
187   *
188   * @type { ?ResourceColor }
189   * @syscap SystemCapability.ArkUI.ArkUI.Full
190   * @crossplatform
191   * @atomicservice
192   * @since 12
193   */
194  pointColor?: ResourceColor;
195
196  /**
197   * Set the border radius of the track of the switch.
198   *
199   * @type { ?(number | Resource) }
200   * @syscap SystemCapability.ArkUI.ArkUI.Full
201   * @crossplatform
202   * @atomicservice
203   * @since 12
204   */
205  trackBorderRadius?: number | Resource;
206}
207
208/**
209 * ToggleConfiguration used by toggle Modifier
210 *
211 * @extends CommonConfiguration<ToggleConfiguration>
212 * @interface ToggleConfiguration
213 * @syscap SystemCapability.ArkUI.ArkUI.Full
214 * @crossplatform
215 * @atomicservice
216 * @since 12
217 */
218declare interface ToggleConfiguration extends CommonConfiguration<ToggleConfiguration> {
219
220  /**
221   * Indicates whether the Toggle is on.
222   *
223   * @type { boolean }
224   * @syscap SystemCapability.ArkUI.ArkUI.Full
225   * @crossplatform
226   * @atomicservice
227   * @since 12
228   */
229  isOn: boolean;
230
231  /**
232   * Indicates whether the Toggle is enabled.
233   *
234   * @type { boolean }
235   * @syscap SystemCapability.ArkUI.ArkUI.Full
236   * @crossplatform
237   * @atomicservice
238   * @since 12
239   */
240  enabled: boolean;
241
242  /**
243   * Trigger toggle select change
244   *
245   * @type { Callback<boolean> }
246   * @syscap SystemCapability.ArkUI.ArkUI.Full
247   * @crossplatform
248   * @atomicservice
249   * @since 12
250   */
251  triggerChange: Callback<boolean>;
252}
253
254/**
255 * Defines the toggle options.
256 *
257 * @interface ToggleOptions
258 * @syscap SystemCapability.ArkUI.ArkUI.Full
259 * @crossplatform
260 * @form
261 * @atomicservice
262 * @since 18
263 */
264declare interface ToggleOptions {
265  /**
266   * Type of the toggle.
267   *
268   * @type { ToggleType }
269   * @syscap SystemCapability.ArkUI.ArkUI.Full
270   * @since 8
271   */
272  /**
273   * Type of the toggle.
274   *
275   * @type { ToggleType }
276   * @syscap SystemCapability.ArkUI.ArkUI.Full
277   * @form
278   * @since 9
279   */
280  /**
281   * Type of the toggle.
282   *
283   * @type { ToggleType }
284   * @syscap SystemCapability.ArkUI.ArkUI.Full
285   * @crossplatform
286   * @form
287   * @since 10
288   */
289  /**
290   * Type of the toggle.
291   *
292   * @type { ToggleType }
293   * @syscap SystemCapability.ArkUI.ArkUI.Full
294   * @crossplatform
295   * @form
296   * @atomicservice
297   * @since 11
298   */
299  /**
300   * Type of the toggle.
301   * Anonymous Object Rectification.
302   *
303   * @type { ToggleType }
304   * @syscap SystemCapability.ArkUI.ArkUI.Full
305   * @crossplatform
306   * @form
307   * @atomicservice
308   * @since 18
309   */
310  type: ToggleType;
311
312  /**
313   * Whether the toggle is on.
314   *
315   * @type { ?boolean }
316   * @syscap SystemCapability.ArkUI.ArkUI.Full
317   * @since 8
318   */
319  /**
320   * Whether the toggle is on.
321   *
322   * @type { ?boolean }
323   * @syscap SystemCapability.ArkUI.ArkUI.Full
324   * @form
325   * @since 9
326   */
327  /**
328   * Whether the toggle is on.
329   *
330   * @type { ?boolean }
331   * @syscap SystemCapability.ArkUI.ArkUI.Full
332   * @crossplatform
333   * @form
334   * @since 10
335   */
336  /**
337   * Whether the toggle is on.
338   *
339   * @type { ?boolean }
340   * @syscap SystemCapability.ArkUI.ArkUI.Full
341   * @crossplatform
342   * @form
343   * @atomicservice
344   * @since 11
345   */
346  /**
347   * Whether the toggle is on.
348   * Anonymous Object Rectification.
349   *
350   * @type { ?boolean }
351   * @syscap SystemCapability.ArkUI.ArkUI.Full
352   * @crossplatform
353   * @form
354   * @atomicservice
355   * @since 18
356   */
357  isOn?: boolean
358}
359
360/**
361 * Defines the toggle interface.
362 *
363 * @interface ToggleInterface
364 * @syscap SystemCapability.ArkUI.ArkUI.Full
365 * @since 8
366 */
367/**
368 * Defines the toggle interface.
369 *
370 * @interface ToggleInterface
371 * @syscap SystemCapability.ArkUI.ArkUI.Full
372 * @form
373 * @since 9
374 */
375/**
376 * Defines the toggle interface.
377 *
378 * @interface ToggleInterface
379 * @syscap SystemCapability.ArkUI.ArkUI.Full
380 * @crossplatform
381 * @form
382 * @since 10
383 */
384/**
385 * Defines the toggle interface.
386 *
387 * @interface ToggleInterface
388 * @syscap SystemCapability.ArkUI.ArkUI.Full
389 * @crossplatform
390 * @form
391 * @atomicservice
392 * @since 11
393 */
394interface ToggleInterface {
395  /**
396   * Set parameters to obtain the toggle.
397   *
398   * @param { object } options
399   * @returns { ToggleAttribute }
400   * @syscap SystemCapability.ArkUI.ArkUI.Full
401   * @since 8
402   */
403  /**
404   * Set parameters to obtain the toggle.
405   *
406   * @param { object } options
407   * @returns { ToggleAttribute }
408   * @syscap SystemCapability.ArkUI.ArkUI.Full
409   * @form
410   * @since 9
411   */
412  /**
413   * Set parameters to obtain the toggle.
414   *
415   * @param { object } options
416   * @returns { ToggleAttribute }
417   * @syscap SystemCapability.ArkUI.ArkUI.Full
418   * @crossplatform
419   * @form
420   * @since 10
421   */
422  /**
423   * Set parameters to obtain the toggle.
424   *
425   * @param { object } options
426   * @returns { ToggleAttribute }
427   * @syscap SystemCapability.ArkUI.ArkUI.Full
428   * @crossplatform
429   * @form
430   * @atomicservice
431   * @since 11
432   */
433  /**
434   * Set parameters to obtain the toggle.
435   * Anonymous Object Rectification.
436   *
437   * @param { ToggleOptions } options - toggle options
438   * @returns { ToggleAttribute }
439   * @syscap SystemCapability.ArkUI.ArkUI.Full
440   * @crossplatform
441   * @form
442   * @atomicservice
443   * @since 18
444   */
445  (options: ToggleOptions): ToggleAttribute;
446}
447
448/**
449 * Defines the toggle attribute functions
450 *
451 * @extends CommonMethod<ToggleAttribute>
452 * @syscap SystemCapability.ArkUI.ArkUI.Full
453 * @since 8
454 */
455/**
456 * Defines the toggle attribute functions
457 *
458 * @extends CommonMethod<ToggleAttribute>
459 * @syscap SystemCapability.ArkUI.ArkUI.Full
460 * @form
461 * @since 9
462 */
463/**
464 * Defines the toggle attribute functions
465 *
466 * @extends CommonMethod<ToggleAttribute>
467 * @syscap SystemCapability.ArkUI.ArkUI.Full
468 * @crossplatform
469 * @form
470 * @since 10
471 */
472/**
473 * Defines the toggle attribute functions
474 *
475 * @extends CommonMethod<ToggleAttribute>
476 * @syscap SystemCapability.ArkUI.ArkUI.Full
477 * @crossplatform
478 * @form
479 * @atomicservice
480 * @since 11
481 */
482declare class ToggleAttribute extends CommonMethod<ToggleAttribute> {
483  /**
484   * Called when the selected state of the component changes.
485   *
486   * @param { function } callback
487   * @returns { ToggleAttribute }
488   * @syscap SystemCapability.ArkUI.ArkUI.Full
489   * @since 8
490   */
491  /**
492   * Called when the selected state of the component changes.
493   *
494   * @param { function } callback
495   * @returns { ToggleAttribute }
496   * @syscap SystemCapability.ArkUI.ArkUI.Full
497   * @form
498   * @since 9
499   */
500  /**
501   * Called when the selected state of the component changes.
502   *
503   * @param { function } callback
504   * @returns { ToggleAttribute }
505   * @syscap SystemCapability.ArkUI.ArkUI.Full
506   * @crossplatform
507   * @form
508   * @since 10
509   */
510  /**
511   * Called when the selected state of the component changes.
512   *
513   * @param { function } callback
514   * @returns { ToggleAttribute }
515   * @syscap SystemCapability.ArkUI.ArkUI.Full
516   * @crossplatform
517   * @form
518   * @atomicservice
519   * @since 11
520   */
521  onChange(callback: (isOn: boolean) => void): ToggleAttribute;
522
523  /**
524   * Set the content modifier of toggle.
525   *
526   * @param { ContentModifier<ToggleConfiguration> } modifier - The content modifier of toggle.
527   * @returns { ToggleAttribute }
528   * @syscap SystemCapability.ArkUI.ArkUI.Full
529   * @crossplatform
530   * @atomicservice
531   * @since 12
532   */
533  contentModifier(modifier: ContentModifier<ToggleConfiguration>): ToggleAttribute;
534
535  /**
536   * Called when the color of the selected button is set.
537   *
538   * @param { ResourceColor } value
539   * @returns { ToggleAttribute }
540   * @syscap SystemCapability.ArkUI.ArkUI.Full
541   * @since 8
542   */
543  /**
544   * Called when the color of the selected button is set.
545   *
546   * @param { ResourceColor } value
547   * @returns { ToggleAttribute }
548   * @syscap SystemCapability.ArkUI.ArkUI.Full
549   * @form
550   * @since 9
551   */
552  /**
553   * Called when the color of the selected button is set.
554   *
555   * @param { ResourceColor } value
556   * @returns { ToggleAttribute }
557   * @syscap SystemCapability.ArkUI.ArkUI.Full
558   * @crossplatform
559   * @form
560   * @since 10
561   */
562  /**
563   * Called when the color of the selected button is set.
564   *
565   * @param { ResourceColor } value
566   * @returns { ToggleAttribute }
567   * @syscap SystemCapability.ArkUI.ArkUI.Full
568   * @crossplatform
569   * @form
570   * @atomicservice
571   * @since 11
572   */
573  selectedColor(value: ResourceColor): ToggleAttribute;
574
575  /**
576   * Called when the color of the selected button is set.
577   *
578   * @param { ResourceColor } color
579   * @returns { ToggleAttribute }
580   * @syscap SystemCapability.ArkUI.ArkUI.Full
581   * @since 8
582   */
583  /**
584   * Called when the color of the selected button is set.
585   *
586   * @param { ResourceColor } color
587   * @returns { ToggleAttribute }
588   * @syscap SystemCapability.ArkUI.ArkUI.Full
589   * @form
590   * @since 9
591   */
592  /**
593   * Called when the color of the selected button is set.
594   *
595   * @param { ResourceColor } color
596   * @returns { ToggleAttribute }
597   * @syscap SystemCapability.ArkUI.ArkUI.Full
598   * @crossplatform
599   * @form
600   * @since 10
601   */
602  /**
603   * Called when the color of the selected button is set.
604   *
605   * @param { ResourceColor } color
606   * @returns { ToggleAttribute }
607   * @syscap SystemCapability.ArkUI.ArkUI.Full
608   * @crossplatform
609   * @form
610   * @atomicservice
611   * @since 11
612   */
613  switchPointColor(color: ResourceColor): ToggleAttribute;
614
615  /**
616   * Set the style of the switch.
617   *
618   * @param { SwitchStyle } value
619   * @returns { ToggleAttribute }
620   * @syscap SystemCapability.ArkUI.ArkUI.Full
621   * @crossplatform
622   * @atomicservice
623   * @since 12
624   */
625  switchStyle(value: SwitchStyle): ToggleAttribute;
626}
627
628/**
629 * Defines Toggle Component.
630 *
631 * @syscap SystemCapability.ArkUI.ArkUI.Full
632 * @since 8
633 */
634/**
635 * Defines Toggle Component.
636 *
637 * @syscap SystemCapability.ArkUI.ArkUI.Full
638 * @form
639 * @since 9
640 */
641/**
642 * Defines Toggle Component.
643 *
644 * @syscap SystemCapability.ArkUI.ArkUI.Full
645 * @crossplatform
646 * @form
647 * @since 10
648 */
649/**
650 * Defines Toggle Component.
651 *
652 * @syscap SystemCapability.ArkUI.ArkUI.Full
653 * @crossplatform
654 * @form
655 * @atomicservice
656 * @since 11
657 */
658declare const Toggle: ToggleInterface;
659
660/**
661 * Defines Toggle Component instance.
662 *
663 * @syscap SystemCapability.ArkUI.ArkUI.Full
664 * @since 8
665 */
666/**
667 * Defines Toggle Component instance.
668 *
669 * @syscap SystemCapability.ArkUI.ArkUI.Full
670 * @form
671 * @since 9
672 */
673/**
674 * Defines Toggle Component instance.
675 *
676 * @syscap SystemCapability.ArkUI.ArkUI.Full
677 * @crossplatform
678 * @form
679 * @since 10
680 */
681/**
682 * Defines Toggle Component instance.
683 *
684 * @syscap SystemCapability.ArkUI.ArkUI.Full
685 * @crossplatform
686 * @form
687 * @atomicservice
688 * @since 11
689 */
690declare const ToggleInstance: ToggleAttribute;
691