1 /* 2 * Copyright (c) 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 import type { Callback } from './@ohos.base'; 22 import type UIAbilityContext from './application/UIAbilityContext'; 23 import type { NavigationOperation, NavBar } from '../component/navigation'; 24 25 /** 26 * Register callbacks to observe ArkUI behavior. 27 * 28 * @namespace uiObserver 29 * @syscap SystemCapability.ArkUI.ArkUI.Full 30 * @crossplatform 31 * @since 11 32 */ 33 /** 34 * Register callbacks to observe ArkUI behavior. 35 * 36 * @namespace uiObserver 37 * @syscap SystemCapability.ArkUI.ArkUI.Full 38 * @crossplatform 39 * @atomicservice 40 * @since 12 41 */ 42 declare namespace uiObserver { 43 /** 44 * NavDestination state. 45 * 46 * @enum { number } 47 * @syscap SystemCapability.ArkUI.ArkUI.Full 48 * @crossplatform 49 * @since 11 50 * @form 51 */ 52 /** 53 * NavDestination state. 54 * 55 * @enum { number } 56 * @syscap SystemCapability.ArkUI.ArkUI.Full 57 * @crossplatform 58 * @atomicservice 59 * @since 12 60 * @form 61 */ 62 export enum NavDestinationState { 63 /** 64 * When the NavDestination is displayed. 65 * 66 * @syscap SystemCapability.ArkUI.ArkUI.Full 67 * @crossplatform 68 * @since 11 69 * @form 70 */ 71 /** 72 * When the NavDestination displayed. 73 * 74 * @syscap SystemCapability.ArkUI.ArkUI.Full 75 * @crossplatform 76 * @atomicservice 77 * @since 12 78 * @form 79 */ 80 ON_SHOWN = 0, 81 82 /** 83 * When the NavDestination is hidden. 84 * 85 * @syscap SystemCapability.ArkUI.ArkUI.Full 86 * @crossplatform 87 * @since 11 88 * @form 89 */ 90 /** 91 * When the NavDestination is hidden. 92 * 93 * @syscap SystemCapability.ArkUI.ArkUI.Full 94 * @crossplatform 95 * @atomicservice 96 * @since 12 97 * @form 98 */ 99 ON_HIDDEN = 1, 100 101 /** 102 * When the NavDestination appear. 103 * 104 * @syscap SystemCapability.ArkUI.ArkUI.Full 105 * @crossplatform 106 * @atomicservice 107 * @since 12 108 * @form 109 */ 110 ON_APPEAR = 2, 111 112 /** 113 * When the NavDestination disappear. 114 * 115 * @syscap SystemCapability.ArkUI.ArkUI.Full 116 * @crossplatform 117 * @atomicservice 118 * @since 12 119 * @form 120 */ 121 ON_DISAPPEAR = 3, 122 123 /** 124 * Before the NavDestination is displayed. 125 * 126 * @syscap SystemCapability.ArkUI.ArkUI.Full 127 * @crossplatform 128 * @form 129 * @atomicservice 130 * @since 12 131 */ 132 ON_WILL_SHOW = 4, 133 134 /** 135 * Before the NavDestination is hidden. 136 * 137 * @syscap SystemCapability.ArkUI.ArkUI.Full 138 * @crossplatform 139 * @form 140 * @atomicservice 141 * @since 12 142 */ 143 ON_WILL_HIDE = 5, 144 145 /** 146 * Before the NavDestination is appeared. 147 * 148 * @syscap SystemCapability.ArkUI.ArkUI.Full 149 * @crossplatform 150 * @form 151 * @atomicservice 152 * @since 12 153 */ 154 ON_WILL_APPEAR = 6, 155 156 /** 157 * Before the NavDestination is disappeared. 158 * 159 * @syscap SystemCapability.ArkUI.ArkUI.Full 160 * @crossplatform 161 * @form 162 * @atomicservice 163 * @since 12 164 */ 165 ON_WILL_DISAPPEAR = 7, 166 167 /** 168 * When back press event happened in NavDestination. 169 * 170 * @syscap SystemCapability.ArkUI.ArkUI.Full 171 * @crossplatform 172 * @atomicservice 173 * @since 12 174 * @form 175 */ 176 ON_BACKPRESS = 100 177 } 178 179 /** 180 * Router page state. 181 * 182 * @enum { number } 183 * @syscap SystemCapability.ArkUI.ArkUI.Full 184 * @crossplatform 185 * @since 11 186 */ 187 /** 188 * Router page state. 189 * 190 * @enum { number } 191 * @syscap SystemCapability.ArkUI.ArkUI.Full 192 * @crossplatform 193 * @atomicservice 194 * @since 12 195 */ 196 export enum RouterPageState { 197 /** 198 * When the router page create. 199 * 200 * @syscap SystemCapability.ArkUI.ArkUI.Full 201 * @crossplatform 202 * @since 11 203 */ 204 /** 205 * When the router page create. 206 * 207 * @syscap SystemCapability.ArkUI.ArkUI.Full 208 * @crossplatform 209 * @atomicservice 210 * @since 12 211 */ 212 ABOUT_TO_APPEAR = 0, 213 214 /** 215 * When the router page destroy. 216 * 217 * @syscap SystemCapability.ArkUI.ArkUI.Full 218 * @crossplatform 219 * @since 11 220 */ 221 /** 222 * When the router page destroy. 223 * 224 * @syscap SystemCapability.ArkUI.ArkUI.Full 225 * @crossplatform 226 * @atomicservice 227 * @since 12 228 */ 229 ABOUT_TO_DISAPPEAR = 1, 230 231 /** 232 * When the router page show. 233 * 234 * @syscap SystemCapability.ArkUI.ArkUI.Full 235 * @crossplatform 236 * @since 11 237 */ 238 /** 239 * When the router page show. 240 * 241 * @syscap SystemCapability.ArkUI.ArkUI.Full 242 * @crossplatform 243 * @atomicservice 244 * @since 12 245 */ 246 ON_PAGE_SHOW = 2, 247 248 /** 249 * When the router page hide. 250 * 251 * @syscap SystemCapability.ArkUI.ArkUI.Full 252 * @crossplatform 253 * @since 11 254 */ 255 /** 256 * When the router page hide. 257 * 258 * @syscap SystemCapability.ArkUI.ArkUI.Full 259 * @crossplatform 260 * @atomicservice 261 * @since 12 262 */ 263 ON_PAGE_HIDE = 3, 264 265 /** 266 * When back press event happened in the router page. 267 * 268 * @syscap SystemCapability.ArkUI.ArkUI.Full 269 * @crossplatform 270 * @since 11 271 */ 272 /** 273 * When back press event happened in the router page. 274 * 275 * @syscap SystemCapability.ArkUI.ArkUI.Full 276 * @crossplatform 277 * @atomicservice 278 * @since 12 279 */ 280 ON_BACK_PRESS = 4 281 } 282 283 /** 284 * ScrollEvent type. 285 * 286 * @enum { number } 287 * @syscap SystemCapability.ArkUI.ArkUI.Full 288 * @crossplatform 289 * @atomicservice 290 * @since 12 291 */ 292 export enum ScrollEventType { 293 /** 294 * When the ScrollEvent start. 295 * 296 * @syscap SystemCapability.ArkUI.ArkUI.Full 297 * @crossplatform 298 * @atomicservice 299 * @since 12 300 */ 301 SCROLL_START = 0, 302 303 /** 304 * When the ScrollEvent stop. 305 * 306 * @syscap SystemCapability.ArkUI.ArkUI.Full 307 * @crossplatform 308 * @atomicservice 309 * @since 12 310 */ 311 SCROLL_STOP = 1 312 } 313 314 /** 315 * NavDestination info. 316 * 317 * @interface NavDestinationInfo 318 * @syscap SystemCapability.ArkUI.ArkUI.Full 319 * @crossplatform 320 * @since 11 321 */ 322 /** 323 * NavDestination info. 324 * 325 * @interface NavDestinationInfo 326 * @syscap SystemCapability.ArkUI.ArkUI.Full 327 * @crossplatform 328 * @atomicservice 329 * @since 12 330 */ 331 export interface NavDestinationInfo { 332 /** 333 * Navigation id. 334 * 335 * @type { ResourceStr } 336 * @syscap SystemCapability.ArkUI.ArkUI.Full 337 * @crossplatform 338 * @since 11 339 */ 340 /** 341 * Navigation id. 342 * 343 * @type { ResourceStr } 344 * @syscap SystemCapability.ArkUI.ArkUI.Full 345 * @crossplatform 346 * @atomicservice 347 * @since 12 348 */ 349 navigationId: ResourceStr, 350 351 /** 352 * Changed NavDestination name. 353 * 354 * @type { ResourceStr } 355 * @syscap SystemCapability.ArkUI.ArkUI.Full 356 * @crossplatform 357 * @since 11 358 */ 359 /** 360 * Changed NavDestination name. 361 * 362 * @type { ResourceStr } 363 * @syscap SystemCapability.ArkUI.ArkUI.Full 364 * @crossplatform 365 * @atomicservice 366 * @since 12 367 */ 368 name: ResourceStr, 369 370 /** 371 * Changed NavDestination state. 372 * 373 * @type { NavDestinationState } 374 * @syscap SystemCapability.ArkUI.ArkUI.Full 375 * @crossplatform 376 * @since 11 377 */ 378 /** 379 * Changed NavDestination state. 380 * 381 * @type { NavDestinationState } 382 * @syscap SystemCapability.ArkUI.ArkUI.Full 383 * @crossplatform 384 * @atomicservice 385 * @since 12 386 */ 387 state: NavDestinationState, 388 389 /** 390 * NavDestination index. 391 * 392 * @type { number } 393 * @syscap SystemCapability.ArkUI.ArkUI.Full 394 * @crossplatform 395 * @atomicservice 396 * @since 12 397 */ 398 index: number; 399 400 /** 401 * The detailed parameter of NavDestination. 402 * 403 * @type { ?Object } 404 * @syscap SystemCapability.ArkUI.ArkUI.Full 405 * @crossplatform 406 * @atomicservice 407 * @since 12 408 */ 409 param?: Object; 410 411 /** 412 * Auto-generated navDestination id, which is different from common property id of Component. 413 * 414 * @type { string } 415 * @syscap SystemCapability.ArkUI.ArkUI.Full 416 * @crossplatform 417 * @atomicservice 418 * @since 12 419 */ 420 navDestinationId: string; 421 } 422 423 /** 424 * Navigation info. 425 * 426 * @interface NavigationInfo 427 * @syscap SystemCapability.ArkUI.ArkUI.Full 428 * @crossplatform 429 * @atomicservice 430 * @since 12 431 */ 432 export interface NavigationInfo { 433 /** 434 * Navigation id. 435 * 436 * @type { string } 437 * @syscap SystemCapability.ArkUI.ArkUI.Full 438 * @crossplatform 439 * @atomicservice 440 * @since 12 441 */ 442 navigationId: string; 443 444 /** 445 * Navigation path stack. 446 * 447 * @type { NavPathStack } 448 * @syscap SystemCapability.ArkUI.ArkUI.Full 449 * @crossplatform 450 * @atomicservice 451 * @since 12 452 */ 453 pathStack: NavPathStack; 454 } 455 456 /** 457 * ScrollEvent info. 458 * 459 * @interface ScrollEventInfo 460 * @syscap SystemCapability.ArkUI.ArkUI.Full 461 * @crossplatform 462 * @atomicservice 463 * @since 12 464 */ 465 export interface ScrollEventInfo { 466 /** 467 * Scroll id. 468 * 469 * @type { string } 470 * @syscap SystemCapability.ArkUI.ArkUI.Full 471 * @crossplatform 472 * @atomicservice 473 * @since 12 474 */ 475 id: string, 476 477 /** 478 * The uniqueId of the scrollable component. 479 * 480 * @type { number } 481 * @syscap SystemCapability.ArkUI.ArkUI.Full 482 * @crossplatform 483 * @atomicservice 484 * @since 12 485 */ 486 uniqueId: number, 487 488 /** 489 * Changed ScrollEvent type. 490 * 491 * @type { ScrollEventType } 492 * @syscap SystemCapability.ArkUI.ArkUI.Full 493 * @crossplatform 494 * @atomicservice 495 * @since 12 496 */ 497 scrollEvent: ScrollEventType, 498 499 /** 500 * Changed ScrollEvent offset. 501 * 502 * @type { number } 503 * @syscap SystemCapability.ArkUI.ArkUI.Full 504 * @crossplatform 505 * @atomicservice 506 * @since 12 507 */ 508 offset: number 509 } 510 511 /** 512 * observer options. 513 * 514 * @interface ObserverOptions 515 * @syscap SystemCapability.ArkUI.ArkUI.Full 516 * @crossplatform 517 * @atomicservice 518 * @since 12 519 */ 520 export interface ObserverOptions { 521 /** 522 * component id. 523 * 524 * @type { string } 525 * @syscap SystemCapability.ArkUI.ArkUI.Full 526 * @crossplatform 527 * @atomicservice 528 * @since 12 529 */ 530 id: string 531 } 532 533 /** 534 * Router page info. 535 * 536 * @syscap SystemCapability.ArkUI.ArkUI.Full 537 * @crossplatform 538 * @since 11 539 */ 540 /** 541 * Router page info. 542 * 543 * @syscap SystemCapability.ArkUI.ArkUI.Full 544 * @crossplatform 545 * @atomicservice 546 * @since 12 547 */ 548 export class RouterPageInfo { 549 /** 550 * The context of the changed router page. 551 * 552 * @type { UIAbilityContext | UIContext } 553 * @syscap SystemCapability.ArkUI.ArkUI.Full 554 * @crossplatform 555 * @since 11 556 */ 557 /** 558 * The context of the changed router page. 559 * 560 * @type { UIAbilityContext | UIContext } 561 * @syscap SystemCapability.ArkUI.ArkUI.Full 562 * @crossplatform 563 * @atomicservice 564 * @since 12 565 */ 566 context: UIAbilityContext | UIContext; 567 568 /** 569 * The index of the changed router page in router stack. 570 * 571 * @type { number } 572 * @syscap SystemCapability.ArkUI.ArkUI.Full 573 * @crossplatform 574 * @since 11 575 */ 576 /** 577 * The index of the changed router page in router stack. 578 * 579 * @type { number } 580 * @syscap SystemCapability.ArkUI.ArkUI.Full 581 * @crossplatform 582 * @atomicservice 583 * @since 12 584 */ 585 index: number; 586 587 /** 588 * The name of the changed router page. 589 * 590 * @type { string } 591 * @syscap SystemCapability.ArkUI.ArkUI.Full 592 * @crossplatform 593 * @since 11 594 */ 595 /** 596 * The name of the changed router page. 597 * 598 * @type { string } 599 * @syscap SystemCapability.ArkUI.ArkUI.Full 600 * @crossplatform 601 * @atomicservice 602 * @since 12 603 */ 604 name: string; 605 606 /** 607 * The path of the changed router page. 608 * 609 * @type { string } 610 * @syscap SystemCapability.ArkUI.ArkUI.Full 611 * @crossplatform 612 * @since 11 613 */ 614 /** 615 * The path of the changed router page. 616 * 617 * @type { string } 618 * @syscap SystemCapability.ArkUI.ArkUI.Full 619 * @crossplatform 620 * @atomicservice 621 * @since 12 622 */ 623 path: string; 624 625 /** 626 * The state of the changed router page. 627 * 628 * @type { RouterPageState } 629 * @syscap SystemCapability.ArkUI.ArkUI.Full 630 * @crossplatform 631 * @since 11 632 */ 633 /** 634 * The state of the changed router page. 635 * 636 * @type { RouterPageState } 637 * @syscap SystemCapability.ArkUI.ArkUI.Full 638 * @crossplatform 639 * @atomicservice 640 * @since 12 641 */ 642 state: RouterPageState; 643 644 /** 645 * The unique identifier of the router page. 646 * 647 * @type { string } 648 * @syscap SystemCapability.ArkUI.ArkUI.Full 649 * @crossplatform 650 * @atomicservice 651 * @since 12 652 */ 653 pageId: string; 654 } 655 656 /** 657 * Density info. 658 * 659 * @syscap SystemCapability.ArkUI.ArkUI.Full 660 * @crossplatform 661 * @atomicservice 662 * @since 12 663 */ 664 export class DensityInfo { 665 /** 666 * The context of the changed screen density. 667 * 668 * @type { UIContext } 669 * @syscap SystemCapability.ArkUI.ArkUI.Full 670 * @crossplatform 671 * @atomicservice 672 * @since 12 673 */ 674 context: UIContext; 675 676 /** 677 * The changed screen density. 678 * 679 * @type { number } 680 * @syscap SystemCapability.ArkUI.ArkUI.Full 681 * @crossplatform 682 * @atomicservice 683 * @since 12 684 */ 685 density: number; 686 } 687 688 /** 689 * NavDestination switch info 690 * 691 * @interface NavDestinationSwitchInfo 692 * @syscap SystemCapability.ArkUI.ArkUI.Full 693 * @crossplatform 694 * @atomicservice 695 * @since 12 696 */ 697 export interface NavDestinationSwitchInfo { 698 /** 699 * The context of the navigation operation. 700 * 701 * @type { UIAbilityContext | UIContext } 702 * @syscap SystemCapability.ArkUI.ArkUI.Full 703 * @crossplatform 704 * @atomicservice 705 * @since 12 706 */ 707 context: UIAbilityContext | UIContext; 708 709 /** 710 * From navigation content info. 711 * 712 * @type { NavDestinationInfo | NavBar } 713 * @syscap SystemCapability.ArkUI.ArkUI.Full 714 * @crossplatform 715 * @atomicservice 716 * @since 12 717 */ 718 from: NavDestinationInfo | NavBar; 719 720 /** 721 * To navigation content info. 722 * 723 * @type { NavDestinationInfo | NavBar } 724 * @syscap SystemCapability.ArkUI.ArkUI.Full 725 * @crossplatform 726 * @atomicservice 727 * @since 12 728 */ 729 to: NavDestinationInfo | NavBar; 730 731 /** 732 * The operation type. 733 * 734 * @type { NavigationOperation } 735 * @syscap SystemCapability.ArkUI.ArkUI.Full 736 * @crossplatform 737 * @atomicservice 738 * @since 12 739 */ 740 operation: NavigationOperation; 741 } 742 743 /** 744 * Indicates the options of NavDestination switch. 745 * 746 * @interface NavDestinationSwitchObserverOptions 747 * @syscap SystemCapability.ArkUI.ArkUI.Full 748 * @crossplatform 749 * @atomicservice 750 * @since 12 751 */ 752 export interface NavDestinationSwitchObserverOptions { 753 /** 754 * The navigationId that need observation 755 * 756 * @type { ResourceStr } 757 * @syscap SystemCapability.ArkUI.ArkUI.Full 758 * @crossplatform 759 * @atomicservice 760 * @since 12 761 */ 762 navigationId: ResourceStr; 763 } 764 765 /** 766 * Registers a callback function to be called when the navigation destination is updated. 767 * 768 * @param { 'navDestinationUpdate' } type - The type of event to listen for. Must be 'navDestinationUpdate'. 769 * @param { object } options - The options object. 770 * @param { Callback<NavDestinationInfo> } callback - The callback function to be called when the navigation destination is updated. 771 * @syscap SystemCapability.ArkUI.ArkUI.Full 772 * @crossplatform 773 * @since 11 774 */ 775 /** 776 * Registers a callback function to be called when the navigation destination is updated. 777 * 778 * @param { 'navDestinationUpdate' } type - The type of event to listen for. Must be 'navDestinationUpdate'. 779 * @param { object } options - The options object. 780 * @param { Callback<NavDestinationInfo> } callback - The callback function to be called when the navigation destination is updated. 781 * @syscap SystemCapability.ArkUI.ArkUI.Full 782 * @crossplatform 783 * @atomicservice 784 * @since 12 785 */ 786 export function on(type: 'navDestinationUpdate', options: { navigationId: ResourceStr }, callback: Callback<NavDestinationInfo>): void; 787 788 /** 789 * Removes a callback function that was previously registered with `on()`. 790 * 791 * @param { 'navDestinationUpdate' } type - The type of event to remove the listener for. Must be 'navDestinationUpdate'. 792 * @param { object } options - The options object. 793 * @param { Callback<NavDestinationInfo> } callback - The callback function to remove. If not provided, all callbacks for the given event type and 794 * navigation ID will be removed. 795 * @syscap SystemCapability.ArkUI.ArkUI.Full 796 * @crossplatform 797 * @since 11 798 */ 799 /** 800 * Removes a callback function that was previously registered with `on()`. 801 * 802 * @param { 'navDestinationUpdate' } type - The type of event to remove the listener for. Must be 'navDestinationUpdate'. 803 * @param { object } options - The options object. 804 * @param { Callback<NavDestinationInfo> } callback - The callback function to remove. If not provided, all callbacks for the given event type and 805 * navigation ID will be removed. 806 * @syscap SystemCapability.ArkUI.ArkUI.Full 807 * @crossplatform 808 * @atomicservice 809 * @since 12 810 */ 811 export function off(type: 'navDestinationUpdate', options: { navigationId: ResourceStr }, callback?: Callback<NavDestinationInfo>): void; 812 813 /** 814 * Registers a callback function to be called when the navigation destination is updated. 815 * 816 * @param { 'navDestinationUpdate' } type - The type of event to listen for. Must be 'navDestinationUpdate'. 817 * @param { Callback<NavDestinationInfo> } callback - The callback function to be called when the navigation destination is updated. 818 * @syscap SystemCapability.ArkUI.ArkUI.Full 819 * @crossplatform 820 * @since 11 821 */ 822 /** 823 * Registers a callback function to be called when the navigation destination is updated. 824 * 825 * @param { 'navDestinationUpdate' } type - The type of event to listen for. Must be 'navDestinationUpdate'. 826 * @param { Callback<NavDestinationInfo> } callback - The callback function to be called when the navigation destination is updated. 827 * @syscap SystemCapability.ArkUI.ArkUI.Full 828 * @crossplatform 829 * @atomicservice 830 * @since 12 831 */ 832 export function on(type: 'navDestinationUpdate', callback: Callback<NavDestinationInfo>): void; 833 834 /** 835 * Removes a callback function that was previously registered with `on()`. 836 * 837 * @param { 'navDestinationUpdate'} type - The type of event to remove the listener for. Must be 'navDestinationUpdate'. 838 * @param { Callback<NavDestinationInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type 839 * will be removed. 840 * @syscap SystemCapability.ArkUI.ArkUI.Full 841 * @crossplatform 842 * @since 11 843 */ 844 /** 845 * Removes a callback function that was previously registered with `on()`. 846 * 847 * @param { 'navDestinationUpdate'} type - The type of event to remove the listener for. Must be 'navDestinationUpdate'. 848 * @param { Callback<NavDestinationInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type 849 * will be removed. 850 * @syscap SystemCapability.ArkUI.ArkUI.Full 851 * @crossplatform 852 * @atomicservice 853 * @since 12 854 */ 855 export function off(type: 'navDestinationUpdate', callback?: Callback<NavDestinationInfo>): void; 856 857 /** 858 * Registers a callback function to be called when the scroll event start or stop. 859 * 860 * @param { 'scrollEvent' } type - The type of event to listen for. Must be 'scrollEvent'. 861 * @param { ObserverOptions } options - The options object. 862 * @param { Callback<ScrollEventInfo> } callback - The callback function to be called when the scroll event start or stop. 863 * @syscap SystemCapability.ArkUI.ArkUI.Full 864 * @crossplatform 865 * @atomicservice 866 * @since 12 867 */ 868 export function on(type: 'scrollEvent', options: ObserverOptions, callback: Callback<ScrollEventInfo>): void; 869 870 /** 871 * Removes a callback function that was previously registered with `on()`. 872 * 873 * @param { 'scrollEvent' } type - The type of event to remove the listener for. Must be 'scrollEvent'. 874 * @param { ObserverOptions } options - The options object. 875 * @param { Callback<ScrollEventInfo> } callback - The callback function to remove. If not provided, all callbacks for the given event type and 876 * scroll ID will be removed. 877 * @syscap SystemCapability.ArkUI.ArkUI.Full 878 * @crossplatform 879 * @atomicservice 880 * @since 12 881 */ 882 export function off(type: 'scrollEvent', options: ObserverOptions, callback?: Callback<ScrollEventInfo>): void; 883 884 /** 885 * Registers a callback function to be called when the scroll event start or stop. 886 * 887 * @param { 'scrollEvent' } type - The type of event to listen for. Must be 'scrollEvent'. 888 * @param { Callback<ScrollEventInfo> } callback - The callback function to be called when the scroll event start or stop. 889 * @syscap SystemCapability.ArkUI.ArkUI.Full 890 * @crossplatform 891 * @atomicservice 892 * @since 12 893 */ 894 export function on(type: 'scrollEvent', callback: Callback<ScrollEventInfo>): void; 895 896 /** 897 * Removes a callback function that was previously registered with `on()`. 898 * 899 * @param { 'scrollEvent'} type - The type of event to remove the listener for. Must be 'scrollEvent'. 900 * @param { Callback<ScrollEventInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type 901 * will be removed. 902 * @syscap SystemCapability.ArkUI.ArkUI.Full 903 * @crossplatform 904 * @atomicservice 905 * @since 12 906 */ 907 export function off(type: 'scrollEvent', callback?: Callback<ScrollEventInfo>): void; 908 909 /** 910 * Registers a callback function to be called when the router page is updated. 911 * 912 * @param { 'routerPageUpdate' } type - The type of event to listen for. Must be 'routerPageUpdate'. 913 * @param { UIAbilityContext | UIContext } context - The context scope of the observer. 914 * @param { Callback<RouterPageInfo> } callback - The callback function to be called when the router page is updated. 915 * @syscap SystemCapability.ArkUI.ArkUI.Full 916 * @crossplatform 917 * @since 11 918 */ 919 /** 920 * Registers a callback function to be called when the router page is updated. 921 * 922 * @param { 'routerPageUpdate' } type - The type of event to listen for. Must be 'routerPageUpdate'. 923 * @param { UIAbilityContext | UIContext } context - The context scope of the observer. 924 * @param { Callback<RouterPageInfo> } callback - The callback function to be called when the router page is updated. 925 * @syscap SystemCapability.ArkUI.ArkUI.Full 926 * @crossplatform 927 * @atomicservice 928 * @since 12 929 */ 930 export function on(type: 'routerPageUpdate', context: UIAbilityContext | UIContext, callback: Callback<RouterPageInfo>): void; 931 932 /** 933 * Removes a callback function that was previously registered with `on()`. 934 * 935 * @param { 'routerPageUpdate' } type - The type of event to remove the listener for. Must be 'routerPageUpdate'. 936 * @param { UIAbilityContext | UIContext } context - The context scope of the observer. 937 * @param { Callback<RouterPageInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type 938 * will be removed. 939 * @syscap SystemCapability.ArkUI.ArkUI.Full 940 * @crossplatform 941 * @since 11 942 */ 943 /** 944 * Removes a callback function that was previously registered with `on()`. 945 * 946 * @param { 'routerPageUpdate' } type - The type of event to remove the listener for. Must be 'routerPageUpdate'. 947 * @param { UIAbilityContext | UIContext } context - The context scope of the observer. 948 * @param { Callback<RouterPageInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type 949 * will be removed. 950 * @syscap SystemCapability.ArkUI.ArkUI.Full 951 * @crossplatform 952 * @atomicservice 953 * @since 12 954 */ 955 export function off(type: 'routerPageUpdate', context: UIAbilityContext | UIContext, callback?: Callback<RouterPageInfo>): void; 956 957 /** 958 * Registers a callback function to be called when the screen density is updated. 959 * 960 * @param { 'densityUpdate' } type - The type of event to listen for. Must be 'densityUpdate'. 961 * @param { UIContext } context - The context scope of the observer. 962 * @param { Callback<DensityInfo> } callback - The callback function to be called when the screen density is updated. 963 * @syscap SystemCapability.ArkUI.ArkUI.Full 964 * @crossplatform 965 * @atomicservice 966 * @since 12 967 */ 968 export function on(type: 'densityUpdate', context: UIContext, callback: Callback<DensityInfo>): void; 969 970 /** 971 * Removes a callback function that was previously registered with `on()`. 972 * 973 * @param { 'densityUpdate' } type - The type of event to remove the listener for. Must be 'densityUpdate'. 974 * @param { UIContext } context - The context scope of the observer. 975 * @param { Callback<DensityInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type 976 * will be removed. 977 * @syscap SystemCapability.ArkUI.ArkUI.Full 978 * @crossplatform 979 * @atomicservice 980 * @since 12 981 */ 982 export function off(type: 'densityUpdate', context: UIContext, callback?: Callback<DensityInfo>): void; 983 984 /** 985 * Registers a callback function to be called when the draw command will be drawn. 986 * 987 * @param { 'willDraw' } type - The type of event to listen for. Must be 'willDraw'. 988 * @param { UIContext } context - The context scope of the observer. 989 * @param { Callback<void> } callback - The callback function to be called when the draw command will be drawn. 990 * @syscap SystemCapability.ArkUI.ArkUI.Full 991 * @crossplatform 992 * @atomicservice 993 * @since 12 994 */ 995 export function on(type: 'willDraw', context: UIContext, callback: Callback<void>): void; 996 997 /** 998 * Removes a callback function that was previously registered with `on()`. 999 * 1000 * @param { 'willDraw' } type - The type of event to remove the listener for. Must be 'willDraw'. 1001 * @param { UIContext } context - The context scope of the observer. 1002 * @param { Callback<void> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type 1003 * will be removed. 1004 * @syscap SystemCapability.ArkUI.ArkUI.Full 1005 * @crossplatform 1006 * @atomicservice 1007 * @since 12 1008 */ 1009 export function off(type: 'willDraw', context: UIContext, callback?: Callback<void>): void; 1010 1011 /** 1012 * Registers a callback function to be called when the layout is done. 1013 * 1014 * @param { 'didLayout' } type - The type of event to listen for. Must be 'didLayout'. 1015 * @param { UIContext } context - The context scope of the observer. 1016 * @param { Callback<void> } callback - The callback function to be called when the layout is done. 1017 * @syscap SystemCapability.ArkUI.ArkUI.Full 1018 * @crossplatform 1019 * @atomicservice 1020 * @since 12 1021 */ 1022 export function on(type: 'didLayout', context: UIContext, callback: Callback<void>): void; 1023 1024 /** 1025 * Removes a callback function that was previously registered with `on()`. 1026 * 1027 * @param { 'didLayout' } type - The type of event to remove the listener for. Must be 'didLayout'. 1028 * @param { UIContext } context - The context scope of the observer. 1029 * @param { Callback<void> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type 1030 * will be removed. 1031 * @syscap SystemCapability.ArkUI.ArkUI.Full 1032 * @crossplatform 1033 * @atomicservice 1034 * @since 12 1035 */ 1036 export function off(type: 'didLayout', context: UIContext, callback?: Callback<void>): void; 1037 1038 /** 1039 * Registers a callback function to be called when the navigation switched to a new navDestination. 1040 * 1041 * @param { 'navDestinationSwitch' } type - The type of event to listen for. Must be 'navDestinationSwitch'. 1042 * @param { UIAbilityContext | UIContext } context - The context scope of the observer. 1043 * @param { Callback<NavDestinationSwitchInfo> } callback - The callback function to be called when the navigation switched to a new navDestination. 1044 * @syscap SystemCapability.ArkUI.ArkUI.Full 1045 * @crossplatform 1046 * @atomicservice 1047 * @since 12 1048 */ 1049 export function on( 1050 type: 'navDestinationSwitch', 1051 context: UIAbilityContext | UIContext, 1052 callback: Callback<NavDestinationSwitchInfo> 1053 ): void; 1054 1055 /** 1056 * Removes a callback function that was previously registered with `on()`. 1057 * 1058 * @param { 'navDestinationSwitch' } type - The type of event to remove the listener for. Must be 'navDestinationSwitch'. 1059 * @param { UIAbilityContext | UIContext } context - The context scope of the observer. 1060 * @param { Callback<NavDestinationSwitchInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type 1061 * will be removed. 1062 * @syscap SystemCapability.ArkUI.ArkUI.Full 1063 * @crossplatform 1064 * @atomicservice 1065 * @since 12 1066 */ 1067 export function off( 1068 type: 'navDestinationSwitch', 1069 context: UIAbilityContext | UIContext, 1070 callback?: Callback<NavDestinationSwitchInfo> 1071 ): void; 1072 1073 /** 1074 * Registers a callback function to be called when the navigation switched to a new navDestination. 1075 * 1076 * @param { 'navDestinationSwitch' } type - The type of event to listen for. Must be 'navDestinationSwitch'. 1077 * @param { UIAbilityContext | UIContext } context - The context scope of the observer. 1078 * @param { NavDestinationSwitchObserverOptions } observerOptions - Options. 1079 * @param { Callback<NavDestinationSwitchInfo> } callback - The callback function to be called when the navigation switched to a new navDestination. 1080 * @syscap SystemCapability.ArkUI.ArkUI.Full 1081 * @crossplatform 1082 * @atomicservice 1083 * @since 12 1084 */ 1085 export function on( 1086 type: 'navDestinationSwitch', 1087 context: UIAbilityContext | UIContext, 1088 observerOptions: NavDestinationSwitchObserverOptions, 1089 callback: Callback<NavDestinationSwitchInfo> 1090 ): void; 1091 1092 /** 1093 * Removes a callback function that was previously registered with `on()`. 1094 * 1095 * @param { 'navDestinationSwitch' } type - The type of event to remove the listener for. Must be 'navDestinationSwitch'. 1096 * @param { UIAbilityContext | UIContext } context - The context scope of the observer. 1097 * @param { NavDestinationSwitchObserverOptions } observerOptions - Options. 1098 * @param { Callback<NavDestinationSwitchInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type 1099 * will be removed. 1100 * @syscap SystemCapability.ArkUI.ArkUI.Full 1101 * @crossplatform 1102 * @atomicservice 1103 * @since 12 1104 */ 1105 export function off( 1106 type: 'navDestinationSwitch', 1107 context: UIAbilityContext | UIContext, 1108 observerOptions: NavDestinationSwitchObserverOptions, 1109 callback?: Callback<NavDestinationSwitchInfo> 1110 ): void; 1111 } 1112 1113 export default uiObserver; 1114