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 { CommonConfiguration,CommonMethod,ShadowOptions,ContentModifier } from './common' 23import { ResourceColor,Length,ResourceStr } from './units' 24import { FontStyle,FontWeight } from './enums' 25/*** endif */ 26 27/** 28 * Provides a way to control the process. 29 * 30 * @since 8 31 */ 32/** 33 * Provides a way to control the process. 34 * 35 * @syscap SystemCapability.ArkUI.ArkUI.Full 36 * @crossplatform 37 * @form 38 * @since 10 39 */ 40/** 41 * Provides a way to control the process. 42 * 43 * @syscap SystemCapability.ArkUI.ArkUI.Full 44 * @crossplatform 45 * @form 46 * @atomicservice 47 * @since arkts {'1.1':'11','1.2':'20'} 48 * @arkts 1.1&1.2 49 */ 50declare class TextTimerController { 51 /** 52 * constructor. 53 * 54 * @syscap SystemCapability.ArkUI.ArkUI.Full 55 * @since 8 56 */ 57 /** 58 * constructor. 59 * 60 * @syscap SystemCapability.ArkUI.ArkUI.Full 61 * @crossplatform 62 * @form 63 * @since 10 64 */ 65 /** 66 * constructor. 67 * A constructor used to create a TextTimerController object. 68 * 69 * @syscap SystemCapability.ArkUI.ArkUI.Full 70 * @crossplatform 71 * @form 72 * @atomicservice 73 * @since arkts {'1.1':'11','1.2':'20'} 74 * @arkts 1.1&1.2 75 */ 76 constructor(); 77 78 /** 79 * Provides a start event for timer. 80 * 81 * @syscap SystemCapability.ArkUI.ArkUI.Full 82 * @since 8 83 */ 84 /** 85 * Provides a start event for timer. 86 * 87 * @syscap SystemCapability.ArkUI.ArkUI.Full 88 * @crossplatform 89 * @form 90 * @since 10 91 */ 92 /** 93 * Starts the timer. 94 * 95 * @syscap SystemCapability.ArkUI.ArkUI.Full 96 * @crossplatform 97 * @form 98 * @atomicservice 99 * @since 11 100 */ 101 start(); 102 103 /** 104 * Provides a start event for timer. 105 * 106 * @syscap SystemCapability.ArkUI.ArkUI.Full 107 * @crossplatform 108 * @form 109 * @atomicservice 110 * @since 20 111 * @arkts 1.2 112 */ 113 start():void; 114 115 /** 116 * Provides a pause event for timer. 117 * 118 * @syscap SystemCapability.ArkUI.ArkUI.Full 119 * @since 8 120 */ 121 /** 122 * Provides a pause event for timer. 123 * 124 * @syscap SystemCapability.ArkUI.ArkUI.Full 125 * @crossplatform 126 * @form 127 * @since 10 128 */ 129 /** 130 * Pauses the timer. 131 * 132 * @syscap SystemCapability.ArkUI.ArkUI.Full 133 * @crossplatform 134 * @form 135 * @atomicservice 136 * @since 11 137 */ 138 pause(); 139 140 /** 141 * Provides a pause event for timer. 142 * 143 * @syscap SystemCapability.ArkUI.ArkUI.Full 144 * @crossplatform 145 * @form 146 * @atomicservice 147 * @since 20 148 * @arkts 1.2 149 */ 150 pause():void; 151 152 /** 153 * Provides an event to reset timer. 154 * 155 * @syscap SystemCapability.ArkUI.ArkUI.Full 156 * @since 8 157 */ 158 /** 159 * Provides an event to reset timer. 160 * 161 * @syscap SystemCapability.ArkUI.ArkUI.Full 162 * @crossplatform 163 * @form 164 * @since 10 165 */ 166 /** 167 * Resets the timer. 168 * 169 * @syscap SystemCapability.ArkUI.ArkUI.Full 170 * @crossplatform 171 * @form 172 * @atomicservice 173 * @since 11 174 */ 175 reset(); 176 177 /** 178 * Provides an event to reset timer. 179 * 180 * @syscap SystemCapability.ArkUI.ArkUI.Full 181 * @crossplatform 182 * @form 183 * @atomicservice 184 * @since 20 185 * @arkts 1.2 186 */ 187 reset():void; 188} 189 190/** 191 * TextTimerConfiguration used by content modifier. 192 * 193 * @extends CommonConfiguration<TextTimerConfiguration> 194 * @interface TextTimerConfiguration 195 * @syscap SystemCapability.ArkUI.ArkUI.Full 196 * @crossplatform 197 * @atomicservice 198 * @since arkts {'1.1':'12','1.2':'20'} 199 * @arkts 1.1&1.2 200 */ 201declare interface TextTimerConfiguration extends CommonConfiguration<TextTimerConfiguration> { 202 /** 203 * Timer duration, in milliseconds. 204 * It is effective only when isCountDown is true. 205 * The maximum value is 86400000 ms (24 hours). 206 * 207 * <p><strong>NOTE</strong>: 208 * <br>If the value is between 0 and 86,400,000, it is used as the initial countdown time. 209 * <br>Otherwise, the default value is used as the initial countdown time. 210 * </p> 211 * 212 * @type { number } 213 * @default 60000 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 count: number; 221 222 /** 223 * Whether the timer is a countdown. 224 * The value true means that the timer counts down, 225 * and false means that the timer counts up. 226 * 227 * @type { boolean } 228 * @default false 229 * @syscap SystemCapability.ArkUI.ArkUI.Full 230 * @crossplatform 231 * @atomicservice 232 * @since arkts {'1.1':'12','1.2':'20'} 233 * @arkts 1.1&1.2 234 */ 235 isCountDown: boolean; 236 237 /** 238 * Whether the timer has already started. 239 * 240 * @type { boolean } 241 * @syscap SystemCapability.ArkUI.ArkUI.Full 242 * @crossplatform 243 * @atomicservice 244 * @since arkts {'1.1':'12','1.2':'20'} 245 * @arkts 1.1&1.2 246 */ 247 started: boolean; 248 249 /** 250 * Elapsed time of the timer, in the minimum unit of the format. 251 * 252 * @type { number } 253 * @syscap SystemCapability.ArkUI.ArkUI.Full 254 * @crossplatform 255 * @atomicservice 256 * @since arkts {'1.1':'12','1.2':'20'} 257 * @arkts 1.1&1.2 258 */ 259 elapsedTime: number; 260} 261 262/** 263 * Defines the options of TextTimer. 264 * 265 * @interface TextTimerOptions 266 * @syscap SystemCapability.ArkUI.ArkUI.Full 267 * @since 8 268 */ 269/** 270 * Defines the options of TextTimer. 271 * 272 * @interface TextTimerOptions 273 * @syscap SystemCapability.ArkUI.ArkUI.Full 274 * @crossplatform 275 * @form 276 * @since 10 277 */ 278/** 279 * Parameters of the TextTimer component. 280 * 281 * @interface TextTimerOptions 282 * @syscap SystemCapability.ArkUI.ArkUI.Full 283 * @crossplatform 284 * @form 285 * @atomicservice 286 * @since arkts {'1.1':'11','1.2':'20'} 287 * @arkts 1.1&1.2 288 */ 289interface TextTimerOptions { 290 /** 291 * Sets whether to countdown.The default value is false. 292 * 293 * @type { ?boolean } 294 * @syscap SystemCapability.ArkUI.ArkUI.Full 295 * @since 8 296 */ 297 /** 298 * Sets whether to countdown.The default value is false. 299 * 300 * @type { ?boolean } 301 * @syscap SystemCapability.ArkUI.ArkUI.Full 302 * @crossplatform 303 * @form 304 * @since 10 305 */ 306 /** 307 * Whether the timer is a countdown. 308 * The value true means that the timer counts down, 309 * and false means that the timer counts up. 310 * 311 * @type { ?boolean } - Default value: false 312 * @syscap SystemCapability.ArkUI.ArkUI.Full 313 * @crossplatform 314 * @form 315 * @atomicservice 316 * @since arkts {'1.1':'11','1.2':'20'} 317 * @arkts 1.1&1.2 318 */ 319 isCountDown?: boolean; 320 321 /** 322 * Specifies the timer range. 323 * In the non-countDown scenario, a negative value indicates that the timer is not limited. 324 * The unit is millisecond. 325 * 326 * @type { ?number } 327 * @syscap SystemCapability.ArkUI.ArkUI.Full 328 * @since 8 329 */ 330 /** 331 * Specifies the timer range. 332 * In the non-countDown scenario, a negative value indicates that the timer is not limited. 333 * The unit is millisecond. 334 * 335 * @type { ?number } 336 * @syscap SystemCapability.ArkUI.ArkUI.Full 337 * @crossplatform 338 * @form 339 * @since 10 340 */ 341 /** 342 * Timer duration, in milliseconds. 343 * It is effective only when isCountDown is true. 344 * The maximum value is 86400000 ms (24 hours). 345 * 346 * <p><strong>NOTE</strong>: 347 * <br>If the value is between 0 and 86,400,000, it is used as the initial countdown time. 348 * <br>Otherwise, the default value is used as the initial countdown time. 349 * </p> 350 * 351 * @type { ?number } - Default value: 60000 352 * @syscap SystemCapability.ArkUI.ArkUI.Full 353 * @crossplatform 354 * @form 355 * @atomicservice 356 * @since arkts {'1.1':'11','1.2':'20'} 357 * @arkts 1.1&1.2 358 */ 359 count?: number; 360 361 /** 362 * Controller of Texttimer. 363 * 364 * @type { ?TextTimerController } 365 * @syscap SystemCapability.ArkUI.ArkUI.Full 366 * @since 8 367 */ 368 /** 369 * Controller of Texttimer. 370 * 371 * @type { ?TextTimerController } 372 * @syscap SystemCapability.ArkUI.ArkUI.Full 373 * @crossplatform 374 * @form 375 * @since 10 376 */ 377 /** 378 * TextTimer controller. 379 * 380 * @type { ?TextTimerController } 381 * @syscap SystemCapability.ArkUI.ArkUI.Full 382 * @crossplatform 383 * @form 384 * @atomicservice 385 * @since arkts {'1.1':'11','1.2':'20'} 386 * @arkts 1.1&1.2 387 */ 388 controller?: TextTimerController; 389} 390 391/** 392 * Provides an interface for texttimer containers. 393 * 394 * @interface TextTimerInterface 395 * @syscap SystemCapability.ArkUI.ArkUI.Full 396 * @since 8 397 */ 398/** 399 * Provides an interface for texttimer containers. 400 * 401 * @interface TextTimerInterface 402 * @syscap SystemCapability.ArkUI.ArkUI.Full 403 * @crossplatform 404 * @form 405 * @since 10 406 */ 407/** 408 * Provides an interface for texttimer containers. 409 * 410 * @interface TextTimerInterface 411 * @syscap SystemCapability.ArkUI.ArkUI.Full 412 * @crossplatform 413 * @form 414 * @atomicservice 415 * @since arkts {'1.1':'11','1.2':'20'} 416 * @arkts 1.1&1.2 417 */ 418interface TextTimerInterface { 419 /** 420 * Defines the TextTimer constructor. 421 * 422 * @param { TextTimerOptions } options 423 * @returns { TextTimerAttribute } 424 * @syscap SystemCapability.ArkUI.ArkUI.Full 425 * @since 8 426 */ 427 /** 428 * Defines the TextTimer constructor. 429 * 430 * @param { TextTimerOptions } options 431 * @returns { TextTimerAttribute } 432 * @syscap SystemCapability.ArkUI.ArkUI.Full 433 * @crossplatform 434 * @form 435 * @since 10 436 */ 437 /** 438 * A constructor used to create a TextTimerController object. 439 * 440 * @param { TextTimerOptions } options 441 * @returns { TextTimerAttribute } 442 * @syscap SystemCapability.ArkUI.ArkUI.Full 443 * @crossplatform 444 * @form 445 * @atomicservice 446 * @since arkts {'1.1':'11','1.2':'20'} 447 * @arkts 1.1&1.2 448 */ 449 (options?: TextTimerOptions): TextTimerAttribute; 450} 451 452/** 453 * Defines the TextTimer attribute functions. 454 * 455 * @extends CommonMethod<TextTimerAttribute> 456 * @since 8 457 */ 458/** 459 * Defines the TextTimer attribute functions. 460 * 461 * @extends CommonMethod<TextTimerAttribute> 462 * @syscap SystemCapability.ArkUI.ArkUI.Full 463 * @crossplatform 464 * @form 465 * @since 10 466 */ 467/** 468 * Defines the TextTimer attribute functions. 469 * 470 * @extends CommonMethod<TextTimerAttribute> 471 * @syscap SystemCapability.ArkUI.ArkUI.Full 472 * @crossplatform 473 * @form 474 * @atomicservice 475 * @since arkts {'1.1':'11','1.2':'20'} 476 * @arkts 1.1&1.2 477 */ 478declare class TextTimerAttribute extends CommonMethod<TextTimerAttribute> { 479 /** 480 * Set the display time format, for example, now is hh/mm/ss/ms and current: hh-mm-ss-ms. 481 * The time format string can be hh, mm, ss, or ms. 482 * 483 * @param { string } value 484 * @returns { TextTimerAttribute } 485 * @syscap SystemCapability.ArkUI.ArkUI.Full 486 * @since 8 487 */ 488 /** 489 * Set the display time format, for example, now is hh/mm/ss/ms and current: hh-mm-ss-ms. 490 * The time format string can be hh, mm, ss, or ms. 491 * 492 * @param { string } value 493 * @returns { TextTimerAttribute } 494 * @syscap SystemCapability.ArkUI.ArkUI.Full 495 * @crossplatform 496 * @form 497 * @since 10 498 */ 499 /** 500 * Sets the custom format. 501 * The value must contain at least one of the following keywords: HH, mm, ss, and SS. 502 * 503 * <p><strong>NOTE</strong>: 504 * <br>If the specified date format is yy, MM, or dd, the default value is used instead. 505 * </p> 506 * 507 * @param { string } value - Custom format.Default value: 'HH:mm:ss.SS' 508 * @returns { TextTimerAttribute } 509 * @syscap SystemCapability.ArkUI.ArkUI.Full 510 * @crossplatform 511 * @form 512 * @atomicservice 513 * @since arkts {'1.1':'11','1.2':'20'} 514 * @arkts 1.1&1.2 515 */ 516 format(value: string): TextTimerAttribute; 517 518 /** 519 * Called when the font color is set. 520 * 521 * @param { ResourceColor } value 522 * @returns { TextTimerAttribute } 523 * @syscap SystemCapability.ArkUI.ArkUI.Full 524 * @since 8 525 */ 526 /** 527 * Called when the font color is set. 528 * 529 * @param { ResourceColor } value 530 * @returns { TextTimerAttribute } 531 * @syscap SystemCapability.ArkUI.ArkUI.Full 532 * @crossplatform 533 * @form 534 * @since 10 535 */ 536 /** 537 * Sets the font color. 538 * 539 * @param { ResourceColor } value 540 * @returns { TextTimerAttribute } 541 * @syscap SystemCapability.ArkUI.ArkUI.Full 542 * @crossplatform 543 * @form 544 * @atomicservice 545 * @since arkts {'1.1':'11','1.2':'20'} 546 * @arkts 1.1&1.2 547 */ 548 fontColor(value: ResourceColor): TextTimerAttribute; 549 550 /** 551 * Called when the font size is set. 552 * 553 * @param { Length } value 554 * @returns { TextTimerAttribute } 555 * @syscap SystemCapability.ArkUI.ArkUI.Full 556 * @since 8 557 */ 558 /** 559 * Called when the font size is set. 560 * 561 * @param { Length } value 562 * @returns { TextTimerAttribute } 563 * @syscap SystemCapability.ArkUI.ArkUI.Full 564 * @crossplatform 565 * @form 566 * @since 10 567 */ 568 /** 569 * Sets the font size. 570 * 571 * @param { Length } value - Font size.The default font size is 16 fp. 572 * <br>If fontSize is of the number type, the unit fp is used. 573 * <br>The value cannot be a percentage. 574 * @returns { TextTimerAttribute } 575 * @syscap SystemCapability.ArkUI.ArkUI.Full 576 * @crossplatform 577 * @form 578 * @atomicservice 579 * @since arkts {'1.1':'11','1.2':'20'} 580 * @arkts 1.1&1.2 581 */ 582 fontSize(value: Length): TextTimerAttribute; 583 584 /** 585 * Called when the fontStyle is set 586 * 587 * @param { FontStyle } value 588 * @returns { TextTimerAttribute } 589 * @syscap SystemCapability.ArkUI.ArkUI.Full 590 * @since 8 591 */ 592 /** 593 * Called when the fontStyle is set 594 * 595 * @param { FontStyle } value 596 * @returns { TextTimerAttribute } 597 * @syscap SystemCapability.ArkUI.ArkUI.Full 598 * @crossplatform 599 * @form 600 * @since 10 601 */ 602 /** 603 * Sets the font style. 604 * 605 * @param { FontStyle } value - Font style.Default value: FontStyle.Normal 606 * @returns { TextTimerAttribute } 607 * @syscap SystemCapability.ArkUI.ArkUI.Full 608 * @crossplatform 609 * @form 610 * @atomicservice 611 * @since arkts {'1.1':'11','1.2':'20'} 612 * @arkts 1.1&1.2 613 */ 614 fontStyle(value: FontStyle): TextTimerAttribute; 615 616 /** 617 * Called when the fontWeight is set 618 * 619 * @param { number | FontWeight | string } value 620 * @returns { TextTimerAttribute } 621 * @syscap SystemCapability.ArkUI.ArkUI.Full 622 * @since 8 623 */ 624 /** 625 * Called when the fontWeight is set 626 * 627 * @param { number | FontWeight | string } value 628 * @returns { TextTimerAttribute } 629 * @syscap SystemCapability.ArkUI.ArkUI.Full 630 * @crossplatform 631 * @form 632 * @since 10 633 */ 634 /** 635 * Called when the fontWeight is set 636 * 637 * @param { number | FontWeight | string } value 638 * @returns { TextTimerAttribute } 639 * @syscap SystemCapability.ArkUI.ArkUI.Full 640 * @crossplatform 641 * @form 642 * @atomicservice 643 * @since 11 644 */ 645 /** 646 * Sets the font weight. 647 * 648 * <p><strong>NOTE</strong>: 649 * <br>If the value is too large, the text may be clipped depending on the font. 650 * </p> 651 * 652 * @param { number | FontWeight | ResourceStr } value - Font weight. 653 * <br>For the number type, Value range: [100, 900], at an interval of 100.The default value is 400. 654 * <br>A larger value indicates a heavier font weight. 655 * <br>For the string type, only strings that represent a number. 656 * @returns { TextTimerAttribute } 657 * @syscap SystemCapability.ArkUI.ArkUI.Full 658 * @crossplatform 659 * @form 660 * @atomicservice 661 * @since 20 662 * @arkts 1.1&1.2 663 */ 664 fontWeight(value: number | FontWeight | ResourceStr): TextTimerAttribute; 665 666 /** 667 * Called when the fontFamily is set 668 * 669 * @param { ResourceStr } value 670 * @returns { TextTimerAttribute } 671 * @syscap SystemCapability.ArkUI.ArkUI.Full 672 * @since 8 673 */ 674 /** 675 * Called when the fontFamily is set 676 * 677 * @param { ResourceStr } value 678 * @returns { TextTimerAttribute } 679 * @syscap SystemCapability.ArkUI.ArkUI.Full 680 * @crossplatform 681 * @form 682 * @since 10 683 */ 684 /** 685 * Sets the font family. 686 * 687 * @param { ResourceStr } value - Font family. Default font: 'HarmonyOS Sans' 688 * @returns { TextTimerAttribute } 689 * @syscap SystemCapability.ArkUI.ArkUI.Full 690 * @crossplatform 691 * @form 692 * @atomicservice 693 * @since arkts {'1.1':'11','1.2':'20'} 694 * @arkts 1.1&1.2 695 */ 696 fontFamily(value: ResourceStr): TextTimerAttribute; 697 698 /** 699 * Called when the timer value is returned. 700 * 701 * @param { function } event 702 * @returns { TextTimerAttribute } 703 * @syscap SystemCapability.ArkUI.ArkUI.Full 704 * @since 8 705 */ 706 /** 707 * Called when the timer value is returned. 708 * 709 * @param { function } event 710 * @returns { TextTimerAttribute } 711 * @syscap SystemCapability.ArkUI.ArkUI.Full 712 * @crossplatform 713 * @form 714 * @since 10 715 */ 716 /** 717 * Triggered when the time text changes. 718 * This event is not triggered when the screen is locked or the application is running in the background. 719 * When high-precision formats (such as SSS or SS) are used, the callback interval may vary. 720 * 721 * @param { function } event 722 * @returns { TextTimerAttribute } 723 * @syscap SystemCapability.ArkUI.ArkUI.Full 724 * @crossplatform 725 * @form 726 * @atomicservice 727 * @since arkts {'1.1':'11','1.2':'20'} 728 * @arkts 1.1&1.2 729 */ 730 onTimer(event: (utc: number, elapsedTime: number) => void): TextTimerAttribute; 731 732 /** 733 * Called when the text shadow is set. 734 * 735 * @param { ShadowOptions | Array<ShadowOptions> } value - The shadow options. 736 * @returns { TextTimerAttribute } 737 * @syscap SystemCapability.ArkUI.ArkUI.Full 738 * @crossplatform 739 * @since 11 740 */ 741 /** 742 * Sets the text shadow. 743 * It supports input parameters in an array to implement multiple text shadows. 744 * This API does not work with the fill attribute or coloring strategy. 745 * 746 * @param { ShadowOptions | Array<ShadowOptions> } value - The shadow options. 747 * @returns { TextTimerAttribute } 748 * @syscap SystemCapability.ArkUI.ArkUI.Full 749 * @crossplatform 750 * @atomicservice 751 * @since arkts {'1.1':'12','1.2':'20'} 752 * @arkts 1.1&1.2 753 */ 754 textShadow(value: ShadowOptions | Array<ShadowOptions>): TextTimerAttribute; 755 756 /** 757 * Creates a content modifier. 758 * 759 * @param { ContentModifier<TextTimerConfiguration> } modifier - The content modifier of texttimer. 760 * @returns { TextTimerAttribute } 761 * @syscap SystemCapability.ArkUI.ArkUI.Full 762 * @crossplatform 763 * @atomicservice 764 * @since arkts {'1.1':'12','1.2':'20'} 765 * @arkts 1.1&1.2 766 */ 767 contentModifier(modifier: ContentModifier<TextTimerConfiguration>): TextTimerAttribute; 768} 769 770/** 771 * Defines TextTimer Component. 772 * 773 * @syscap SystemCapability.ArkUI.ArkUI.Full 774 * @since 8 775 */ 776/** 777 * Defines TextTimer Component. 778 * 779 * @syscap SystemCapability.ArkUI.ArkUI.Full 780 * @crossplatform 781 * @form 782 * @since 10 783 */ 784/** 785 * Defines TextTimer Component. 786 * 787 * @syscap SystemCapability.ArkUI.ArkUI.Full 788 * @crossplatform 789 * @form 790 * @atomicservice 791 * @since 11 792 */ 793declare const TextTimer: TextTimerInterface; 794 795/** 796 * Defines TextTimer Component instance. 797 * 798 * @syscap SystemCapability.ArkUI.ArkUI.Full 799 * @since 8 800 */ 801/** 802 * Defines TextTimer Component instance. 803 * 804 * @syscap SystemCapability.ArkUI.ArkUI.Full 805 * @crossplatform 806 * @form 807 * @since 10 808 */ 809/** 810 * Defines TextTimer Component instance. 811 * 812 * @syscap SystemCapability.ArkUI.ArkUI.Full 813 * @crossplatform 814 * @form 815 * @atomicservice 816 * @since 11 817 */ 818declare const TextTimerInstance: TextTimerAttribute; 819