1  /*
2   * Copyright (c) 2022-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  #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TABS_TAB_BAR_PATTERN_H
17  #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TABS_TAB_BAR_PATTERN_H
18  
19  #include <optional>
20  #include <unordered_map>
21  
22  #include "base/geometry/axis.h"
23  #include "base/memory/referenced.h"
24  #include "core/components/common/layout/constants.h"
25  #include "core/components/swiper/swiper_controller.h"
26  #include "core/components/tab_bar/tab_theme.h"
27  #include "core/components_ng/event/event_hub.h"
28  #include "core/components_ng/pattern/pattern.h"
29  #include "core/components_ng/pattern/swiper/swiper_model.h"
30  #include "core/components_ng/pattern/swiper/swiper_pattern.h"
31  #include "core/components_ng/pattern/tabs/tab_bar_accessibility_property.h"
32  #include "core/components_ng/pattern/tabs/tab_bar_layout_algorithm.h"
33  #include "core/components_ng/pattern/tabs/tab_bar_layout_property.h"
34  #include "core/components_ng/pattern/tabs/tab_bar_paint_method.h"
35  #include "core/components_ng/pattern/tabs/tab_bar_paint_property.h"
36  #include "core/components_ng/pattern/tabs/tab_content_model.h"
37  #include "core/event/mouse_event.h"
38  #include "core/components_ng/pattern/tabs/tab_content_transition_proxy.h"
39  #include "frameworks/core/components/focus_animation/focus_animation_theme.h"
40  #include "frameworks/core/components_ng/event/focus_hub.h"
41  
42  namespace OHOS::Ace::NG {
43  class InspectorFilter;
44  
45  const auto TabBarPhysicalCurve = AceType::MakeRefPtr<InterpolatingSpring>(-1.0f, 1.0f, 228.0f, 30.f);
46  
47  using TabBarBuilderFunc = std::function<void()>;
48  class TabBarParam : public virtual Referenced {
49  public:
TabBarParam(const std::string & textParam,const std::string & iconParam,TabBarBuilderFunc && builderParam)50      TabBarParam(const std::string& textParam, const std::string& iconParam, TabBarBuilderFunc&& builderParam)
51          : text_(textParam), icon_(iconParam), builder_(std::move(builderParam)) {};
52  
GetIcon()53      const std::string& GetIcon() const
54      {
55          return icon_;
56      }
57  
SetIcon(const std::string & icon)58      void SetIcon(const std::string& icon)
59      {
60          icon_ = icon;
61      }
62  
GetText()63      const std::string& GetText() const
64      {
65          return text_;
66      }
67  
SetText(const std::string & text)68      void SetText(const std::string& text)
69      {
70          text_ = text;
71      }
72  
GetSymbol()73      const std::optional<TabBarSymbol>& GetSymbol() const
74      {
75          return symbol_;
76      }
77  
SetSymbol(const std::optional<TabBarSymbol> & symbol)78      void SetSymbol(const std::optional<TabBarSymbol>& symbol)
79      {
80          symbol_ = symbol;
81      }
82  
HasBuilder()83      bool HasBuilder() const
84      {
85          return builder_ != nullptr;
86      }
87  
SetBuilder(TabBarBuilderFunc && builderParam)88      void SetBuilder(TabBarBuilderFunc&& builderParam)
89      {
90          builder_ = std::move(builderParam);
91      }
92  
ExecuteBuilder()93      void ExecuteBuilder() const
94      {
95          if (builder_ != nullptr) {
96              builder_();
97          }
98      }
99  
SetTabBarStyle(TabBarStyle tabBarStyle)100      void SetTabBarStyle(TabBarStyle tabBarStyle)
101      {
102          tabBarStyle_ = tabBarStyle;
103      }
104  
GetTabBarStyle()105      TabBarStyle GetTabBarStyle() const
106      {
107          return tabBarStyle_;
108      }
109  
SetCustomNode(FrameNode * node)110      void SetCustomNode(FrameNode* node)
111      {
112          node_ = node;
113      }
114  
115  private:
116      std::string text_;
117      std::string icon_;
118      std::optional<TabBarSymbol> symbol_;
119      TabBarBuilderFunc builder_;
120      TabBarStyle tabBarStyle_ = TabBarStyle::NOSTYLE;
121      FrameNode* node_ = nullptr;
122  };
123  
124  enum class AnimationType {
125      PRESS = 0,
126      HOVER,
127      HOVERTOPRESS,
128  };
129  
130  class TabBarPattern : public Pattern {
131      DECLARE_ACE_TYPE(TabBarPattern, Pattern);
132  
133  public:
134      explicit TabBarPattern(const RefPtr<SwiperController>& swiperController);
135      ~TabBarPattern() override = default;
136  
IsAtomicNode()137      bool IsAtomicNode() const override
138      {
139          return false;
140      }
141  
CreateLayoutProperty()142      RefPtr<LayoutProperty> CreateLayoutProperty() override
143      {
144          return MakeRefPtr<TabBarLayoutProperty>();
145      }
146  
CreateLayoutAlgorithm()147      RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override
148      {
149          auto layoutAlgorithm = MakeRefPtr<TabBarLayoutAlgorithm>();
150          layoutAlgorithm->SetCurrentDelta(currentDelta_);
151          layoutAlgorithm->SetTabBarStyle(tabBarStyle_);
152          if (targetIndex_) {
153              layoutAlgorithm->SetTargetIndex(targetIndex_);
154          } else if (jumpIndex_) {
155              layoutAlgorithm->SetJumpIndex(jumpIndex_);
156          }
157          layoutAlgorithm->SetVisibleItemPosition(visibleItemPosition_);
158          layoutAlgorithm->SetCanOverScroll(canOverScroll_);
159          return layoutAlgorithm;
160      }
161  
CreatePaintProperty()162      RefPtr<PaintProperty> CreatePaintProperty() override
163      {
164          return MakeRefPtr<TabBarPaintProperty>();
165      }
166  
167      RefPtr<NodePaintMethod> CreateNodePaintMethod() override;
168  
CreateAccessibilityProperty()169      RefPtr<AccessibilityProperty> CreateAccessibilityProperty() override
170      {
171          return MakeRefPtr<TabBarAccessibilityProperty>();
172      }
173  
GetFocusPattern()174      FocusPattern GetFocusPattern() const override
175      {
176          FocusPaintParam focusPaintParams;
177          auto pipeline = PipelineBase::GetCurrentContext();
178          CHECK_NULL_RETURN(pipeline, FocusPattern());
179          auto focusTheme = pipeline->GetTheme<FocusAnimationTheme>();
180          CHECK_NULL_RETURN(focusTheme, FocusPattern());
181          auto tabTheme = pipeline->GetTheme<TabTheme>();
182          CHECK_NULL_RETURN(tabTheme, FocusPattern());
183          focusPaintParams.SetPaintWidth(tabTheme->GetActiveIndicatorWidth());
184          focusPaintParams.SetPaintColor(focusTheme->GetColor());
185          return { FocusType::NODE, true, FocusStyleType::CUSTOM_REGION, focusPaintParams };
186      }
187  
SetIndicator(int32_t indicator)188      void SetIndicator(int32_t indicator)
189      {
190          indicator_ = indicator;
191      }
192  
193      void OnTabBarIndexChange(int32_t index);
194  
195      void UpdateCurrentOffset(float offset);
196  
197      void UpdateIndicator(int32_t indicator);
198  
199      void UpdateTextColorAndFontWeight(int32_t indicator);
200  
201      void UpdateImageColor(int32_t indicator);
202  
203      void UpdateSymbolStats(int32_t index, int32_t preIndex);
204  
205      void UpdateSymbolEffect(int32_t index);
206  
207      void UpdateSubTabBoard(int32_t index);
208  
209      SelectedMode GetSelectedMode() const;
210  
AddTabBarItemType(int32_t tabBarItemId,bool isBuilder)211      void AddTabBarItemType(int32_t tabBarItemId, bool isBuilder)
212      {
213          tabBarType_.emplace(std::make_pair(tabBarItemId, isBuilder));
214      }
215  
216      bool IsContainsBuilder();
217  
SetAnimationDuration(int32_t animationDuration)218      void SetAnimationDuration(int32_t animationDuration)
219      {
220          animationDuration_ = animationDuration;
221      }
222  
SetTouching(bool isTouching)223      void SetTouching(bool isTouching)
224      {
225          touching_ = isTouching;
226      }
227  
IsTouching()228      bool IsTouching() const
229      {
230          return touching_;
231      }
232  
SetTabBarStyle(TabBarStyle tabBarStyle)233      void SetTabBarStyle(TabBarStyle tabBarStyle)
234      {
235          tabBarStyle_ = tabBarStyle;
236          InitLongPressAndDragEvent();
237      }
238  
GetTabBarStyle()239      TabBarStyle GetTabBarStyle() const
240      {
241          return tabBarStyle_;
242      }
243  
244      void TriggerTranslateAnimation(int32_t currentIndex, int32_t targetIndex);
245  
246      void HandleBottomTabBarChange(int32_t index);
247  
GetChangeByClick()248      bool GetChangeByClick() const
249      {
250          return changeByClick_;
251      }
252  
SetChangeByClick(bool changeByClick)253      void SetChangeByClick(bool changeByClick)
254      {
255          changeByClick_ = changeByClick;
256      }
257  
GetClickRepeat()258      bool GetClickRepeat() const
259      {
260          return clickRepeat_;
261      }
262  
SetClickRepeat(bool clickRepeat)263      void SetClickRepeat(bool clickRepeat)
264      {
265          clickRepeat_ = clickRepeat;
266      }
267  
SetSelectedMode(SelectedMode selectedMode,uint32_t position)268      void SetSelectedMode(SelectedMode selectedMode, uint32_t position)
269      {
270          if (selectedModes_.size() <= position) {
271              selectedModes_.emplace_back(selectedMode);
272          } else {
273              selectedModes_[position] = selectedMode;
274          }
275      }
276  
SetIndicatorStyle(const IndicatorStyle & indicatorStyle,uint32_t position)277      void SetIndicatorStyle(const IndicatorStyle& indicatorStyle, uint32_t position)
278      {
279          if (indicatorStyles_.size() <= position) {
280              indicatorStyles_.emplace_back(indicatorStyle);
281          } else {
282              indicatorStyles_[position] = indicatorStyle;
283          }
284      }
285  
SetTabBarStyle(TabBarStyle tabBarStyle,uint32_t position)286      void SetTabBarStyle(TabBarStyle tabBarStyle, uint32_t position)
287      {
288          if (tabBarStyles_.size() <= position) {
289              tabBarStyles_.emplace_back(tabBarStyle);
290          } else {
291              tabBarStyles_[position] = tabBarStyle;
292          }
293      }
294  
SetBottomTabBarStyle(const BottomTabBarStyle & bottomTabBarStyle,uint32_t position)295      void SetBottomTabBarStyle(const BottomTabBarStyle& bottomTabBarStyle, uint32_t position)
296      {
297          if (bottomTabBarStyles_.size() <= position) {
298              bottomTabBarStyles_.emplace_back(bottomTabBarStyle);
299          } else {
300              bottomTabBarStyles_[position] = bottomTabBarStyle;
301          }
302      }
303  
SetLabelStyle(int32_t tabBarItemId,const LabelStyle & labelStyle)304      void SetLabelStyle(int32_t tabBarItemId, const LabelStyle& labelStyle)
305      {
306          labelStyles_[tabBarItemId] = labelStyle;
307      }
308  
SetIconStyle(const IconStyle & iconStyle,uint32_t position)309      void SetIconStyle(const IconStyle& iconStyle, uint32_t position)
310      {
311          if (iconStyles_.size() <= position) {
312              iconStyles_.emplace_back(iconStyle);
313          } else {
314              iconStyles_[position] = iconStyle;
315          }
316      }
317  
GetIconStyle()318      std::vector<IconStyle> GetIconStyle()
319      {
320          return iconStyles_;
321      }
322  
SetSymbol(const TabBarSymbol & symbol,uint32_t position)323      void SetSymbol(const TabBarSymbol& symbol, uint32_t position)
324      {
325          if (symbolArray_.size() <= position) {
326              symbolArray_.emplace_back(symbol);
327          } else {
328              symbolArray_[position] = symbol;
329          }
330      }
331  
GetSymbol()332      std::vector<TabBarSymbol> GetSymbol()
333      {
334          return symbolArray_;
335      }
336  
IsMaskAnimationByCreate()337      bool IsMaskAnimationByCreate()
338      {
339          return isMaskAnimationByCreate_;
340      }
341  
SetMaskAnimationByCreate(bool isMaskAnimationByCreate)342      void SetMaskAnimationByCreate(bool isMaskAnimationByCreate)
343      {
344          isMaskAnimationByCreate_ = isMaskAnimationByCreate;
345      }
346  
IsMaskAnimationExecuted()347      bool IsMaskAnimationExecuted()
348      {
349          return isMaskAnimationExecuted_;
350      }
351  
SetMaskAnimationExecuted(bool isMaskAnimationExecuted)352      void SetMaskAnimationExecuted(bool isMaskAnimationExecuted)
353      {
354          isMaskAnimationExecuted_ = isMaskAnimationExecuted;
355      }
356  
SetImageColorOnIndex(int32_t index)357      void SetImageColorOnIndex(int32_t index)
358      {
359          imageColorOnIndex_ = index;
360      }
361  
GetImageColorOnIndex()362      std::optional<int32_t> GetImageColorOnIndex()
363      {
364          return imageColorOnIndex_;
365      }
366  
GetIndicator()367      int32_t GetIndicator()
368      {
369          return indicator_;
370      }
371  
372      bool IsAtTop() const;
373  
374      bool IsAtBottom() const;
375      std::string ProvideRestoreInfo() override;
376      void OnRestoreInfo(const std::string& restoreInfo) override;
377  
378      void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
379      void FromJson(const std::unique_ptr<JsonValue>& json) override;
380  
SetFirstFocus(bool isFirstFocus)381      void SetFirstFocus(bool isFirstFocus)
382      {
383          isFirstFocus_ = isFirstFocus;
384      }
385  
ResetIndicatorAnimationState()386      void ResetIndicatorAnimationState()
387      {
388          isAnimating_ = false;
389          animationTargetIndex_.reset();
390      }
391  
GetTouchingSwiper()392      bool GetTouchingSwiper() const
393      {
394          return isTouchingSwiper_;
395      }
396  
GetTabBarStyle(uint32_t position)397      TabBarStyle GetTabBarStyle(uint32_t position) const
398      {
399          if (position < 0 || position >= tabBarStyles_.size()) {
400              return TabBarStyle::NOSTYLE;
401          }
402          return tabBarStyles_[position];
403      }
404  
GetBottomTabBarStyle(uint32_t position)405      const BottomTabBarStyle& GetBottomTabBarStyle(uint32_t position) const
406      {
407          if (position < 0 || position >= bottomTabBarStyles_.size()) {
408              return bottomTabBarStyle_;
409          }
410          return bottomTabBarStyles_[position];
411      }
412  
GetBottomTabLabelStyle(int32_t tabBarItemId)413      LabelStyle GetBottomTabLabelStyle(int32_t tabBarItemId) const
414      {
415          auto iter = labelStyles_.find(tabBarItemId);
416          if (iter == labelStyles_.end()) {
417              LabelStyle labelStyle{};
418              return labelStyle;
419          }
420          return iter->second;
421      }
422  
423      void DumpAdvanceInfo() override;
424  
GetAnimationDuration()425      std::optional<int32_t> GetAnimationDuration()
426      {
427          return animationDuration_;
428      }
429  
GetTabContentWillChangeFlag()430      bool GetTabContentWillChangeFlag()
431      {
432          return tabContentWillChangeFlag_;
433      }
434  
ResetTabContentWillChangeFlag()435      void ResetTabContentWillChangeFlag()
436      {
437          tabContentWillChangeFlag_ = false;
438      }
439  
440      void UpdateAnimationDuration();
441  
HasSurfaceChangedCallback()442      bool HasSurfaceChangedCallback()
443      {
444          return surfaceChangedCallbackId_.has_value();
445      }
446  
UpdateSurfaceChangedCallbackId(int32_t id)447      void UpdateSurfaceChangedCallbackId(int32_t id)
448      {
449          surfaceChangedCallbackId_ = id;
450      }
451  
452      bool ContentWillChange(int32_t comingIndex);
453      bool ContentWillChange(int32_t currentIndex, int32_t comingIndex);
454  
455      void AddTabBarItemClickEvent(const RefPtr<FrameNode>& tabBarItem);
456  
RemoveTabBarItemInfo(int32_t tabBarItemId)457      void RemoveTabBarItemInfo(int32_t tabBarItemId)
458      {
459          clickEvents_.erase(tabBarItemId);
460          labelStyles_.erase(tabBarItemId);
461      }
462  
SetIsExecuteBuilder(bool isExecuteBuilder)463      void SetIsExecuteBuilder(bool isExecuteBuilder)
464      {
465          isExecuteBuilder_ = isExecuteBuilder;
466      }
467  
468  private:
469      void OnModifyDone() override;
470      void OnAttachToFrameNode() override;
471      void OnDetachFromFrameNode(FrameNode* node) override;
472      void BeforeCreateLayoutWrapper() override;
473      void InitSurfaceChangedCallback();
474      bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
475      bool CustomizeExpandSafeArea() override;
476      void OnSyncGeometryNode(const DirtySwapConfig& config) override;
477  
478      void InitLongPressEvent(const RefPtr<GestureEventHub>& gestureHub);
479      void InitDragEvent(const RefPtr<GestureEventHub>& gestureHub);
480      void InitScrollableEvent(
481          const RefPtr<TabBarLayoutProperty>& layoutProperty, const RefPtr<GestureEventHub>& gestureHub);
482      void InitScrollable(const RefPtr<GestureEventHub>& gestureHub);
483      void InitTouch(const RefPtr<GestureEventHub>& gestureHub);
484      void InitHoverEvent();
485      void InitMouseEvent();
486      void SetSurfaceChangeCallback();
487  
488      void HandleMouseEvent(const MouseInfo& info);
489      void HandleHoverEvent(bool isHover);
490      void HandleHoverOnEvent(int32_t index);
491      void HandleMoveAway(int32_t index);
492      void InitOnKeyEvent(const RefPtr<FocusHub>& focusHub);
493      bool OnKeyEvent(const KeyEvent& event);
494      bool OnKeyEventWithoutClick(const KeyEvent& event);
495      bool OnKeyEventWithoutClick(const RefPtr<FrameNode>& host, const KeyEvent& event);
496      void HandleLongPressEvent(const GestureEvent& info);
497      void ShowDialogWithNode(int32_t index);
498      void CloseDialog();
499      void InitLongPressAndDragEvent();
500      void HandleClick(SourceType type, int32_t index);
501      void ClickTo(const RefPtr<FrameNode>& host, int32_t index);
502      void HandleTouchEvent(const TouchLocationInfo& info);
503      void HandleSubTabBarClick(const RefPtr<TabBarLayoutProperty>& layoutProperty, int32_t index);
504      void HandleBottomTabBarClick(int32_t selectedIndex, int32_t unselectedIndex);
505      void ChangeMask(int32_t index, float imageSize, const OffsetF& originalMaskOffset, float opacity,
506          float radiusRatio, bool isSelected);
507      void PlayMaskAnimation(float selectedImageSize, const OffsetF& originalSelectedMaskOffset, int32_t selectedIndex,
508          float unselectedImageSize, const OffsetF& originalUnselectedMaskOffset, int32_t unselectedIndex);
509      static void MaskAnimationFinish(const RefPtr<FrameNode>& host, int32_t selectedIndex, bool isSelected);
510      void GetBottomTabBarImageSizeAndOffset(const std::vector<int32_t>& selectedIndexes,
511          int32_t maskIndex, float& selectedImageSize, float& unselectedImageSize, OffsetF& originalSelectedMaskOffset,
512          OffsetF& originalUnselectedMaskOffset);
513      void UpdateBottomTabBarImageColor(const std::vector<int32_t>& selectedIndexes, int32_t maskIndex);
514      void UpdateSymbolApply(const RefPtr<NG::FrameNode>& symbolNode, RefPtr<TextLayoutProperty>& symbolProperty,
515          int32_t index, std::string type);
516      bool CheckSvg(int32_t index) const;
517  
518      void HandleTouchDown(int32_t index);
519      void HandleTouchUp(int32_t index);
520      int32_t CalculateSelectedIndex(const Offset& info);
521  
522      void PlayPressAnimation(int32_t index, const Color& pressColor, AnimationType animationType);
523      void PlayTabBarTranslateAnimation(AnimationOption option, float targetCurrentOffset);
524      void PlayIndicatorTranslateAnimation(AnimationOption option, RectF originalPaintRect, RectF targetPaintRect,
525          float targetOffset);
526      void StopTranslateAnimation();
527      float CalculateTargetOffset(int32_t targetIndex);
528      void UpdateIndicatorCurrentOffset(float offset);
529  
530      void GetInnerFocusPaintRect(RoundRect& paintRect);
531      void PaintFocusState(bool needMarkDirty = true);
532      void FocusIndexChange(int32_t index);
533      void UpdateGradientRegions(bool needMarkDirty = true);
534  
535      float GetSpace(int32_t indicator);
536      float CalculateFrontChildrenMainSize(int32_t indicator);
537      float CalculateBackChildrenMainSize(int32_t indicator);
538      void SetEdgeEffect(const RefPtr<GestureEventHub>& gestureHub);
539      void SetEdgeEffectCallback(const RefPtr<ScrollEdgeEffect>& scrollEffect);
540      bool IsOutOfBoundary();
541      void SetAccessibilityAction();
542      void TabBarClickEvent(int32_t index) const;
543      void OnCustomContentTransition(int32_t fromIndex, int32_t toIndex);
544      void ApplyTurnPageRateToIndicator(float turnPageRate);
545      bool CheckSwiperDisable() const;
546      void SetSwiperCurve(const RefPtr<Curve>& curve) const;
547      void InitTurnPageRateEvent();
548      void GetIndicatorStyle(IndicatorStyle& indicatorStyle, OffsetF& indicatorOffset);
549      void CalculateIndicatorStyle(
550          int32_t startIndex, int32_t nextIndex, IndicatorStyle& indicatorStyle, OffsetF& indicatorOffset);
551      Color GetTabBarBackgroundColor() const;
552      float GetLeftPadding() const;
553      void HandleBottomTabBarAnimation(int32_t index);
554      void UpdatePaintIndicator(int32_t indicator, bool needMarkDirty);
555      std::pair<float, float> GetOverScrollInfo(const SizeF& size);
556      void RemoveTabBarEventCallback();
557      void AddTabBarEventCallback();
558      void AddMaskItemClickEvent();
559      bool ParseTabsIsRtl();
560      bool IsValidIndex(int32_t index);
561      bool CanScroll() const;
562      int32_t GetLoopIndex(int32_t originalIndex) const;
563      RefPtr<SwiperPattern> GetSwiperPattern() const;
564  
565      void StartShowTabBar(int32_t delay = 0);
566      void StopShowTabBar();
567      void InitTabBarProperty();
568      void UpdateTabBarHiddenRatio(float ratio);
569      void SetTabBarTranslate(const TranslateOptions& options);
570      void SetTabBarOpacity(float opacity);
571  
572      RefPtr<NodeAnimatablePropertyFloat> showTabBarProperty_;
573      bool isTabBarShowing_ = false;
574  
575      std::map<int32_t, RefPtr<ClickEvent>> clickEvents_;
576      RefPtr<LongPressEvent> longPressEvent_;
577      RefPtr<TouchEventImpl> touchEvent_;
578      RefPtr<ScrollableEvent> scrollableEvent_;
579      RefPtr<InputEvent> mouseEvent_;
580      RefPtr<InputEvent> hoverEvent_;
581      RefPtr<SwiperController> swiperController_;
582      RefPtr<ScrollEdgeEffect> scrollEffect_;
583      RefPtr<FrameNode> dialogNode_;
584      RefPtr<DragEvent> dragEvent_;
585      AnimationStartEventPtr animationStartEvent_;
586      AnimationEndEventPtr animationEndEvent_;
587  
588      float bigScale_ = 0.0f;
589      float largeScale_ = 0.0f;
590      float maxScale_ = 0.0f;
591      int32_t indicator_ = 0;
592      int32_t focusIndicator_ = 0;
593      Axis axis_ = Axis::HORIZONTAL;
594      std::unordered_map<int32_t, bool> tabBarType_;
595      std::optional<int32_t> animationDuration_;
596  
597      std::shared_ptr<AnimationUtils::Animation> tabbarIndicatorAnimation_;
598      std::shared_ptr<AnimationUtils::Animation> translateAnimation_;
599      std::shared_ptr<AnimationUtils::Animation> maskAnimation_;
600  
601      bool indicatorAnimationIsRunning_ = false;
602      bool translateAnimationIsRunning_ = false;
603  
604      bool isRTL_ = false;
605  
606      bool touching_ = false; // whether the item is in touching
607      bool isHover_ = false;
608      bool isMaskAnimationByCreate_ = false;
609      bool isMaskAnimationExecuted_ = false;
610      bool tabContentWillChangeFlag_ = false;
611      std::optional<int32_t> imageColorOnIndex_;
612      std::optional<int32_t> touchingIndex_;
613      std::optional<int32_t> hoverIndex_;
614      std::optional<int32_t> moveIndex_;
615      TabBarStyle tabBarStyle_ = TabBarStyle::NOSTYLE;
616      float currentIndicatorOffset_ = 0.0f;
617      std::vector<SelectedMode> selectedModes_;
618      std::vector<IndicatorStyle> indicatorStyles_;
619      std::vector<TabBarStyle> tabBarStyles_;
620      std::unordered_map<int32_t, LabelStyle> labelStyles_;
621      std::vector<IconStyle> iconStyles_;
622      std::vector<TabBarSymbol> symbolArray_;
623      bool isFirstFocus_ = true;
624      bool isTouchingSwiper_ = false;
625      float indicatorStartPos_ = 0.0f;
626      float indicatorEndPos_ = 0.0f;
627      float turnPageRate_ = 0.0f;
628      int32_t swiperStartIndex_ = 0;
629      std::vector<BottomTabBarStyle> bottomTabBarStyles_;
630      BottomTabBarStyle bottomTabBarStyle_;
631  
632      RefPtr<TabBarModifier> tabBarModifier_;
633      std::vector<bool> gradientRegions_ = {false, false, false, false};
634      bool isAnimating_ = false;
635      bool changeByClick_ = false;
636      bool clickRepeat_ = false;
637      float scrollMargin_ = 0.0f;
638      bool isFirstLayout_ = true;
639      bool isExecuteBuilder_ = false;
640      std::optional<int32_t> animationTargetIndex_;
641      std::optional<int32_t> surfaceChangedCallbackId_;
642      std::optional<WindowSizeChangeReason> windowSizeChangeReason_;
643      std::pair<double, double> prevRootSize_;
644  
645      std::optional<int32_t> jumpIndex_;
646      std::optional<int32_t> targetIndex_;
647      float currentDelta_ = 0.0f;
648      float currentOffset_ = 0.0f;
649      std::map<int32_t, ItemInfo> visibleItemPosition_;
650      bool canOverScroll_ = false;
651      ACE_DISALLOW_COPY_AND_MOVE(TabBarPattern);
652  };
653  } // namespace OHOS::Ace::NG
654  
655  #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TABS_TAB_BAR_PATTERN_H
656