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' /> 17class ArkSwiperComponent extends ArkComponent implements SwiperAttribute { 18 constructor(nativePtr: KNode, classType?: ModifierType) { 19 super(nativePtr, classType); 20 } 21 initialize(value: Object[]): SwiperAttribute { 22 if (value[0] !== undefined) { 23 modifierWithKey(this._modifiersWithKeys, SwiperInitializeModifier.identity, SwiperInitializeModifier, value[0]); 24 } 25 return this; 26 } 27 index(value: number): this { 28 modifierWithKey(this._modifiersWithKeys, SwiperIndexModifier.identity, SwiperIndexModifier, value); 29 return this; 30 } 31 autoPlay(value: boolean): this { 32 modifierWithKey(this._modifiersWithKeys, SwiperAutoPlayModifier.identity, SwiperAutoPlayModifier, value); 33 return this; 34 } 35 interval(value: number): this { 36 modifierWithKey(this._modifiersWithKeys, SwiperIntervalModifier.identity, SwiperIntervalModifier, value); 37 return this; 38 } 39 40 indicator(value: boolean | DotIndicator | DigitIndicator): this { 41 modifierWithKey(this._modifiersWithKeys, SwiperIndicatorModifier.identity, SwiperIndicatorModifier, value); 42 return this; 43 } 44 45 displayArrow(value: boolean | ArrowStyle, isHoverShow?: boolean | undefined): this { 46 let arkDisplayArrow = new ArkDisplayArrow(); 47 arkDisplayArrow.value = value; 48 arkDisplayArrow.isHoverShow = isHoverShow; 49 modifierWithKey( 50 this._modifiersWithKeys, 51 SwiperDisplayArrowModifier.identity, 52 SwiperDisplayArrowModifier, 53 arkDisplayArrow 54 ); 55 return this; 56 } 57 loop(value: boolean): this { 58 modifierWithKey(this._modifiersWithKeys, SwiperLoopModifier.identity, SwiperLoopModifier, value); 59 return this; 60 } 61 duration(value: number): this { 62 modifierWithKey(this._modifiersWithKeys, SwiperDurationModifier.identity, SwiperDurationModifier, value); 63 return this; 64 } 65 vertical(value: boolean): this { 66 modifierWithKey(this._modifiersWithKeys, SwiperVerticalModifier.identity, SwiperVerticalModifier, value); 67 return this; 68 } 69 itemSpace(value: string | number): this { 70 modifierWithKey(this._modifiersWithKeys, SwiperItemSpaceModifier.identity, SwiperItemSpaceModifier, value); 71 return this; 72 } 73 displayMode(value: SwiperDisplayMode): this { 74 modifierWithKey(this._modifiersWithKeys, SwiperDisplayModeModifier.identity, SwiperDisplayModeModifier, value); 75 return this; 76 } 77 cachedCount(value: number, isShown?: boolean): this { 78 let arkCachedCount = new ArkSwiperCachedCount(); 79 arkCachedCount.value = value; 80 arkCachedCount.isShown = isShown; 81 modifierWithKey( 82 this._modifiersWithKeys, 83 SwiperCachedCountModifier.identity, 84 SwiperCachedCountModifier, 85 arkCachedCount 86 ); 87 return this; 88 } 89 displayCount(value: string | number | SwiperAutoFill, swipeByGroup?: boolean | undefined): this { 90 let arkDisplayCount = new ArkDisplayCount(); 91 arkDisplayCount.value = value; 92 arkDisplayCount.swipeByGroup = swipeByGroup; 93 modifierWithKey( 94 this._modifiersWithKeys, 95 SwiperDisplayCountModifier.identity, 96 SwiperDisplayCountModifier, 97 arkDisplayCount 98 ); 99 return this; 100 } 101 effectMode(value: EdgeEffect): this { 102 modifierWithKey(this._modifiersWithKeys, SwiperEffectModeModifier.identity, SwiperEffectModeModifier, value); 103 return this; 104 } 105 disableSwipe(value: boolean): this { 106 modifierWithKey(this._modifiersWithKeys, SwiperDisableSwipeModifier.identity, SwiperDisableSwipeModifier, value); 107 return this; 108 } 109 110 curve(value: string | Curve | ICurve): this { 111 modifierWithKey(this._modifiersWithKeys, SwiperCurveModifier.identity, SwiperCurveModifier, value); 112 return this; 113 } 114 onChange(event: (index: number) => void): this { 115 modifierWithKey(this._modifiersWithKeys, SwiperOnChangeModifier.identity, SwiperOnChangeModifier, event); 116 return this; 117 } 118 indicatorStyle(value?: IndicatorStyle | undefined): this { 119 throw new Error('Method not implemented.'); 120 } 121 prevMargin(value: Length): this { 122 modifierWithKey(this._modifiersWithKeys, SwiperPrevMarginModifier.identity, SwiperPrevMarginModifier, value); 123 return this; 124 } 125 nextMargin(value: Length): this { 126 modifierWithKey(this._modifiersWithKeys, SwiperNextMarginModifier.identity, SwiperNextMarginModifier, value); 127 return this; 128 } 129 enabled(value: boolean): this { 130 modifierWithKey(this._modifiersWithKeys, SwiperEnabledModifier.identity, SwiperEnabledModifier, value); 131 return this; 132 } 133 onAnimationStart(event: (index: number, targetIndex: number, extraInfo: SwiperAnimationEvent) => void): this { 134 modifierWithKey(this._modifiersWithKeys, SwiperOnAnimationStartModifier.identity, SwiperOnAnimationStartModifier, event); 135 return this; 136 } 137 onAnimationEnd(event: (index: number, extraInfo: SwiperAnimationEvent) => void): this { 138 modifierWithKey(this._modifiersWithKeys, SwiperOnAnimationEndModifier.identity, SwiperOnAnimationEndModifier, event); 139 return this; 140 } 141 onGestureSwipe(event: (index: number, extraInfo: SwiperAnimationEvent) => void): this { 142 modifierWithKey(this._modifiersWithKeys, SwiperOnGestureSwipeModifier.identity, SwiperOnGestureSwipeModifier, event); 143 return this; 144 } 145 nestedScroll(value: SwiperNestedScrollMode): this { 146 modifierWithKey(this._modifiersWithKeys, SwiperNestedScrollModifier.identity, SwiperNestedScrollModifier, value); 147 return this; 148 } 149 indicatorInteractive(value: boolean): this { 150 modifierWithKey(this._modifiersWithKeys, SwiperIndicatorInteractiveModifier.identity, SwiperIndicatorInteractiveModifier, value); 151 return this; 152 } 153 customContentTransition(transition: SwiperContentAnimatedTransition): this { 154 modifierWithKey(this._modifiersWithKeys, SwiperCustomContentTransitionModifier.identity, SwiperCustomContentTransitionModifier, transition); 155 return this; 156 } 157 onContentDidScroll(handler: ContentDidScrollCallback): this { 158 modifierWithKey(this._modifiersWithKeys, SwiperOnContentDidScrollModifier.identity, SwiperOnContentDidScrollModifier, handler); 159 return this; 160 } 161 pageFlipMode(value: PageFlipMode): this { 162 modifierWithKey(this._modifiersWithKeys, SwiperPageFlipModeModifier.identity, SwiperPageFlipModeModifier, value); 163 return this; 164 } 165 onContentWillScroll(handler: ContentWillScrollCallback): this { 166 modifierWithKey(this._modifiersWithKeys, SwiperOnContentWillScrollModifier.identity, SwiperOnContentWillScrollModifier, handler); 167 return this; 168 } 169} 170class SwiperInitializeModifier extends ModifierWithKey<SwiperController> { 171 static identity: Symbol = Symbol('swiperInitialize'); 172 applyPeer(node: KNode, reset: boolean): void { 173 if (reset) { 174 getUINativeModule().swiper.resetSwiperInitialize(node); 175 } else { 176 getUINativeModule().swiper.setSwiperInitialize(node, this.value); 177 } 178 } 179} 180class SwiperNextMarginModifier extends ModifierWithKey<Length> { 181 static identity: Symbol = Symbol('swiperNextMargin'); 182 applyPeer(node: KNode, reset: boolean): void { 183 if (reset) { 184 getUINativeModule().swiper.resetSwiperNextMargin(node); 185 } else { 186 getUINativeModule().swiper.setSwiperNextMargin(node, this.value); 187 } 188 } 189 checkObjectDiff(): boolean { 190 return !isBaseOrResourceEqual(this.stageValue, this.value); 191 } 192} 193class SwiperPrevMarginModifier extends ModifierWithKey<Length> { 194 static identity: Symbol = Symbol('swiperPrevMargin'); 195 applyPeer(node: KNode, reset: boolean): void { 196 if (reset) { 197 getUINativeModule().swiper.resetSwiperPrevMargin(node); 198 } else { 199 getUINativeModule().swiper.setSwiperPrevMargin(node, this.value); 200 } 201 } 202 checkObjectDiff(): boolean { 203 return !isBaseOrResourceEqual(this.stageValue, this.value); 204 } 205} 206 207class SwiperDisplayCountModifier extends ModifierWithKey<ArkDisplayCount> { 208 static identity: Symbol = Symbol('swiperDisplayCount'); 209 applyPeer(node: KNode, reset: boolean): void { 210 if (reset) { 211 getUINativeModule().swiper.resetSwiperSwipeByGroup(node); 212 getUINativeModule().swiper.resetSwiperDisplayCount(node); 213 } else { 214 if (!isNull(this.value) && !isUndefined(this.value)) { 215 let swipeByGroup; 216 if (typeof this.value.swipeByGroup === 'boolean') { 217 swipeByGroup = this.value.swipeByGroup; 218 } 219 220 getUINativeModule().swiper.setSwiperSwipeByGroup(node, swipeByGroup); 221 222 if (typeof this.value.value === 'object') { 223 let minSize = (this.value.value as SwiperAutoFill).minSize.toString(); 224 getUINativeModule().swiper.setSwiperDisplayCount(node, minSize, typeof this.value.value); 225 } else { 226 getUINativeModule().swiper.setSwiperDisplayCount(node, this.value.value, typeof this.value.value); 227 } 228 } else { 229 getUINativeModule().swiper.resetSwiperSwipeByGroup(node); 230 getUINativeModule().swiper.resetSwiperDisplayCount(node); 231 } 232 } 233 } 234 checkObjectDiff(): boolean { 235 if ( 236 this.stageValue.swipeByGroup !== this.value.swipeByGroup || 237 typeof this.stageValue.value !== typeof this.value.value 238 ) { 239 return true; 240 } else if ( 241 typeof this.stageValue.value === 'object' && 242 typeof this.value.value === 'object' 243 ) { 244 return (this.stageValue.value as SwiperAutoFill).minSize !== (this.value.value as SwiperAutoFill).minSize; 245 } else { 246 return !isBaseOrResourceEqual(this.stageValue.value, this.value.value); 247 } 248 } 249} 250 251class SwiperDisplayArrowModifier extends ModifierWithKey<ArkDisplayArrow> { 252 static identity: Symbol = Symbol('swiperDisplayArrow'); 253 applyPeer(node: KNode, reset: boolean): void { 254 if (reset) { 255 getUINativeModule().swiper.resetSwiperDisplayArrow(node); 256 } else { 257 if (!isNull(this.value.value) && !isUndefined(this.value.value) && typeof this.value === 'object') { 258 let displayArrowValue = 3; 259 let showBackground; 260 let isSidebarMiddle; 261 let backgroundSize; 262 let backgroundColor; 263 let arrowSize; 264 let arrowColor; 265 if (typeof this.value.value === 'boolean') { 266 if (this.value.value) { 267 displayArrowValue = 1; 268 } else { 269 displayArrowValue = 0; 270 } 271 } else if (typeof this.value.value === 'object') { 272 displayArrowValue = 2; 273 showBackground = this.value.value.showBackground; 274 isSidebarMiddle = this.value.value.isSidebarMiddle; 275 backgroundSize = this.value.value.backgroundSize; 276 backgroundColor = this.value.value.backgroundColor; 277 arrowSize = this.value.value.arrowSize; 278 arrowColor = this.value.value.arrowColor; 279 } 280 let isHoverShow; 281 if (typeof this.value.isHoverShow === 'boolean') { 282 isHoverShow = this.value.isHoverShow; 283 } 284 getUINativeModule().swiper.setSwiperDisplayArrow( 285 node, 286 displayArrowValue, 287 showBackground, 288 isSidebarMiddle, 289 backgroundSize, 290 backgroundColor, 291 arrowSize, 292 arrowColor, 293 isHoverShow 294 ); 295 } else { 296 getUINativeModule().swiper.resetSwiperDisplayArrow(node); 297 } 298 } 299 } 300 checkObjectDiff(): boolean { 301 if ( 302 this.stageValue.isHoverShow !== this.value.isHoverShow || 303 typeof this.stageValue.value !== typeof this.value.value 304 ) { 305 return true; 306 } 307 if ( 308 typeof this.stageValue.value === 'boolean' && 309 typeof this.value.value === 'boolean' && 310 this.stageValue.value !== this.value.value 311 ) { 312 return true; 313 } else if (typeof this.stageValue.value === 'object' && typeof this.value.value === 'object') { 314 return ( 315 !isBaseOrResourceEqual( 316 (this.stageValue.value as ArrowStyle).showBackground, 317 (this.value.value as ArrowStyle).showBackground 318 ) || 319 !isBaseOrResourceEqual( 320 (this.stageValue.value as ArrowStyle).isSidebarMiddle, 321 (this.value.value as ArrowStyle).isSidebarMiddle 322 ) || 323 !isBaseOrResourceEqual( 324 (this.stageValue.value as ArrowStyle).backgroundSize, 325 (this.value.value as ArrowStyle).backgroundSize 326 ) || 327 !isBaseOrResourceEqual( 328 (this.stageValue.value as ArrowStyle).backgroundColor, 329 (this.value.value as ArrowStyle).backgroundColor 330 ) || 331 !isBaseOrResourceEqual( 332 (this.stageValue.value as ArrowStyle).arrowSize, 333 (this.value.value as ArrowStyle).arrowSize 334 ) || 335 !isBaseOrResourceEqual( 336 (this.stageValue.value as ArrowStyle).arrowColor, 337 (this.value.value as ArrowStyle).arrowColor 338 ) 339 ); 340 } else { 341 return true; 342 } 343 } 344} 345 346class SwiperIndicatorModifier extends ModifierWithKey<boolean | DotIndicator | DigitIndicator | IndicatorComponentController> { 347 static identity: Symbol = Symbol('swiperIndicator'); 348 applyPeer(node: KNode, reset: boolean): void { 349 if (reset) { 350 getUINativeModule().swiper.resetSwiperIndicator(node); 351 } else { 352 let left; 353 let top; 354 let right; 355 let bottom; 356 let itemWidth; 357 let itemHeight; 358 let selectedItemWidth; 359 let selectedItemHeight; 360 let mask; 361 let color; 362 let selectedColor; 363 let maxDisplayCount; 364 let fontColor; 365 let selectedFontColor; 366 let digitFontSize; 367 let digitFontWeight; 368 let selectedDigitFontSize; 369 let selectedDigitFontWeight; 370 if (typeof this.value === 'boolean') { 371 getUINativeModule().swiper.setSwiperIndicator(node, 'boolean', this.value); 372 } else if (typeof this.value === 'object' && (this.value as ArkDotIndicator).type === 'DotIndicator') { 373 left = (this.value as ArkDotIndicator).leftValue; 374 top = (this.value as ArkDotIndicator).topValue; 375 right = (this.value as ArkDotIndicator).rightValue; 376 bottom = (this.value as ArkDotIndicator).bottomValue; 377 itemWidth = (this.value as ArkDotIndicator).itemWidthValue; 378 itemHeight = (this.value as ArkDotIndicator).itemHeightValue; 379 selectedItemWidth = (this.value as ArkDotIndicator).selectedItemWidthValue; 380 selectedItemHeight = (this.value as ArkDotIndicator).selectedItemHeightValue; 381 mask = (this.value as ArkDotIndicator).maskValue; 382 color = (this.value as ArkDotIndicator).colorValue; 383 selectedColor = (this.value as ArkDotIndicator).selectedColorValue; 384 maxDisplayCount = (this.value as ArkDotIndicator).maxDisplayCountValue; 385 getUINativeModule().swiper.setSwiperIndicator( 386 node, 387 'ArkDotIndicator', 388 itemWidth, 389 itemHeight, 390 selectedItemWidth, 391 selectedItemHeight, 392 mask, 393 color, 394 selectedColor, 395 maxDisplayCount, 396 left, 397 top, 398 right, 399 bottom 400 ); 401 } else if (typeof this.value === 'object' && (this.value as ArkDigitIndicator).type === 'DigitIndicator') { 402 left = (this.value as ArkDigitIndicator).leftValue; 403 top = (this.value as ArkDigitIndicator).topValue; 404 right = (this.value as ArkDigitIndicator).rightValue; 405 bottom = (this.value as ArkDigitIndicator).bottomValue; 406 fontColor = (this.value as ArkDigitIndicator).fontColorValue; 407 selectedFontColor = (this.value as ArkDigitIndicator).selectedFontColorValue; 408 let arkDigitFont = new ArkDigitFont(); 409 if (typeof (this.value as ArkDigitIndicator).digitFontValue === 'object') { 410 digitFontSize = ((this.value as ArkDigitIndicator).digitFontValue as Font).size; 411 digitFontWeight = arkDigitFont.parseFontWeight( 412 ((this.value as ArkDigitIndicator).digitFontValue as Font).weight 413 ); 414 } 415 if (typeof (this.value as ArkDigitIndicator).selectedDigitFontValue === 'object') { 416 selectedDigitFontSize = ((this.value as ArkDigitIndicator).selectedDigitFontValue as Font).size; 417 selectedDigitFontWeight = arkDigitFont.parseFontWeight( 418 ((this.value as ArkDigitIndicator).selectedDigitFontValue as Font).weight 419 ); 420 } 421 getUINativeModule().swiper.setSwiperIndicator( 422 node, 423 'ArkDigitIndicator', 424 fontColor, 425 selectedFontColor, 426 digitFontSize, 427 digitFontWeight, 428 selectedDigitFontSize, 429 selectedDigitFontWeight, 430 left, 431 top, 432 right, 433 bottom 434 ); 435 } else { 436 getUINativeModule().swiper.setSwiperIndicator(node, 'IndicatorComponentController', this.value ); 437 } 438 } 439 } 440 checkObjectDiff(): boolean { 441 if (typeof this.stageValue !== typeof this.value) { 442 return true; 443 } 444 if (typeof this.stageValue === 'boolean' && typeof this.value === 'boolean') { 445 return this.stageValue !== this.value; 446 } 447 if (this.stageValue instanceof ArkDotIndicator && this.value instanceof ArkDotIndicator) { 448 return ( 449 !isBaseOrResourceEqual( 450 (this.stageValue as ArkDotIndicator).itemWidthValue, 451 (this.value as ArkDotIndicator).itemWidthValue 452 ) || 453 !isBaseOrResourceEqual( 454 (this.stageValue as ArkDotIndicator).itemHeightValue, 455 (this.value as ArkDotIndicator).itemHeightValue 456 ) || 457 !isBaseOrResourceEqual( 458 (this.stageValue as ArkDotIndicator).selectedItemWidthValue, 459 (this.value as ArkDotIndicator).selectedItemWidthValue 460 ) || 461 !isBaseOrResourceEqual( 462 (this.stageValue as ArkDotIndicator).selectedItemHeightValue, 463 (this.value as ArkDotIndicator).selectedItemHeightValue 464 ) || 465 !isBaseOrResourceEqual( 466 (this.stageValue as ArkDotIndicator).maskValue, 467 (this.value as ArkDotIndicator).maskValue 468 ) || 469 !isBaseOrResourceEqual( 470 (this.stageValue as ArkDotIndicator).colorValue, 471 (this.value as ArkDotIndicator).colorValue 472 ) || 473 !isBaseOrResourceEqual( 474 (this.stageValue as ArkDotIndicator).selectedColorValue, 475 (this.value as ArkDotIndicator).selectedColorValue 476 ) || 477 !isBaseOrResourceEqual( 478 (this.stageValue as ArkDotIndicator).maxDisplayCountValue, 479 (this.value as ArkDotIndicator).maxDisplayCountValue 480 ) 481 ); 482 } else if (this.stageValue instanceof ArkDigitIndicator && this.value instanceof ArkDigitIndicator) { 483 return ( 484 !isBaseOrResourceEqual( 485 (this.stageValue as ArkDigitIndicator).fontColorValue, 486 (this.value as ArkDigitIndicator).fontColorValue 487 ) || 488 !isBaseOrResourceEqual( 489 (this.stageValue as ArkDigitIndicator).selectedFontColorValue, 490 (this.value as ArkDigitIndicator).selectedFontColorValue 491 ) || 492 !isBaseOrResourceEqual( 493 ((this.stageValue as ArkDigitIndicator).digitFontValue as Font).size, 494 ((this.value as ArkDigitIndicator).digitFontValue as Font).size 495 ) || 496 !isBaseOrResourceEqual( 497 ((this.stageValue as ArkDigitIndicator).digitFontValue as Font).weight, 498 ((this.value as ArkDigitIndicator).digitFontValue as Font).weight 499 ) || 500 !isBaseOrResourceEqual( 501 ((this.stageValue as ArkDigitIndicator).selectedDigitFontValue as Font).size, 502 ((this.value as ArkDigitIndicator).selectedDigitFontValue as Font).size 503 ) || 504 !isBaseOrResourceEqual( 505 ((this.stageValue as ArkDigitIndicator).selectedDigitFontValue as Font).weight, 506 ((this.value as ArkDigitIndicator).selectedDigitFontValue as Font).weight 507 ) 508 ); 509 } else { 510 return true; 511 } 512 } 513} 514 515class SwiperCurveModifier extends ModifierWithKey<string | Curve | ICurve> { 516 static identity: Symbol = Symbol('swiperCurve'); 517 applyPeer(node: KNode, reset: boolean): void { 518 if (reset) { 519 getUINativeModule().swiper.resetSwiperCurve(node); 520 } else { 521 const curveMap = { 522 [0]: 'linear', 523 [1]: 'ease', 524 [2]: 'ease-in', 525 [3]: 'ease-out', 526 [4]: 'ease-in-out', 527 [5]: 'fast-out-slow-in', 528 [6]: 'linear-out-slow-in', 529 [7]: 'fast-out-linear-in', 530 [8]: 'extreme-deceleration', 531 [9]: 'sharp', 532 [10]: 'rhythm', 533 [11]: 'smooth', 534 [12]: 'friction' 535 }; 536 if (typeof this.value === 'number') { 537 if (this.value in curveMap) { 538 this.value = curveMap[this.value]; 539 } else { 540 this.value = this.value.toString(); 541 } 542 } 543 getUINativeModule().swiper.setSwiperCurve(node, this.value); 544 } 545 } 546 checkObjectDiff(): boolean { 547 return !isBaseOrResourceEqual(this.stageValue, this.value); 548 } 549} 550class SwiperOnChangeModifier extends ModifierWithKey<Callback<number>> { 551 constructor(value: Callback<number>) { 552 super(value); 553 } 554 static identity: Symbol = Symbol('swiperOnChange'); 555 applyPeer(node: KNode, reset: boolean): void { 556 if (reset) { 557 getUINativeModule().swiper.resetSwiperOnChange(node); 558 } else { 559 getUINativeModule().swiper.setSwiperOnChange(node, this.value); 560 } 561 } 562} 563class SwiperDisableSwipeModifier extends ModifierWithKey<boolean> { 564 static identity: Symbol = Symbol('swiperDisableSwipe'); 565 applyPeer(node: KNode, reset: boolean): void { 566 if (reset) { 567 getUINativeModule().swiper.resetSwiperDisableSwipe(node); 568 } else { 569 getUINativeModule().swiper.setSwiperDisableSwipe(node, this.value); 570 } 571 } 572 checkObjectDiff(): boolean { 573 return !isBaseOrResourceEqual(this.stageValue, this.value); 574 } 575} 576class SwiperEffectModeModifier extends ModifierWithKey<EdgeEffect> { 577 static identity: Symbol = Symbol('swiperEffectMode'); 578 applyPeer(node: KNode, reset: boolean): void { 579 if (reset) { 580 getUINativeModule().swiper.resetSwiperEffectMode(node); 581 } else { 582 getUINativeModule().swiper.setSwiperEffectMode(node, this.value); 583 } 584 } 585 checkObjectDiff(): boolean { 586 return !isBaseOrResourceEqual(this.stageValue, this.value); 587 } 588} 589class SwiperCachedCountModifier extends ModifierWithKey<ArkSwiperCachedCount> { 590 static identity: Symbol = Symbol('swiperCachedCount'); 591 applyPeer(node: KNode, reset: boolean): void { 592 if (reset) { 593 getUINativeModule().swiper.resetSwiperCachedCount(node); 594 getUINativeModule().swiper.resetSwiperIsShown(node); 595 } else { 596 getUINativeModule().swiper.setSwiperCachedCount(node, this.value.value); 597 getUINativeModule().swiper.setSwiperIsShown(node, this.value.isShown); 598 } 599 } 600 checkObjectDiff(): boolean { 601 return (!isBaseOrResourceEqual(this.stageValue.value, this.value.value) || 602 !isBaseOrResourceEqual(this.stageValue.isShown, this.value.isShown)); 603 } 604} 605class SwiperDisplayModeModifier extends ModifierWithKey<number> { 606 static identity: Symbol = Symbol('swiperDisplayMode'); 607 applyPeer(node: KNode, reset: boolean): void { 608 if (reset) { 609 getUINativeModule().swiper.resetSwiperDisplayMode(node); 610 } else { 611 getUINativeModule().swiper.setSwiperDisplayMode(node, this.value); 612 } 613 } 614 checkObjectDiff(): boolean { 615 return !isBaseOrResourceEqual(this.stageValue, this.value); 616 } 617} 618class SwiperItemSpaceModifier extends ModifierWithKey<string | number> { 619 static identity: Symbol = Symbol('swiperItemSpace'); 620 applyPeer(node: KNode, reset: boolean): void { 621 if (reset) { 622 getUINativeModule().swiper.resetSwiperItemSpace(node); 623 } else { 624 getUINativeModule().swiper.setSwiperItemSpace(node, this.value); 625 } 626 } 627 checkObjectDiff(): boolean { 628 return !isBaseOrResourceEqual(this.stageValue, this.value); 629 } 630} 631class SwiperVerticalModifier extends ModifierWithKey<boolean> { 632 static identity: Symbol = Symbol('swiperVertical'); 633 applyPeer(node: KNode, reset: boolean): void { 634 if (reset) { 635 getUINativeModule().swiper.resetSwiperVertical(node); 636 } else { 637 getUINativeModule().swiper.setSwiperVertical(node, this.value); 638 } 639 } 640 checkObjectDiff(): boolean { 641 return !isBaseOrResourceEqual(this.stageValue, this.value); 642 } 643} 644class SwiperLoopModifier extends ModifierWithKey<boolean> { 645 static identity: Symbol = Symbol('swiperLoop'); 646 applyPeer(node: KNode, reset: boolean): void { 647 if (reset) { 648 getUINativeModule().swiper.resetSwiperLoop(node); 649 } else { 650 getUINativeModule().swiper.setSwiperLoop(node, this.value); 651 } 652 } 653 checkObjectDiff(): boolean { 654 return !isBaseOrResourceEqual(this.stageValue, this.value); 655 } 656} 657class SwiperIntervalModifier extends ModifierWithKey<number> { 658 static identity: Symbol = Symbol('swiperInterval'); 659 applyPeer(node: KNode, reset: boolean): void { 660 if (reset) { 661 getUINativeModule().swiper.resetSwiperInterval(node); 662 } else { 663 getUINativeModule().swiper.setSwiperInterval(node, this.value); 664 } 665 } 666 checkObjectDiff(): boolean { 667 return !isBaseOrResourceEqual(this.stageValue, this.value); 668 } 669} 670class SwiperAutoPlayModifier extends ModifierWithKey<boolean> { 671 static identity: Symbol = Symbol('swiperAutoPlay'); 672 applyPeer(node: KNode, reset: boolean): void { 673 if (reset) { 674 getUINativeModule().swiper.resetSwiperAutoPlay(node); 675 } else { 676 getUINativeModule().swiper.setSwiperAutoPlay(node, this.value); 677 } 678 } 679 checkObjectDiff(): boolean { 680 return !isBaseOrResourceEqual(this.stageValue, this.value); 681 } 682} 683class SwiperIndexModifier extends ModifierWithKey<number> { 684 static identity: Symbol = Symbol('swiperIndex'); 685 applyPeer(node: KNode, reset: boolean): void { 686 if (reset) { 687 getUINativeModule().swiper.resetSwiperIndex(node); 688 } else { 689 getUINativeModule().swiper.setSwiperIndex(node, this.value); 690 } 691 } 692 checkObjectDiff(): boolean { 693 return !isBaseOrResourceEqual(this.stageValue, this.value); 694 } 695} 696class SwiperDurationModifier extends ModifierWithKey<number> { 697 static identity: Symbol = Symbol('swiperDuration'); 698 applyPeer(node: KNode, reset: boolean): void { 699 if (reset) { 700 getUINativeModule().swiper.resetSwiperDuration(node); 701 } else { 702 getUINativeModule().swiper.setSwiperDuration(node, this.value); 703 } 704 } 705 checkObjectDiff(): boolean { 706 return !isBaseOrResourceEqual(this.stageValue, this.value); 707 } 708} 709 710class SwiperEnabledModifier extends ModifierWithKey<boolean> { 711 constructor(value: boolean) { 712 super(value); 713 } 714 static identity: Symbol = Symbol('swiperenabled'); 715 applyPeer(node: KNode, reset: boolean): void { 716 if (reset) { 717 getUINativeModule().swiper.resetSwiperEnabled(node); 718 719 } else { 720 getUINativeModule().swiper.setSwiperEnabled(node, this.value); 721 } 722 } 723} 724 725class SwiperNestedScrollModifier extends ModifierWithKey<SwiperNestedScrollMode> { 726 constructor(value: SwiperNestedScrollMode) { 727 super(value); 728 } 729 static identity: Symbol = Symbol('nestedScroll'); 730 applyPeer(node: KNode, reset: boolean): void { 731 if (reset) { 732 getUINativeModule().swiper.resetNestedScroll(node); 733 } else { 734 getUINativeModule().swiper.setNestedScroll(node, this.value); 735 } 736 } 737 checkObjectDiff(): boolean { 738 return !isBaseOrResourceEqual(this.stageValue, this.value); 739 } 740} 741class SwiperOnAnimationStartModifier extends ModifierWithKey<(index: number, targetIndex: number, 742 extraInfo: SwiperAnimationEvent) => void> { 743 constructor(value: (index: number, targetIndex: number, extraInfo: SwiperAnimationEvent) => void) { 744 super(value); 745 } 746 static identity: Symbol = Symbol('swiperOnAnimationStart'); 747 applyPeer(node: KNode, reset: boolean): void { 748 if (reset) { 749 getUINativeModule().swiper.resetSwiperOnAnimationStart(node); 750 } else { 751 getUINativeModule().swiper.setSwiperOnAnimationStart(node, this.value); 752 } 753 } 754} 755class SwiperOnAnimationEndModifier extends ModifierWithKey<Callback<number, SwiperAnimationEvent>> { 756 constructor(value: Callback<number, SwiperAnimationEvent>) { 757 super(value); 758 } 759 static identity: Symbol = Symbol('swiperOnAnimationEnd'); 760 applyPeer(node: KNode, reset: boolean): void { 761 if (reset) { 762 getUINativeModule().swiper.resetSwiperOnAnimationEnd(node); 763 } else { 764 getUINativeModule().swiper.setSwiperOnAnimationEnd(node, this.value); 765 } 766 } 767} 768class SwiperOnGestureSwipeModifier extends ModifierWithKey<Callback<number, SwiperAnimationEvent>> { 769 constructor(value: Callback<number, SwiperAnimationEvent>) { 770 super(value); 771 } 772 static identity: Symbol = Symbol('swiperOnGestureSwipe'); 773 applyPeer(node: KNode, reset: boolean): void { 774 if (reset) { 775 getUINativeModule().swiper.resetSwiperOnGestureSwipe(node); 776 } else { 777 getUINativeModule().swiper.setSwiperOnGestureSwipe(node, this.value); 778 } 779 } 780} 781class SwiperIndicatorInteractiveModifier extends ModifierWithKey<boolean> { 782 constructor(value: boolean) { 783 super(value); 784 } 785 static identity: Symbol = Symbol('indicatorInteractive'); 786 applyPeer(node: KNode, reset: boolean): void { 787 if (reset) { 788 getUINativeModule().swiper.resetIndicatorInteractive(node); 789 } else { 790 getUINativeModule().swiper.setIndicatorInteractive(node, this.value); 791 } 792 } 793} 794class SwiperCustomContentTransitionModifier extends ModifierWithKey<SwiperContentAnimatedTransition> { 795 constructor(value: SwiperContentAnimatedTransition) { 796 super(value); 797 } 798 static identity: Symbol = Symbol('swiperCustomContentTransition'); 799 applyPeer(node: KNode, reset: boolean): void { 800 if (reset) { 801 getUINativeModule().swiper.resetSwiperCustomContentTransition(node); 802 } else { 803 getUINativeModule().swiper.setSwiperCustomContentTransition(node, this.value); 804 } 805 } 806 checkObjectDiff(): boolean { 807 return !isBaseOrResourceEqual(this.stageValue, this.value); 808 } 809} 810class SwiperOnContentDidScrollModifier extends ModifierWithKey<(selectedIndex: number, index: number, 811 position: number, mainAxisLength: number) => void> { 812 constructor(value: (selectedIndex: number, index: number, position: number, mainAxisLength: number) => void) { 813 super(value); 814 } 815 static identity: Symbol = Symbol('swiperOnContentDidScroll'); 816 applyPeer(node: KNode, reset: boolean): void { 817 if (reset) { 818 getUINativeModule().swiper.resetSwiperOnContentDidScroll(node); 819 } else { 820 getUINativeModule().swiper.setSwiperOnContentDidScroll(node, this.value); 821 } 822 } 823 checkObjectDiff(): boolean { 824 return !isBaseOrResourceEqual(this.stageValue, this.value); 825 } 826} 827class SwiperPageFlipModeModifier extends ModifierWithKey<PageFlipMode> { 828 constructor(value: PageFlipMode) { 829 super(value); 830 } 831 static identity: Symbol = Symbol('swiperPageFlipMode'); 832 applyPeer(node: KNode, reset: boolean): void { 833 if (reset) { 834 getUINativeModule().swiper.resetSwiperPageFlipMode(node); 835 } else { 836 getUINativeModule().swiper.setSwiperPageFlipMode(node, this.value); 837 } 838 } 839 checkObjectDiff(): boolean { 840 return !isBaseOrResourceEqual(this.stageValue, this.value); 841 } 842} 843class SwiperOnContentWillScrollModifier extends ModifierWithKey<(result: SwiperContentWillScrollResult) => boolean> { 844 constructor(value: (result: SwiperContentWillScrollResult) => boolean) { 845 super(value); 846 } 847 static identity: Symbol = Symbol('swiperOnContentWillScroll'); 848 applyPeer(node: KNode, reset: boolean): void { 849 if (reset) { 850 getUINativeModule().swiper.resetSwiperOnContentWillScroll(node); 851 } else { 852 getUINativeModule().swiper.setSwiperOnContentWillScroll(node, this.value); 853 } 854 } 855 checkObjectDiff(): boolean { 856 return !isBaseOrResourceEqual(this.stageValue, this.value); 857 } 858} 859// @ts-ignore 860globalThis.Swiper.attributeModifier = function (modifier: ArkComponent): void { 861 attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => { 862 return new ArkSwiperComponent(nativePtr); 863 }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => { 864 return new modifierJS.SwiperModifier(nativePtr, classType); 865 }); 866}; 867