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