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