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