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/// <reference path='./import.ts' /> 17 18import { ArkScrollable } from "./ArkScrollable"; 19 20class ListEditModeModifier extends ModifierWithKey<boolean> { 21 constructor(value: boolean) { 22 super(value); 23 } 24 static identity: Symbol = Symbol('editMode'); 25 applyPeer(node: KNode, reset: boolean): void { 26 if (reset) { 27 getUINativeModule().list.resetEditMode(node); 28 } else { 29 getUINativeModule().list.setEditMode(node, this.value!); 30 } 31 } 32} 33 34class ListMultiSelectableModifier extends ModifierWithKey<boolean> { 35 constructor(value: boolean) { 36 super(value); 37 } 38 static identity: Symbol = Symbol('listMultiSelectable'); 39 applyPeer(node: KNode, reset: boolean): void { 40 if (reset) { 41 getUINativeModule().list.resetMultiSelectable(node); 42 } else { 43 getUINativeModule().list.setMultiSelectable(node, this.value!); 44 } 45 } 46} 47 48class ListAlignListItemModifier extends ModifierWithKey<ListItemAlign> { 49 constructor(value: ListItemAlign) { 50 super(value); 51 } 52 static identity: Symbol = Symbol('listAlignListItem'); 53 applyPeer(node: KNode, reset: boolean): void { 54 if (reset) { 55 getUINativeModule().list.resetAlignListItem(node); 56 } else { 57 getUINativeModule().list.setAlignListItem(node, this.value!); 58 } 59 } 60} 61 62class ListScrollSnapAlignModifier extends ModifierWithKey<ScrollSnapAlign> { 63 constructor(value: ScrollSnapAlign) { 64 super(value); 65 } 66 static identity: Symbol = Symbol('listScrollSnapAlign'); 67 applyPeer(node: KNode, reset: boolean): void { 68 if (reset) { 69 getUINativeModule().list.resetScrollSnapAlign(node); 70 } else { 71 getUINativeModule().list.setScrollSnapAlign(node, this.value!); 72 } 73 } 74} 75 76class ContentStartOffsetModifier extends ModifierWithKey<number> { 77 constructor(value: number) { 78 super(value); 79 } 80 static identity: Symbol = Symbol('contentStartOffset'); 81 applyPeer(node: KNode, reset: boolean): void { 82 if (reset) { 83 getUINativeModule().list.resetContentStartOffset(node); 84 } else { 85 getUINativeModule().list.setContentStartOffset(node, this.value); 86 } 87 } 88} 89 90class ContentEndOffsetModifier extends ModifierWithKey<number> { 91 constructor(value: number) { 92 super(value); 93 } 94 static identity: Symbol = Symbol('contentEndOffset'); 95 applyPeer(node: KNode, reset: boolean): void { 96 if (reset) { 97 getUINativeModule().list.resetContentEndOffset(node); 98 } else { 99 getUINativeModule().list.setContentEndOffset(node, this.value); 100 } 101 } 102} 103 104class ListDividerModifier extends ModifierWithKey<DividerStyle> { 105 constructor(value: DividerStyle) { 106 super(value); 107 } 108 static identity: Symbol = Symbol('listDivider'); 109 applyPeer(node: KNode, reset: boolean): void { 110 if (reset) { 111 getUINativeModule().list.resetDivider(node); 112 } else { 113 getUINativeModule().list.setDivider(node, this.value?.strokeWidth!, this.value?.color, this.value?.startMargin, this.value?.endMargin); 114 } 115 } 116 117 checkObjectDiff(): boolean { 118 return !(this.stageValue?.strokeWidth === this.value?.strokeWidth && 119 this.stageValue?.color === this.value?.color && 120 this.stageValue?.startMargin === this.value?.startMargin && 121 this.stageValue?.endMargin === this.value?.endMargin); 122 } 123} 124 125class ChainAnimationOptionsModifier extends ModifierWithKey<ChainAnimationOptions> { 126 constructor(value: ChainAnimationOptions) { 127 super(value); 128 } 129 static identity: Symbol = Symbol('chainAnimationOptions'); 130 applyPeer(node: KNode, reset: boolean): void { 131 if (reset) { 132 getUINativeModule().list.resetChainAnimationOptions(node); 133 } else { 134 getUINativeModule().list.setChainAnimationOptions(node, this.value?.minSpace!, 135 this.value?.maxSpace!, this.value?.conductivity, this.value?.intensity, 136 this.value?.edgeEffect, this.value?.stiffness, this.value?.damping); 137 } 138 } 139 140 checkObjectDiff(): boolean { 141 return !(this.stageValue.minSpace === this.value.minSpace && this.stageValue.maxSpace === this.value.maxSpace && 142 this.stageValue.conductivity === this.value.conductivity && this.stageValue.intensity === this.value.intensity && 143 this.stageValue.edgeEffect === this.value.edgeEffect && this.stageValue.stiffness === this.value.stiffness && 144 this.stageValue.damping === this.value.damping); 145 } 146} 147 148class ListChainAnimationModifier extends ModifierWithKey<boolean> { 149 constructor(value: boolean) { 150 super(value); 151 } 152 static identity: Symbol = Symbol('listChainAnimation'); 153 applyPeer(node: KNode, reset: boolean): void { 154 if (reset) { 155 getUINativeModule().list.resetChainAnimation(node); 156 } else { 157 getUINativeModule().list.setChainAnimation(node, this.value!); 158 } 159 } 160} 161 162class ListCachedCountModifier extends ModifierWithKey<number> { 163 constructor(value: number) { 164 super(value); 165 } 166 static identity: Symbol = Symbol('listCachedCount'); 167 applyPeer(node: KNode, reset: boolean): void { 168 if (reset) { 169 getUINativeModule().list.resetCachedCount(node); 170 } else { 171 getUINativeModule().list.setCachedCount(node, this.value!); 172 } 173 } 174} 175 176class ListEnableScrollInteractionModifier extends ModifierWithKey<boolean> { 177 constructor(value: boolean) { 178 super(value); 179 } 180 static identity: Symbol = Symbol('listEnableScrollInteraction'); 181 applyPeer(node: KNode, reset: boolean): void { 182 if (reset) { 183 getUINativeModule().list.resetEnableScrollInteraction(node); 184 } else { 185 getUINativeModule().list.setEnableScrollInteraction(node, this.value!); 186 } 187 } 188} 189 190class ListStickyModifier extends ModifierWithKey<number> { 191 constructor(value: number) { 192 super(value); 193 } 194 static identity: Symbol = Symbol('listSticky'); 195 applyPeer(node: KNode, reset: boolean): void { 196 if (reset) { 197 getUINativeModule().list.resetSticky(node); 198 } else { 199 getUINativeModule().list.setSticky(node, this.value!); 200 } 201 } 202} 203 204class ListListDirectionModifier extends ModifierWithKey<number> { 205 constructor(value: number) { 206 super(value); 207 } 208 static identity: Symbol = Symbol('listListDirection'); 209 applyPeer(node: KNode, reset: boolean): void { 210 if (reset) { 211 getUINativeModule().list.resetListDirection(node); 212 } else { 213 getUINativeModule().list.setListDirection(node, this.value!); 214 } 215 } 216} 217 218class ListFrictionModifier extends ModifierWithKey<number | Resource> { 219 constructor(value: number | Resource) { 220 super(value); 221 } 222 static identity: Symbol = Symbol('listFriction'); 223 applyPeer(node: KNode, reset: boolean): void { 224 if (reset) { 225 getUINativeModule().list.resetListFriction(node); 226 } else { 227 if (!isNumber(this.value) && !isResource(this.value)) { 228 getUINativeModule().list.resetListFriction(node); 229 } else { 230 getUINativeModule().list.setListFriction(node, this.value); 231 } 232 } 233 } 234 235 checkObjectDiff(): boolean { 236 return !isBaseOrResourceEqual(this.stageValue, this.value); 237 } 238} 239 240class ListMaintainVisibleContentPositionModifier extends ModifierWithKey<boolean | undefined> { 241 constructor(value: boolean | undefined) { 242 super(value); 243 } 244 static identity: Symbol = Symbol('listMaintainVisibleContentPosition'); 245 applyPeer(node: KNode, reset: boolean): void { 246 if (reset) { 247 getUINativeModule().list.resetListMaintainVisibleContentPosition(node); 248 } else { 249 getUINativeModule().list.setListMaintainVisibleContentPosition(node, this.value); 250 } 251 } 252} 253 254class ListNestedScrollModifier extends ModifierWithKey<NestedScrollOptions> { 255 constructor(value: NestedScrollOptions) { 256 super(value); 257 } 258 static identity: Symbol = Symbol('listNestedScroll'); 259 applyPeer(node: KNode, reset: boolean): void { 260 if (reset) { 261 getUINativeModule().list.resetListNestedScroll(node); 262 } else { 263 getUINativeModule().list.setListNestedScroll(node, this.value?.scrollForward, this.value?.scrollBackward); 264 } 265 } 266} 267 268class ListScrollBarModifier extends ModifierWithKey<number> { 269 constructor(value: number) { 270 super(value); 271 } 272 static identity: Symbol = Symbol('listScrollBar'); 273 applyPeer(node: KNode, reset: boolean): void { 274 if (reset) { 275 getUINativeModule().list.resetListScrollBar(node); 276 } else { 277 getUINativeModule().list.setListScrollBar(node, this.value!); 278 } 279 } 280} 281 282class ListScrollBarWidthModifier extends ModifierWithKey<string | number> { 283 constructor(value: string | number) { 284 super(value); 285 } 286 static identity: Symbol = Symbol('listScrollBarWidth'); 287 applyPeer(node: KNode, reset: boolean): void { 288 if (reset) { 289 getUINativeModule().list.resetScrollBarWidth(node); 290 } else { 291 getUINativeModule().list.setScrollBarWidth(node, this.value); 292 } 293 } 294 checkObjectDiff(): boolean { 295 return !isBaseOrResourceEqual(this.stageValue, this.value); 296 } 297} 298 299class ListScrollBarColorModifier extends ModifierWithKey<string | number | Color> { 300 constructor(value: string | number | Color) { 301 super(value); 302 } 303 static identity: Symbol = Symbol('listScrollBarColor'); 304 applyPeer(node: KNode, reset: boolean): void { 305 if (reset) { 306 getUINativeModule().list.resetScrollBarColor(node); 307 } else { 308 getUINativeModule().list.setScrollBarColor(node, this.value); 309 } 310 } 311 checkObjectDiff(): boolean { 312 return !isBaseOrResourceEqual(this.stageValue, this.value); 313 } 314} 315 316class ListFlingSpeedLimitModifier extends ModifierWithKey<number> { 317 constructor(value: number) { 318 super(value); 319 } 320 static identity: Symbol = Symbol('listFlingSpeedLimit'); 321 applyPeer(node: KNode, reset: boolean): void { 322 if (reset) { 323 getUINativeModule().list.resetFlingSpeedLimit(node); 324 } else { 325 getUINativeModule().list.setFlingSpeedLimit(node, this.value); 326 } 327 } 328 checkObjectDiff(): boolean { 329 return !isBaseOrResourceEqual(this.stageValue, this.value); 330 } 331} 332 333class ListLanesModifier extends ModifierWithKey<ArkLanesOpt> { 334 constructor(value: ArkLanesOpt) { 335 super(value); 336 } 337 static identity: Symbol = Symbol('listLanes'); 338 applyPeer(node: KNode, reset: boolean): void { 339 if (reset) { 340 getUINativeModule().list.resetListLanes(node); 341 } else { 342 getUINativeModule().list.setListLanes(node, this.value.lanesNum, 343 this.value.minLength, this.value.maxLength, this.value.gutter); 344 } 345 } 346 checkObjectDiff(): boolean { 347 return true; 348 } 349} 350 351class ListClipModifier extends ModifierWithKey<boolean | object> { 352 constructor(value: boolean | object) { 353 super(value); 354 } 355 static identity: Symbol = Symbol('listClip'); 356 applyPeer(node: KNode, reset: boolean): void { 357 if (reset) { 358 getUINativeModule().common.resetClipWithEdge(node); 359 } else { 360 getUINativeModule().common.setClipWithEdge(node, this.value); 361 } 362 } 363 checkObjectDiff(): boolean { 364 return true; 365 } 366} 367 368class ListOnScrollIndexModifier extends ModifierWithKey<(start: number, end: number, center: number) => void> { 369 constructor(value: (start: number, end: number, center: number) => void) { 370 super(value); 371 } 372 static identity: Symbol = Symbol('listOnScrollIndex'); 373 applyPeer(node: KNode, reset: boolean): void { 374 if (reset) { 375 getUINativeModule().list.resetOnScrollIndex(node); 376 } else { 377 getUINativeModule().list.setOnScrollIndex(node, this.value); 378 } 379 } 380} 381 382class ListOnScrollVisibleContentChangeModifier extends ModifierWithKey<OnScrollVisibleContentChangeCallback> { 383 constructor(value: OnScrollVisibleContentChangeCallback) { 384 super(value); 385 } 386 static identity: Symbol = Symbol('listOnScrollVisibleContentChange'); 387 applyPeer(node: KNode, reset: boolean): void { 388 if (reset) { 389 getUINativeModule().list.resetOnScrollVisibleContentChange(node); 390 } else { 391 getUINativeModule().list.setOnScrollVisibleContentChange(node, this.value); 392 } 393 } 394} 395 396class ListOnReachStartModifier extends ModifierWithKey<() => void> { 397 constructor(value: () => void) { 398 super(value); 399 } 400 static identity: Symbol = Symbol('listOnReachStart'); 401 applyPeer(node: KNode, reset: boolean): void { 402 if (reset) { 403 getUINativeModule().list.resetOnReachStart(node); 404 } else { 405 getUINativeModule().list.setOnReachStart(node, this.value); 406 } 407 } 408} 409 410class ListOnReachEndModifier extends ModifierWithKey<() => void> { 411 constructor(value: () => void) { 412 super(value); 413 } 414 static identity: Symbol = Symbol('listOnReachEnd'); 415 applyPeer(node: KNode, reset: boolean): void { 416 if (reset) { 417 getUINativeModule().list.resetOnReachEnd(node); 418 } else { 419 getUINativeModule().list.setOnReachEnd(node, this.value); 420 } 421 } 422} 423 424class ListOnScrollStartModifier extends ModifierWithKey<() => void> { 425 constructor(value: () => void) { 426 super(value); 427 } 428 static identity: Symbol = Symbol('listOnScrollStart'); 429 applyPeer(node: KNode, reset: boolean): void { 430 if (reset) { 431 getUINativeModule().list.resetOnScrollStart(node); 432 } else { 433 getUINativeModule().list.setOnScrollStart(node, this.value); 434 } 435 } 436} 437 438class ListOnScrollStopModifier extends ModifierWithKey<() => void> { 439 constructor(value: () => void) { 440 super(value); 441 } 442 static identity: Symbol = Symbol('listOnScrollStop'); 443 applyPeer(node: KNode, reset: boolean): void { 444 if (reset) { 445 getUINativeModule().list.resetOnScrollStop(node); 446 } else { 447 getUINativeModule().list.setOnScrollStop(node, this.value); 448 } 449 } 450} 451 452class ListOnItemMoveModifier extends ModifierWithKey<(from: number, to: number) => boolean> { 453 constructor(value: (from: number, to: number) => boolean) { 454 super(value); 455 } 456 static identity: Symbol = Symbol('listOnItemMove'); 457 applyPeer(node: KNode, reset: boolean): void { 458 if (reset) { 459 getUINativeModule().list.resetOnItemMove(node); 460 } else { 461 getUINativeModule().list.setOnItemMove(node, this.value); 462 } 463 } 464} 465 466class ListOnItemDragStartModifier extends ModifierWithKey<(event: ItemDragInfo, itemIndex: number) => void | (() => any)> { 467 constructor(value: (event: ItemDragInfo, itemIndex: number) => void | (() => any)) { 468 super(value); 469 } 470 static identity: Symbol = Symbol('listOnItemDragStart'); 471 applyPeer(node: KNode, reset: boolean): void { 472 if (reset) { 473 getUINativeModule().list.resetOnItemDragStart(node); 474 } else { 475 getUINativeModule().list.setOnItemDragStart(node, this.value); 476 } 477 } 478} 479 480class ListOnItemDragEnterModifier extends ModifierWithKey<(event: ItemDragInfo) => void> { 481 constructor(value: (event: ItemDragInfo) => void) { 482 super(value); 483 } 484 static identity: Symbol = Symbol('listOnItemDragEnter'); 485 applyPeer(node: KNode, reset: boolean): void { 486 if (reset) { 487 getUINativeModule().list.resetOnItemDragEnter(node); 488 } else { 489 getUINativeModule().list.setOnItemDragEnter(node, this.value); 490 } 491 } 492} 493 494class ListOnItemDragMoveModifier extends ModifierWithKey<(event: ItemDragInfo, itemIndex: number, insertIndex: number) => void> { 495 constructor(value: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void) { 496 super(value); 497 } 498 static identity: Symbol = Symbol('listOnItemDragMove'); 499 applyPeer(node: KNode, reset: boolean): void { 500 if (reset) { 501 getUINativeModule().list.resetOnItemDragMove(node); 502 } else { 503 getUINativeModule().list.setOnItemDragMove(node, this.value); 504 } 505 } 506} 507 508class ListOnItemDragLeaveModifier extends ModifierWithKey<(event: ItemDragInfo, itemIndex: number) => void> { 509 constructor(value: (event: ItemDragInfo, itemIndex: number) => void) { 510 super(value); 511 } 512 static identity: Symbol = Symbol('listOnItemDragLeave'); 513 applyPeer(node: KNode, reset: boolean): void { 514 if (reset) { 515 getUINativeModule().list.resetOnItemDragLeave(node); 516 } else { 517 getUINativeModule().list.setOnItemDragLeave(node, this.value); 518 } 519 } 520} 521 522class ListOnItemDropModifier extends ModifierWithKey<(event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void> { 523 constructor(value: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void) { 524 super(value); 525 } 526 static identity: Symbol = Symbol('listOnItemDrop'); 527 applyPeer(node: KNode, reset: boolean): void { 528 if (reset) { 529 getUINativeModule().list.resetOnItemDrop(node); 530 } else { 531 getUINativeModule().list.setOnItemDrop(node, this.value); 532 } 533 } 534} 535 536class ListOnScrollFrameBeginModifier extends ModifierWithKey<(offset: number, state: ScrollState) => { offsetRemain: number }> { 537 constructor(value: (offset: number, state: ScrollState) => { offsetRemain: number; }) { 538 super(value); 539 } 540 static identity: Symbol = Symbol('listOnScrollFrameBegin'); 541 applyPeer(node: KNode, reset: boolean): void { 542 if (reset) { 543 getUINativeModule().list.resetOnScrollFrameBegin(node); 544 } else { 545 getUINativeModule().list.setOnScrollFrameBegin(node, this.value); 546 } 547 } 548} 549 550class ListOnWillScrollModifier extends ModifierWithKey<(xOffset: number, yOffset: number, 551 scrollState: ScrollState, scrollSource: ScrollSource) => void | OffsetResult> { 552 constructor(value: (xOffset: number, yOffset: number, 553 scrollState: ScrollState, scrollSource: ScrollSource) => void | OffsetResult) { 554 super(value); 555 } 556 static identity: Symbol = Symbol('listOnWillScroll'); 557 applyPeer(node: KNode, reset: boolean): void { 558 if (reset) { 559 getUINativeModule().list.resetOnWillScroll(node); 560 } else { 561 getUINativeModule().list.setOnWillScroll(node, this.value); 562 } 563 } 564} 565 566class ListOnDidScrollModifier extends ModifierWithKey<(xOffset: number, yOffset: number, scrollState: ScrollState) => void> { 567 constructor(value: (xOffset: number, yOffset: number, scrollState: ScrollState) => void) { 568 super(value); 569 } 570 static identity: Symbol = Symbol('listOnDidScroll'); 571 applyPeer(node: KNode, reset: boolean): void { 572 if (reset) { 573 getUINativeModule().list.resetOnDidScroll(node); 574 } else { 575 getUINativeModule().list.setOnDidScroll(node, this.value); 576 } 577 } 578} 579 580class ListChildrenMainSizeModifier extends ModifierWithKey<ChildrenMainSize> { 581 constructor(value: ChildrenMainSize) { 582 super(value); 583 } 584 static identity: Symbol = Symbol('listChildrenMainSize'); 585 applyPeer(node: KNode, reset: boolean): void { 586 if (reset) { 587 getUINativeModule().list.resetListChildrenMainSize(node); 588 } else { 589 getUINativeModule().list.setListChildrenMainSize(node, this.value); 590 } 591 } 592 checkObjectDiff(): boolean { 593 return true; 594 } 595} 596 597class ListSpaceModifier extends ModifierWithKey<number | string> { 598 constructor(value: number | string) { 599 super(value); 600 } 601 static identity: Symbol = Symbol('listSpace'); 602 applyPeer(node: KNode, reset: boolean): void { 603 if (reset) { 604 getUINativeModule().list.resetSpace(node); 605 } 606 else { 607 getUINativeModule().list.setSpace(node, this.value); 608 } 609 } 610} 611 612class ListInitialIndexModifier extends ModifierWithKey<number> { 613 constructor(value: number) { 614 super(value); 615 } 616 static identity: Symbol = Symbol('listInitialIndex'); 617 applyPeer(node: KNode, reset: boolean): void { 618 if (reset) { 619 getUINativeModule().list.resetInitialIndex(node); 620 } 621 else { 622 getUINativeModule().list.setInitialIndex(node, this.value); 623 } 624 } 625} 626 627class ListInitialScrollerModifier extends ModifierWithKey<number> { 628 constructor(value: number) { 629 super(value); 630 } 631 static identity: Symbol = Symbol('listInitialScroller'); 632 applyPeer(node: KNode, reset: boolean): void { 633 if (reset) { 634 getUINativeModule().list.resetInitialScroller(node); 635 } 636 else { 637 getUINativeModule().list.setInitialScroller(node, this.value); 638 } 639 } 640} 641 642interface ListParam { 643 initialIndex?: number; 644 space?: number | string; 645 scroller?: Scroller; 646} 647 648class ArkListComponent extends ArkScrollable<ListAttribute> implements ListAttribute { 649 constructor(nativePtr: KNode, classType?: ModifierType) { 650 super(nativePtr, classType); 651 } 652 initialize(value: Object[]): this { 653 if (value[0] !== undefined) { 654 if ((value[0] as ListParam).initialIndex !== undefined) { 655 modifierWithKey(this._modifiersWithKeys, ListInitialIndexModifier.identity, ListInitialIndexModifier, (value[0] as ListParam).initialIndex); 656 } 657 if ((value[0] as ListParam).space !== undefined) { 658 modifierWithKey(this._modifiersWithKeys, ListSpaceModifier.identity, ListSpaceModifier, (value[0] as ListParam).space); 659 } 660 if ((value[0] as ListParam).scroller !== undefined) { 661 modifierWithKey(this._modifiersWithKeys, ListInitialScrollerModifier.identity, ListInitialScrollerModifier, (value[0] as ListParam).scroller); 662 } 663 } 664 return this; 665 } 666 allowChildTypes(): string[] { 667 return ["ListItem", "ListItemGroup"]; 668 } 669 lanes(value: number | LengthConstrain, gutter?: any): this { 670 let opt: ArkLanesOpt = new ArkLanesOpt(); 671 opt.gutter = gutter; 672 if (isUndefined(value)) { 673 opt.lanesNum = undefined; 674 } else if (isNumber(value)) { 675 opt.lanesNum = value as number; 676 } else { 677 const lc = value as LengthConstrain; 678 opt.minLength = lc.minLength; 679 opt.maxLength = lc.maxLength; 680 } 681 modifierWithKey(this._modifiersWithKeys, ListLanesModifier.identity, ListLanesModifier, opt); 682 return this; 683 } 684 alignListItem(value: ListItemAlign): this { 685 modifierWithKey(this._modifiersWithKeys, ListAlignListItemModifier.identity, ListAlignListItemModifier, value); 686 return this; 687 } 688 listDirection(value: Axis): this { 689 modifierWithKey(this._modifiersWithKeys, ListListDirectionModifier.identity, ListListDirectionModifier, value); 690 return this; 691 } 692 scrollBar(value: BarState): this { 693 modifierWithKey(this._modifiersWithKeys, ListScrollBarModifier.identity, ListScrollBarModifier, value); 694 return this; 695 } 696 scrollBarWidth(value: string | number): this { 697 modifierWithKey(this._modifiersWithKeys, ListScrollBarWidthModifier.identity, ListScrollBarWidthModifier, value); 698 return this; 699 } 700 scrollBarColor(value: string | number | Color): this { 701 modifierWithKey(this._modifiersWithKeys, ListScrollBarColorModifier.identity, ListScrollBarColorModifier, value); 702 return this; 703 } 704 flingSpeedLimit(value: number): this { 705 modifierWithKey(this._modifiersWithKeys, ListFlingSpeedLimitModifier.identity, ListFlingSpeedLimitModifier, value); 706 return this; 707 } 708 contentStartOffset(value: number): this { 709 modifierWithKey(this._modifiersWithKeys, ContentStartOffsetModifier.identity, ContentStartOffsetModifier, value); 710 return this; 711 } 712 contentEndOffset(value: number): this { 713 modifierWithKey(this._modifiersWithKeys, ContentEndOffsetModifier.identity, ContentEndOffsetModifier, value); 714 return this; 715 } 716 divider(value: { strokeWidth: any; color?: any; startMargin?: any; endMargin?: any; } | null): this { 717 modifierWithKey(this._modifiersWithKeys, ListDividerModifier.identity, ListDividerModifier, value); 718 return this; 719 } 720 editMode(value: boolean): this { 721 modifierWithKey(this._modifiersWithKeys, ListEditModeModifier.identity, ListEditModeModifier, value); 722 return this; 723 } 724 multiSelectable(value: boolean): this { 725 modifierWithKey(this._modifiersWithKeys, ListMultiSelectableModifier.identity, ListMultiSelectableModifier, value); 726 return this; 727 } 728 cachedCount(count: number, show?: boolean): this { 729 let opt = new ArkScrollableCacheOptions(count, show ? show : false); 730 modifierWithKey(this._modifiersWithKeys, ListCachedCountModifier.identity, ListCachedCountModifier, opt); 731 return this; 732 } 733 chainAnimation(value: boolean): this { 734 modifierWithKey(this._modifiersWithKeys, ListChainAnimationModifier.identity, ListChainAnimationModifier, value); 735 return this; 736 } 737 chainAnimationOptions(value: ChainAnimationOptions): this { 738 modifierWithKey(this._modifiersWithKeys, ChainAnimationOptionsModifier.identity, ChainAnimationOptionsModifier, value); 739 return this; 740 } 741 sticky(value: StickyStyle): this { 742 modifierWithKey(this._modifiersWithKeys, ListStickyModifier.identity, ListStickyModifier, value); 743 return this; 744 } 745 scrollSnapAlign(value: ScrollSnapAlign): this { 746 modifierWithKey(this._modifiersWithKeys, ListScrollSnapAlignModifier.identity, ListScrollSnapAlignModifier, value); 747 return this; 748 } 749 nestedScroll(value: NestedScrollOptions): this { 750 modifierWithKey(this._modifiersWithKeys, ListNestedScrollModifier.identity, ListNestedScrollModifier, value); 751 return this; 752 } 753 enableScrollInteraction(value: boolean): this { 754 modifierWithKey(this._modifiersWithKeys, ListEnableScrollInteractionModifier.identity, ListEnableScrollInteractionModifier, value); 755 return this; 756 } 757 friction(value: any): this { 758 modifierWithKey(this._modifiersWithKeys, ListFrictionModifier.identity, ListFrictionModifier, value); 759 return this; 760 } 761 maintainVisibleContentPosition(value: boolean | undefined): this { 762 modifierWithKey(this._modifiersWithKeys, ListMaintainVisibleContentPositionModifier.identity, 763 ListMaintainVisibleContentPositionModifier, value); 764 return this; 765 } 766 clip(value: boolean | CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute): this { 767 modifierWithKey(this._modifiersWithKeys, ListClipModifier.identity, ListClipModifier, value); 768 return this; 769 } 770 onScroll(event: (scrollOffset: number, scrollState: ScrollState) => void): this { 771 throw new Error('Method not implemented.'); 772 } 773 onScrollIndex(event: (start: number, end: number, center: number) => void): this { 774 modifierWithKey(this._modifiersWithKeys, ListOnScrollIndexModifier.identity, ListOnScrollIndexModifier, event); 775 return this; 776 } 777 onScrollVisibleContentChange(callback: OnScrollVisibleContentChangeCallback): this { 778 modifierWithKey(this._modifiersWithKeys, ListOnScrollVisibleContentChangeModifier.identity, ListOnScrollVisibleContentChangeModifier, callback); 779 return this; 780 } 781 onItemDelete(event: (index: number) => boolean): this { 782 throw new Error('Method not implemented.'); 783 } 784 onItemMove(callback: (from: number, to: number) => boolean): this { 785 modifierWithKey(this._modifiersWithKeys, ListOnItemMoveModifier.identity, ListOnItemMoveModifier, callback); 786 return this; 787 } 788 onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => void | (() => any)): this { 789 modifierWithKey(this._modifiersWithKeys, ListOnItemDragStartModifier.identity, ListOnItemDragStartModifier, event); 790 return this; 791 } 792 onItemDragEnter(event: (event: ItemDragInfo) => void): this { 793 modifierWithKey(this._modifiersWithKeys, ListOnItemDragEnterModifier.identity, ListOnItemDragEnterModifier, event); 794 return this; 795 } 796 onItemDragMove(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void): this { 797 modifierWithKey(this._modifiersWithKeys, ListOnItemDragMoveModifier.identity, ListOnItemDragMoveModifier, event); 798 return this; 799 } 800 onItemDragLeave(event: (event: ItemDragInfo, itemIndex: number) => void): this { 801 modifierWithKey(this._modifiersWithKeys, ListOnItemDragLeaveModifier.identity, ListOnItemDragLeaveModifier, event); 802 return this; 803 } 804 onItemDrop(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void): this { 805 modifierWithKey(this._modifiersWithKeys, ListOnItemDropModifier.identity, ListOnItemDropModifier, event); 806 return this; 807 } 808 onScrollFrameBegin(callback: (offset: number, state: ScrollState) => { offsetRemain: number }): this { 809 modifierWithKey(this._modifiersWithKeys, ListOnScrollFrameBeginModifier.identity, ListOnScrollFrameBeginModifier, callback); 810 return this; 811 } 812 onWillScroll(callback: (xOffset: number, yOffset: number, 813 scrollState: ScrollState, scrollSource: ScrollSource) => void | OffsetResult): this { 814 modifierWithKey(this._modifiersWithKeys, ListOnWillScrollModifier.identity, ListOnWillScrollModifier, callback); 815 return this; 816 } 817 onDidScroll(callback: (xOffset: number, yOffset: number, scrollState: ScrollState) => void): this { 818 modifierWithKey(this._modifiersWithKeys, ListOnDidScrollModifier.identity, ListOnDidScrollModifier, callback); 819 return this; 820 } 821 onReachStart(event: () => void): this { 822 modifierWithKey(this._modifiersWithKeys, ListOnReachStartModifier.identity, ListOnReachStartModifier, event); 823 return this; 824 } 825 onReachEnd(event: () => void): this { 826 modifierWithKey(this._modifiersWithKeys, ListOnReachEndModifier.identity, ListOnReachEndModifier, event); 827 return this; 828 } 829 onScrollStart(event: () => void): this { 830 modifierWithKey(this._modifiersWithKeys, ListOnScrollStartModifier.identity, ListOnScrollStartModifier, event); 831 return this; 832 } 833 onScrollStop(event: () => void): this { 834 modifierWithKey(this._modifiersWithKeys, ListOnScrollStopModifier.identity, ListOnScrollStopModifier, event); 835 return this; 836 } 837 childrenMainSize(value: ChildrenMainSize): this { 838 modifierWithKey(this._modifiersWithKeys, ListChildrenMainSizeModifier.identity, ListChildrenMainSizeModifier, value); 839 return this; 840 } 841} 842 843// @ts-ignore 844globalThis.List.attributeModifier = function (modifier: ArkComponent): void { 845 attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => { 846 return new ArkListComponent(nativePtr); 847 }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => { 848 return new modifierJS.ListModifier(nativePtr, classType); 849 }); 850}; 851