1 /*
2  * Copyright (c) 2021-2022 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SWIPER_RENDER_SWIPER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SWIPER_RENDER_SWIPER_H
18 
19 #include <functional>
20 #include <map>
21 #include <utility>
22 #include <vector>
23 
24 #include "base/memory/ace_type.h"
25 #include "base/utils/macros.h"
26 #include "core/animation/animation.h"
27 #include "core/animation/animator.h"
28 #include "core/animation/keyframe_animation.h"
29 #include "core/animation/scroll_motion.h"
30 #include "core/animation/spring_motion.h"
31 #include "core/common/vibrator/vibrator_proxy.h"
32 #include "core/components/box/render_box.h"
33 #include "core/components/common/properties/swiper_indicator.h"
34 #include "core/components/common/rotation/rotation_controller.h"
35 #include "core/components/common/rotation/rotation_node.h"
36 #include "core/components/flex/flex_component.h"
37 #include "core/components/flex/render_flex.h"
38 #include "core/components/text/render_text.h"
39 #include "core/components/text/text_component.h"
40 #include "core/components/swiper/swiper_component.h"
41 #include "core/gestures/click_recognizer.h"
42 #include "core/gestures/drag_recognizer.h"
43 #include "core/gestures/raw_recognizer.h"
44 #include "core/pipeline/base/render_node.h"
45 
46 namespace OHOS::Ace {
47 
48 struct IndicatorPaintData {
49     double width = 0.0;
50     double height = 0.0;
51     double radius = 0.0;
52     Color color;
53     Offset position;
54     Offset center;
55 };
56 
57 struct SwiperIndicatorData {
58     bool isDigital = false;
59     bool isPressed = false;
60     bool isHovered = false;
61     IndicatorPaintData indicatorPaintData;
62     std::unordered_map<int32_t, IndicatorPaintData> indicatorItemData;
63     double pointPadding = 0.0;
64     double startEndPadding = 0.0;
65     RefPtr<RenderBox> textBoxRender;
66     RefPtr<FlexComponent> flexComponent;
67     RefPtr<RenderFlex> flexRender;
68     RefPtr<TextComponent> textComponentPrev;
69     RefPtr<RenderText> textRenderPrev;
70     RefPtr<TextComponent> textComponentNext;
71     RefPtr<RenderText> textRenderNext;
72 };
73 
74 struct IndicatorOffsetInfo {
75     double focusStart; // start of focus
76     double focusEnd;   // end of focus
77     Offset center; // circle center of point
78     Offset animationMove; // move offset of animation
79 };
80 
81 enum class SpringStatus {
82     SPRING_STOP = 0,
83     SPRING_START,
84     FOCUS_SWITCH,
85 };
86 
87 // swiper contains content and indicator, their operations are mutually exclusive.
88 enum class TouchContentType {
89     TOUCH_NONE = 0,
90     TOUCH_CONTENT,
91     TOUCH_INDICATOR
92 };
93 
94 enum class RotationStatus {
95     ROTATION_START = 0,
96     ROTATION_UPDATE,
97     ROTATION_END,
98 };
99 
100 using SwiperChangeEndListener = std::function<void(const int32_t)>;
101 
102 class ACE_EXPORT RenderSwiper : public RenderNode, public RotationNode {
103     DECLARE_ACE_TYPE(RenderSwiper, RenderNode, RotationNode)
104 
105 public:
106     static constexpr double FADE_DURATION = 500.0;
107     using BuildChildByIndex = std::function<bool(int32_t)>;
108     using DeleteChildByIndex = std::function<void(int32_t)>;
109 
110     ~RenderSwiper() override;
111     static RefPtr<RenderNode> Create();
112     void Update(const RefPtr<Component>& component) override;
113     void PerformLayout() override;
114     bool IsUseOnly() override;
115 
116     bool IsChildrenTouchEnable() override;
117 
GetCurrentIndex()118     int32_t GetCurrentIndex() const
119     {
120         return currentIndex_;
121     }
122     void OnChildAdded(const RefPtr<RenderNode>& child) override;
123     void OnChildRemoved(const RefPtr<RenderNode>& child) override;
124     void OnFocus();
125     void OnBlur();
126     void RegisterChangeEndListener(int32_t listenerId, const SwiperChangeEndListener& listener);
127     void UnRegisterChangeEndListener(int32_t listenerId);
128     bool OnRotation(const RotationEvent& event) override;
129     void OnStatusChanged(RenderStatus renderStatus) override;
130     void IndicatorShowFocus(bool isFocus);
131     void UpdateIndicatorFocus(bool isFocus, bool reverse);
132 
GetMoveStatus()133     bool GetMoveStatus() const
134     {
135         return moveStatus_;
136     }
137 
ExecuteMoveCallback(int32_t index)138     void ExecuteMoveCallback(int32_t index)
139     {
140         const auto& callback = swiper_->GetMoveCallback();
141         if (callback) {
142             callback(index);
143         }
144     }
145 
DisableSwipe(bool disableSwipe)146     void DisableSwipe(bool disableSwipe)
147     {
148         disableSwipe_ = disableSwipe;
149     }
150 
GetDisableSwipe()151     bool GetDisableSwipe() const
152     {
153         return disableSwipe_;
154     }
155 
GetItemSpace()156     Dimension GetItemSpace() const
157     {
158         return itemSpace_;
159     }
160 
GetMainSize(const Size & size)161     double GetMainSize(const Size& size) const
162     {
163         return axis_ == Axis::HORIZONTAL ? size.Width() : size.Height();
164     }
165 
GetCurveRender()166     std::string GetCurveRender() const
167     {
168         return curveRender_;
169     }
170 
GetColor()171     const Color& GetColor() const
172     {
173         return colors_;
174     }
175 
GetSelectedColor()176     const Color& GetSelectedColor() const
177     {
178         return selectedColors_;
179     }
180 
GetSwiperTop()181     const Dimension& GetSwiperTop() const
182     {
183         return swiperTop_;
184     }
185 
GetSwiperLeft()186     const Dimension& GetSwiperLeft() const
187     {
188         return swiperLeft_;
189     }
190 
GetSwiperBottom()191     const Dimension& GetSwiperBottom() const
192     {
193         return swiperBottom_;
194     }
195 
GetSwiperRight()196     const Dimension& GetSwiperRight() const
197     {
198         return swiperRight_;
199     }
200 
GetSwiperSize()201     const Dimension& GetSwiperSize() const
202     {
203         return swiperSize_;
204     }
205 
206     void ShowPrevious();
207     void ShowNext();
208 
209     /* indicator animation begin */
210     // indicator status init
211     void InitIndicatorAnimation(const WeakPtr<PipelineContext>& context);
212     void CalMaxStretch();
213 
214     // indicator with move or drag
215     void MoveIndicator(int32_t toIndex, double offset, bool isAuto = false);
216     void DragIndicator(double offset);
217     void DragIndicatorEnd();
218     void DragEdgeStretch(double offset);
219     void VibrateIndicator();
220 
221     // indicator animation function
222     void StartIndicatorAnimation(int32_t fromIndex, int32_t toIndex, bool isLoop = false);
223     void StopIndicatorAnimation();
224     void StartIndicatorSpringAnimation(double start, double end);
225     void StopIndicatorSpringAnimation();
226     void StartZoomInAnimation(bool isMouseHover = false);
227     void StartZoomOutAnimation(bool isMouseHover = false);
228     void StartZoomInDotAnimation(int32_t index);
229     void StartZoomOutDotAnimation();
230     void StopZoomAnimation();
231     void StopZoomDotAnimation();
232     void StartDragRetractionAnimation(); // on handle drag end
233     void StopDragRetractionAnimation();
234     void FinishAllSwipeAnimation(bool useFinish = false, bool surfaceChanged = false);
235     bool IsZoomAnimationStopped();
236     bool IsZoomOutAnimationStopped();
237     bool IsZoomOutDotAnimationStopped();
238 
239     // indicator info update with animation
240     void UpdateIndicatorLayout();
241     void UpdateIndicatorOffset(int32_t fromIndex, int32_t toIndex, double value);
242     void UpdateIndicatorHeadPosition(double offset);
243     void UpdateIndicatorTailPosition(double offset, double switchOffset = 0.0);
244     void UpdateIndicatorPointPosition(double offset);
245     void UpdateMaskOpacity(double value);
246     void UpdateZoomValue(double value);
247     void UpdateZoomDotValue(double value);
248     void UpdateEdgeStretchRate(double value); // input 0.0 ~ 1.0 to real rate of high and witdh
249     void UpdatePressStatus(bool isPress);
250     void UpdateHoverStatus(bool isHover);
251     void UpdatePositionOnStretch(Offset& position, const SwiperIndicatorData& indicatorData);
252     void UpdateIndicatorSpringStatus(SpringStatus status);
253     SpringStatus GetIndicatorSpringStatus() const;
254     void ResetIndicatorSpringStatus();
255     void ResetIndicatorPosition();
256     void ResetHoverZoomDot();
257     void MarkIndicatorPosition(bool isZoomMax = true);
258     /* indicator animation end */
259 
260     // for lazy for each
SetBuildChildByIndex(BuildChildByIndex buildChildByIndex)261     void SetBuildChildByIndex(BuildChildByIndex buildChildByIndex)
262     {
263         buildChildByIndex_ = std::move(buildChildByIndex);
264     }
265 
SetDeleteChildByIndex(DeleteChildByIndex deleteChildByIndex)266     void SetDeleteChildByIndex(DeleteChildByIndex deleteChildByIndex)
267     {
268         deleteChildByIndex_ = std::move(deleteChildByIndex);
269     }
270     void AddChildByIndex(int32_t index, const RefPtr<RenderNode>& renderNode);
271     void RemoveChildByIndex(int32_t index);
272     void OnDataSourceUpdated(int32_t totalCount, int32_t startIndex);
273 
GetAutoPlay()274     bool GetAutoPlay() const
275     {
276         return autoPlay_;
277     }
278 
GetAutoPlayInterval()279     uint64_t GetAutoPlayInterval() const
280     {
281         return autoPlayInterval_;
282     }
283 
IsShowIndicator()284     bool IsShowIndicator() const
285     {
286         return showIndicator_;
287     }
288 
GetLoop()289     bool GetLoop() const
290     {
291         return loop_;
292     }
293 
GetDuration()294     double GetDuration() const
295     {
296         return duration_;
297     }
298 
IsVertical()299     bool IsVertical()
300     {
301         return axis_ == Axis::VERTICAL;
302     }
303 
GetCachedCount()304     int32_t GetCachedCount() const
305     {
306         return cachedCount_;
307     }
308 
GetDisplayCount()309     int32_t GetDisplayCount() const
310     {
311         return displayCount_;
312     }
GetDisplayMode()313     SwiperDisplayMode GetDisplayMode() const
314     {
315         return displayMode_;
316     }
317 
GetEdgeEffect()318     EdgeEffect GetEdgeEffect() const
319     {
320         return edgeEffect_;
321     }
322 
323     bool HandleMouseEvent(const MouseEvent& event) override;
324     bool RefuseUpdatePosition(int32_t index);
325     void OnPaintFinish() override;
326     std::string ProvideRestoreInfo() override;
327 protected:
328     struct IndicatorProperties final {
IndicatorPropertiesfinal329         IndicatorProperties(const Offset& normalPaddingStart, const Offset& normalPaddingEnd,
330             const Offset& selectedPaddingStart, const Offset& selectedPaddingEnd, const Offset& centerPadding,
331             uint32_t normalColor, uint32_t selectedColor, double normalPointRadius, double selectedPointRadius,
332             double indicatorPointPadding)
333             : normalPaddingStart(normalPaddingStart), normalPaddingEnd(normalPaddingEnd),
334               selectedPaddingStart(selectedPaddingStart), selectedPaddingEnd(selectedPaddingEnd),
335               centerPadding(centerPadding), normalColor(normalColor), selectedColor(selectedColor),
336               normalPointRadius(normalPointRadius), selectedPointRadius(selectedPointRadius),
337               indicatorPointPadding(indicatorPointPadding)
338         {}
339         IndicatorProperties(IndicatorProperties&& indicatorProperties) = default;
340         ~IndicatorProperties() = default;
341 
342         Offset normalPaddingStart;
343         Offset normalPaddingEnd;
344         Offset selectedPaddingStart;
345         Offset selectedPaddingEnd;
346         Offset centerPadding;
347         uint32_t normalColor;
348         uint32_t selectedColor;
349         double normalPointRadius;
350         double selectedPointRadius;
351         double indicatorPointPadding;
352     };
353     virtual void UpdateIndicator() = 0;
354     void OnHiddenChanged(bool hidden) override;
355     double GetValidEdgeLength(double swiperLength, double indicatorLength, const Dimension& edge) const;
356     void GetIndicatorCurrentRect(SwiperIndicatorData& indicatorData);
357     double GetIndicatorWidth(SwiperIndicatorData& indicatorData);
358     void LayoutIndicator(SwiperIndicatorData& indicatorData);
359     void InitDigitalIndicator(SwiperIndicatorData& indicatorData);
360     void LayoutDigitalIndicator(SwiperIndicatorData& indicatorData);
361     void UpdateIndicatorPosition(SwiperIndicatorData& indicatorData);
362     void UpdateIndicatorItem(SwiperIndicatorData& indicatorData);
363     void IndicatorSwipePrev();
364     void IndicatorSwipeNext();
365     bool MouseHoverTest(const Point& parentLocalPoint) override;
366     std::list<RefPtr<RenderNode>> GetPaintChildList();
367 
368     // swiper item
369     std::unordered_map<int32_t, RefPtr<RenderNode>> items_;
370     double scale_ = 0.0;
371     int32_t itemCount_ = 0;
372     double swiperWidth_ = 0.0;
373     double swiperHeight_ = 0.0;
374     int32_t currentIndex_ = 0;
375     int32_t targetIndex_ = 0;
376     int32_t outItemIndex_ = 0;
377     Axis axis_ = Axis::HORIZONTAL;
378     bool animationOpacity_ = true;
379     bool needReverse_ = false;
380     bool moveStatus_ = false;
381     bool show_ = true;
382     bool digitalIndicator_ = false;
383     bool onFocus_ = false;
384     double dragDelta_ = 0.0;
385     bool isPaintedFade_ = false;
386 
387     // swiper indicator
388     RefPtr<SwiperIndicator> indicator_;
389     SwiperIndicatorData swiperIndicatorData_;
390     Offset indicatorPosition_;
391     Offset indicatorZoomMaxPositionLT_; // left and top position when zoom max
392     Offset indicatorZoomMaxPositionRB_; // right and bottom position when zoom max
393     Offset indicatorZoomMinPositionLT_; // left and top position when zoom min
394     Offset indicatorZoomMinPositionRB_; // right and bottom position when zoom min
395     Rect indicatorRect_;
396     int32_t currentHoverIndex_ = -1;
397     int64_t startTimeStamp_ = 0;
398     int32_t fingerId_ = -1;
399     bool indicatorIsFocus_ = false;
400 
401     // indicator dynamic offset info used by canvas
402     double animationDirect_ = 1.0; // 1.0 or -1.0
403     double indicatorHeadOffset_ = 0.0; // [0.0, 1.0)
404     double indicatorTailOffset_ = 0.0; // [0.0, 1.0)
405     double indicatorPointOffset_ = 0.0; // [0.0, 1.0)
406     double indicatorSwitchTailOffset_ = 0.0; // [0.0, 1.0)
407     double opacityValue_ = 0.0;
408     double focusStretchMaxTime_ = 0.0; // the time of focus indicator stretch longest in range [0.0, 1.0]
409 
410     // indicator animation flag
411     bool isIndicatorAnimationStart_ = false;
412     bool isDragStart_ = false;
413     bool quickTurnItem_ = false; // quick turn swipe item
414     Color fadeColor_ = Color::GRAY;
415 
416 private:
417     // for handle drag event
418     void OnTouchTestHit(
419         const Offset& coordinateOffset, const TouchRestrict& touchRestrict, TouchTestResult& result) override;
420     void StartSpringMotion(double mainPosition, double mainVelocity,
421         const ExtentPair& extent, const ExtentPair& initExtent);
422     void HandleTouchDown(const TouchEventInfo& info);
423     void HandleTouchUp(const TouchEventInfo& info);
424     void HandleTouchMove(const TouchEventInfo& info);
425     void HandleTouchCancel(const TouchEventInfo& info);
426     void HandleClick(const ClickInfo& clickInfo);
427     void HandleRemoteMessage(const ClickInfo& clickInfo);
428     void HandleDragStart(const DragStartInfo& info);
429     void HandleDragUpdate(const DragUpdateInfo& info);
430     void HandleDragEnd(const DragEndInfo& info);
431 
432     void Initialize(const WeakPtr<PipelineContext>& context, bool catchMode);
433     void InitRecognizer(bool catchMode);
434     void InitDragRecognizer();
435     void InitRawDragRecognizer();
436     void InitAccessibilityEventListener();
437     void UpdateIndex(int32_t index);
438     void MoveItems(double dragVelocity);
RestoreAutoPlay()439     void RestoreAutoPlay()
440     {
441         if (!scheduler_) {
442             return;
443         }
444         if (IsDisabled()) {
445             return;
446         }
447         if (autoPlay_) {
448             bool playEnding = currentIndex_ >= itemCount_ - 1 && !loop_;
449             if (playEnding && scheduler_->IsActive()) {
450                 scheduler_->Stop();
451             } else {
452                 scheduler_->Start();
453             }
454         }
455     }
StopSwipeAnimation()456     void StopSwipeAnimation()
457     {
458         if (controller_ && !controller_->IsStopped()) {
459             // clear stop listener before stop, otherwise the previous swipe will be considered complete
460             controller_->ClearStopListeners();
461             controller_->Stop();
462             isIndicatorAnimationStart_ = false;
463         }
464     }
465 
FinishSwipeAnimation()466     void FinishSwipeAnimation()
467     {
468         if (controller_ && !controller_->IsStopped()) {
469             controller_->Finish();
470         }
471     }
472 
473     bool IsAnimatorStopped() const;
474 
475     void FireItemChangedEvent(bool changed) const;
476     void FireSwiperControllerFinishEvent();
477     void ResetCachedChildren();
478     void SetSwiperHidden(int32_t forwardNum, int32_t backNum);
479     void SetSwiperEffect(double dragOffset);
480     void SwipeTo(int32_t index, bool reverse);
481     void OnSurfaceChanged();
482     int32_t GetPrevIndex() const;
483     int32_t GetNextIndex() const;
484     int32_t GetPrevIndex(int32_t index) const;
485     int32_t GetNextIndex(int32_t index) const;
486     int32_t GetPrevIndexOnAnimation() const;
487     int32_t GetNextIndexOnAnimation() const;
488     int32_t GetIndex(int32_t index, bool leftOrTop) const;
489     void InitSwipeToAnimation(double start, double end);
490     void AddSwipeToTranslateListener(int32_t fromIndex, int32_t toIndex);
491     void AddSwipeToOpacityListener(int32_t fromIndex, int32_t toIndex);
492     void AddSwipeToIndicatorListener(int32_t fromIndex, int32_t toIndex);
493     double CalculateEndOffset(int32_t fromIndex, int32_t toIndex, bool reverse);
494     void DoSwipeToAnimation(int32_t fromIndex, int32_t toIndex, bool reverse);
495     void RedoSwipeToAnimation(int32_t toIndex, bool reverse);
496     void StopSwipeToAnimation();
497     void UpdateItemOpacity(uint8_t opacity, int32_t index, int32_t otherIndex);
498     void UpdateOneItemOpacity(uint8_t opacity, int32_t index);
499     void UpdateItemPosition(double offset, int32_t index, int32_t otherIndex);
500     void UpdateScrollPosition(double dragDelta);
501     void UpdateChildPosition(double offset, int32_t fromIndex, bool inLayout = false);
GetMainAxisOffset(double offset)502     Offset GetMainAxisOffset(double offset) const
503     {
504         double margin = (needReverse_ ? nextMargin_ : prevMargin_);
505         if (!loop_) {
506             if (nextIndex_ == 0) {
507                 margin = needReverse_ ? nextMargin_ + prevMargin_ : 0;
508             } else  if (nextIndex_ == itemCount_ - 1) {
509                 margin = needReverse_ ? 0 : nextMargin_ + prevMargin_;
510             }
511         }
512 
513         return axis_ == Axis::HORIZONTAL ? Offset(offset + margin, 0) : Offset(0, offset + margin);
514     }
515     // timer tick callback, duration is in millisecond.
516     void Tick(uint64_t duration);
517     bool SpringItems(const DragEndInfo& info);
518     void HandleRotationStart();
519     void HandleRotationUpdate(double delta);
520     void HandleRotationEnd();
521     void ResetRotationEndListener();
522 
523     void UpdateItemCount(int32_t itemCount);
524     void BuildLazyItems();
525     void LoadItems();
526     void LoadLazyItems(bool swipeToNext);
527     double CalculateFriction(double gamma);
528     void ClearItems(const RefPtr<Component>& lazyForEachComponent, int32_t index);
529     void ApplyRestoreInfo();
530     void ResetScrollOffset();
531     void FireAnimationStart();
532     void FireAnimationEnd();
533 
534     RefPtr<SwiperComponent> swiper_;
535 
536     RefPtr<RawRecognizer> rawRecognizer_;
537     RefPtr<ClickRecognizer> clickRecognizer_;
538     RefPtr<DragRecognizer> dragDetector_;
539     RefPtr<Animation<double>> translate_;
540     RefPtr<Animator> controller_;
541     RefPtr<Animator> swipeToController_;
542     RefPtr<ScrollMotion> scrollMotion_;
543     RefPtr<KeyframeAnimation<double>> curTranslateAnimation_;
544     RefPtr<KeyframeAnimation<double>> targetTranslateAnimation_;
545     RefPtr<KeyframeAnimation<uint8_t>> curOpacityAnimation_;
546     RefPtr<KeyframeAnimation<uint8_t>> targetOpacityAnimation_;
547 
548     bool isAnimationAlreadyAdded_ = false;
549     bool hasDragAction_ = false;
550     bool isSwipeToAnimationAdded_ = false;
551     std::function<void(const std::shared_ptr<BaseEventInfo>&)> changeEvent_;
552     std::function<void()> animationFinishEvent_;
553     std::function<void(const std::shared_ptr<BaseEventInfo>&)> animationStartEvent_;
554     std::function<void(const std::shared_ptr<BaseEventInfo>&)> animationEndEvent_;
555     std::function<void(const std::string&)> rotationEvent_;
556     std::function<void(const std::shared_ptr<ClickInfo>&)> clickEvent_;
557     std::function<void(const std::shared_ptr<ClickInfo>&)> remoteMessageEvent_;
558 
559     double duration_ = 0.0;
560     double prevItemOffset_ = 0.0;
561     double nextItemOffset_ = 0.0;
562     double scrollOffset_ = 0.0;
563     bool showIndicator_ = true;
564     bool autoPlay_ = false;
565     bool loop_ = true;
566     bool disableSwipe_ = false;
567     bool disableRotation_ = false;
568     bool catchMode_ = true;
569     bool needRestore_ = false;
570     Dimension itemSpace_;
571     int32_t index_ = 0;
572     int32_t swipeToIndex_ = -1;
573     MainSwiperSize mainSwiperSize_ = MainSwiperSize::MAX;
574     double prevMargin_ = 0.0;
575     double nextMargin_ = 0.0;
576     int32_t cachedCount_ = -1;
577     int32_t displayCount_ = 1;
578     SwiperDisplayMode displayMode_ = SwiperDisplayMode::STRETCH;
579     EdgeEffect edgeEffect_ = EdgeEffect::SPRING;
580 
581     // need timer for autoplay
582     RefPtr<Scheduler> scheduler_;
583     uint64_t elapsedTime_ = 0; // millisecond.
584     uint64_t autoPlayInterval_ = 0;
585     std::map<int32_t, std::function<void(const int32_t&)>> changeEndListeners_;
586 
587     // handle rotation event on watch
588     CancelableCallback<void()> rotationTimer_;
589     RotationStatus rotationStatus_ = RotationStatus::ROTATION_END;
590 
591     // indicator animation controller and indicator dynamic info.
592     RefPtr<SpringMotion> indicatorSpringMotion_;
593     RefPtr<Animation<double>> indicatorAnimation_;
594     RefPtr<Animation<double>> zoomInDotAnimation_;
595     RefPtr<Animation<double>> zoomOutDotAnimation_;
596     RefPtr<Animation<double>> zoomInAnimation_;
597     RefPtr<Animation<double>> zoomOutAnimation_;
598     RefPtr<Animation<double>> opacityInAnimation_;
599     RefPtr<Animation<double>> opacityOutAnimation_;
600     RefPtr<Animation<double>> dragRetractionAnimation_;
601     RefPtr<Animator> zoomInController_;
602     RefPtr<Animator> zoomOutController_;
603     RefPtr<Animator> zoomInDotController_;
604     RefPtr<Animator> zoomOutDotController_;
605     RefPtr<Animator> springController_;
606     RefPtr<Animator> fadeController_;
607     RefPtr<Animator> indicatorController_;
608     RefPtr<Animator> dragRetractionController_;
609     RefPtr<Vibrator> vibrator_ = nullptr;
610     SpringStatus indicatorSpringStatus_ = SpringStatus::SPRING_STOP;
611     TouchContentType touchContentType_ = TouchContentType::TOUCH_NONE;
612     double hotZoneMaxSize_ = 0.0;
613     double hotZoneMinSize_ = 0.0;
614     double hotZoneRealSize_ = 0.0;
615     double zoomValue_ = 0.0;
616     double zoomDotValue_ = 0.0;
617     double stretchRate_ = 0.0;
618     double widthStretchRate_ = 1.0;
619     double heightStretchRate_ = 1.0;
620     double dragBaseOffset_ = 0.0;
621     double dragMoveOffset_ = 0.0;
622     // for lazy load
623     BuildChildByIndex buildChildByIndex_;
624     DeleteChildByIndex deleteChildByIndex_;
625     int32_t cacheStart_ = 0;
626     int32_t cacheEnd_ = 0;
627     int32_t lazyLoadCacheSize_ = 5; // default lazy load cache number: 5
628     int32_t callbackId_ = 0;
629     double dragOffset_ = 0.0;
630     int32_t nextIndex_ = 0;
631 
632     RefPtr<Curve> curve_;
633     std::string curveRender_;
634     Color colors_;
635     Color selectedColors_;
636     Dimension swiperSize_;
637     Dimension swiperTop_;
638     Dimension swiperLeft_;
639     Dimension swiperBottom_;
640     Dimension swiperRight_;
641 };
642 
643 } // namespace OHOS::Ace
644 
645 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SWIPER_RENDER_SWIPER_H
646