• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_pattern.h"
30 #include "core/components_ng/pattern/tabs/tab_bar_accessibility_property.h"
31 #include "core/components_ng/pattern/tabs/tab_bar_layout_algorithm.h"
32 #include "core/components_ng/pattern/tabs/tab_bar_layout_property.h"
33 #include "core/components_ng/pattern/tabs/tab_bar_paint_method.h"
34 #include "core/components_ng/pattern/tabs/tab_bar_paint_property.h"
35 #include "core/components_ng/pattern/tabs/tab_content_model.h"
36 #include "core/event/mouse_event.h"
37 #include "core/components_ng/pattern/tabs/tab_content_transition_proxy.h"
38 #include "frameworks/core/components_ng/event/focus_hub.h"
39 
40 namespace OHOS::Ace::NG {
41 class InspectorFilter;
42 class TextLayoutProperty;
43 
44 const auto TabBarPhysicalCurve = AceType::MakeRefPtr<InterpolatingSpring>(-1.0f, 1.0f, 228.0f, 30.f);
45 
46 using TabBarBuilderFunc = std::function<void()>;
47 class TabBarParam : public virtual Referenced {
48 public:
TabBarParam(const std::string & textParam,const std::string & iconParam,TabBarBuilderFunc && builderParam)49     TabBarParam(const std::string& textParam, const std::string& iconParam, TabBarBuilderFunc&& builderParam)
50         : text_(textParam), icon_(iconParam), builder_(std::move(builderParam)) {};
51 
GetIcon()52     const std::string& GetIcon() const
53     {
54         return icon_;
55     }
56 
SetIcon(const std::string & icon)57     void SetIcon(const std::string& icon)
58     {
59         icon_ = icon;
60     }
61 
GetText()62     const std::string& GetText() const
63     {
64         return text_;
65     }
66 
SetText(const std::string & text)67     void SetText(const std::string& text)
68     {
69         text_ = text;
70     }
71 
GetSymbol()72     const std::optional<TabBarSymbol>& GetSymbol() const
73     {
74         return symbol_;
75     }
76 
SetSymbol(const std::optional<TabBarSymbol> & symbol)77     void SetSymbol(const std::optional<TabBarSymbol>& symbol)
78     {
79         symbol_ = symbol;
80     }
81 
HasBuilder()82     bool HasBuilder() const
83     {
84         return builder_ != nullptr;
85     }
86 
SetBuilder(TabBarBuilderFunc && builderParam)87     void SetBuilder(TabBarBuilderFunc&& builderParam)
88     {
89         builder_ = std::move(builderParam);
90     }
91 
ExecuteBuilder()92     void ExecuteBuilder() const
93     {
94         if (builder_ != nullptr) {
95             builder_();
96         }
97     }
98 
SetTabBarStyle(TabBarStyle tabBarStyle)99     void SetTabBarStyle(TabBarStyle tabBarStyle)
100     {
101         tabBarStyle_ = tabBarStyle;
102     }
103 
GetTabBarStyle()104     TabBarStyle GetTabBarStyle() const
105     {
106         return tabBarStyle_;
107     }
108 
SetCustomNode(FrameNode * node)109     void SetCustomNode(FrameNode* node)
110     {
111         node_ = node;
112     }
113 
HasContent()114     bool HasContent() const
115     {
116         return !content_.Invalid();
117     }
118 
SetContent(const WeakPtr<NG::UINode> & content)119     void SetContent(const WeakPtr<NG::UINode>& content)
120     {
121         content_ = content;
122     }
123 
GetContent()124     const WeakPtr<NG::UINode>& GetContent() const
125     {
126         return content_;
127     }
128 
129 private:
130     std::string text_;
131     std::string icon_;
132     std::optional<TabBarSymbol> symbol_;
133     TabBarBuilderFunc builder_;
134     WeakPtr<NG::UINode> content_ = nullptr;
135     TabBarStyle tabBarStyle_ = TabBarStyle::NOSTYLE;
136     FrameNode* node_ = nullptr;
137 };
138 
139 enum class AnimationType {
140     PRESS = 0,
141     HOVER,
142     HOVERTOPRESS,
143 };
144 
145 enum class TabBarState {
146     SHOW = 0,
147     HIDE
148 };
149 
150 enum class TabBarParamType {
151     NORMAL = 0,
152     CUSTOM_BUILDER,
153     COMPONENT_CONTENT,
154     SUB_COMPONENT_CONTENT
155 };
156 
157 class TabBarPattern : public Pattern {
158     DECLARE_ACE_TYPE(TabBarPattern, Pattern);
159 
160 public:
161     TabBarPattern();
162     ~TabBarPattern() override;
163 
IsAtomicNode()164     bool IsAtomicNode() const override
165     {
166         return false;
167     }
168 
CreateLayoutProperty()169     RefPtr<LayoutProperty> CreateLayoutProperty() override
170     {
171         return MakeRefPtr<TabBarLayoutProperty>();
172     }
173 
CreateLayoutAlgorithm()174     RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override
175     {
176         auto layoutAlgorithm = MakeRefPtr<TabBarLayoutAlgorithm>();
177         layoutAlgorithm->SetCurrentDelta(currentDelta_);
178         layoutAlgorithm->SetTabBarStyle(tabBarStyle_);
179         if (targetIndex_) {
180             layoutAlgorithm->SetTargetIndex(targetIndex_);
181         } else if (jumpIndex_) {
182             layoutAlgorithm->SetJumpIndex(jumpIndex_);
183         } else if (focusIndex_) {
184             layoutAlgorithm->SetFocusIndex(focusIndex_);
185         }
186         layoutAlgorithm->SetVisibleItemPosition(visibleItemPosition_);
187         layoutAlgorithm->SetCanOverScroll(canOverScroll_);
188         return layoutAlgorithm;
189     }
190 
CreatePaintProperty()191     RefPtr<PaintProperty> CreatePaintProperty() override
192     {
193         return MakeRefPtr<TabBarPaintProperty>();
194     }
195 
196     RefPtr<NodePaintMethod> CreateNodePaintMethod() override;
197 
CreateAccessibilityProperty()198     RefPtr<AccessibilityProperty> CreateAccessibilityProperty() override
199     {
200         return MakeRefPtr<TabBarAccessibilityProperty>();
201     }
202 
GetFocusPattern()203     FocusPattern GetFocusPattern() const override
204     {
205         return { FocusType::SCOPE, true };
206     }
207 
208     void SetController(const RefPtr<SwiperController>& controller);
209 
SetIndicator(int32_t indicator)210     void SetIndicator(int32_t indicator)
211     {
212         indicator_ = indicator;
213     }
214 
215     void OnTabBarIndexChange(int32_t index);
216 
217     void UpdateCurrentOffset(float offset);
218 
219     void UpdateIndicator(int32_t indicator);
220 
221     void UpdateTextColorAndFontWeight(int32_t indicator);
222 
223     void UpdateImageColor(int32_t indicator);
224 
225     void UpdateSymbolStats(int32_t index, int32_t preIndex);
226     void AdjustSymbolStats(int32_t index);
227 
228     void UpdateSymbolEffect(int32_t index);
229 
230     void UpdateSubTabBoard(int32_t index);
231 
232     void GetColumnId(int32_t& selectedColumnId, int32_t& focusedColumnId, int32_t indicator) const;
233 
234     SelectedMode GetSelectedMode() const;
235 
AddTabBarItemType(int32_t tabBarItemId,TabBarParamType type)236     void AddTabBarItemType(int32_t tabBarItemId, TabBarParamType type)
237     {
238         tabBarType_.emplace(std::make_pair(tabBarItemId, type));
239     }
240 
241     bool IsContainsBuilder();
242 
SetAnimationDuration(int32_t animationDuration)243     void SetAnimationDuration(int32_t animationDuration)
244     {
245         animationDuration_ = animationDuration;
246     }
247 
SetTouching(bool isTouching)248     void SetTouching(bool isTouching)
249     {
250         touching_ = isTouching;
251     }
252 
IsTouching()253     bool IsTouching() const
254     {
255         return touching_;
256     }
257 
SetTabBarStyle(TabBarStyle tabBarStyle)258     void SetTabBarStyle(TabBarStyle tabBarStyle)
259     {
260         tabBarStyle_ = tabBarStyle;
261         InitLongPressAndDragEvent();
262     }
263 
GetTabBarStyle()264     TabBarStyle GetTabBarStyle() const
265     {
266         return tabBarStyle_;
267     }
268 
269     void TriggerTranslateAnimation(int32_t currentIndex, int32_t targetIndex);
270 
271     RectF GetOriginalPaintRect(int32_t currentIndex);
272 
273     void HandleBottomTabBarChange(int32_t index);
274 
GetChangeByClick()275     bool GetChangeByClick() const
276     {
277         return changeByClick_;
278     }
279 
SetChangeByClick(bool changeByClick)280     void SetChangeByClick(bool changeByClick)
281     {
282         changeByClick_ = changeByClick;
283     }
284 
GetClickRepeat()285     bool GetClickRepeat() const
286     {
287         return clickRepeat_;
288     }
289 
SetClickRepeat(bool clickRepeat)290     void SetClickRepeat(bool clickRepeat)
291     {
292         clickRepeat_ = clickRepeat;
293     }
294 
295     void SetSelectedMode(SelectedMode selectedMode, uint32_t position, bool newTabBar = false)
296     {
297         if (selectedModes_.size() <= position) {
298             selectedModes_.emplace_back(selectedMode);
299             return;
300         }
301 
302         if (newTabBar) {
303             selectedModes_.insert(selectedModes_.begin() + position, selectedMode);
304             return;
305         }
306 
307         selectedModes_[position] = selectedMode;
308     }
309 
310     void SetIndicatorStyle(const IndicatorStyle& indicatorStyle, uint32_t position, bool newTabBar = false)
311     {
312         if (indicatorStyles_.size() <= position) {
313             indicatorStyles_.emplace_back(indicatorStyle);
314             return;
315         }
316 
317         if (newTabBar) {
318             indicatorStyles_.insert(indicatorStyles_.begin() + position, indicatorStyle);
319             return;
320         }
321 
322         indicatorStyles_[position] = indicatorStyle;
323     }
324 
325     void SetTabBarStyle(TabBarStyle tabBarStyle, uint32_t position, bool newTabBar = false)
326     {
327         if (tabBarStyles_.size() <= position) {
328             tabBarStyles_.emplace_back(tabBarStyle);
329             return;
330         }
331 
332         if (newTabBar) {
333             tabBarStyles_.insert(tabBarStyles_.begin() + position, tabBarStyle);
334             return;
335         }
336 
337         tabBarStyles_[position] = tabBarStyle;
338     }
339 
340     void SetBottomTabBarStyle(const BottomTabBarStyle& bottomTabBarStyle, uint32_t position, bool newTabBar = false)
341     {
342         if (bottomTabBarStyles_.size() <= position) {
343             bottomTabBarStyles_.emplace_back(bottomTabBarStyle);
344             return;
345         }
346 
347         if (newTabBar) {
348             bottomTabBarStyles_.insert(bottomTabBarStyles_.begin() + position, bottomTabBarStyle);
349             return;
350         }
351 
352         bottomTabBarStyles_[position] = bottomTabBarStyle;
353     }
354 
SetLabelStyle(int32_t tabBarItemId,const LabelStyle & labelStyle)355     void SetLabelStyle(int32_t tabBarItemId, const LabelStyle& labelStyle)
356     {
357         labelStyles_[tabBarItemId] = labelStyle;
358     }
359 
360     void SetIconStyle(const IconStyle& iconStyle, uint32_t position, bool newTabBar = false)
361     {
362         if (iconStyles_.size() <= position) {
363             iconStyles_.emplace_back(iconStyle);
364             return;
365         }
366 
367         if (newTabBar) {
368             iconStyles_.insert(iconStyles_.begin() + position, iconStyle);
369             return;
370         }
371 
372         iconStyles_[position] = iconStyle;
373     }
374 
GetIconStyle()375     std::vector<IconStyle> GetIconStyle()
376     {
377         return iconStyles_;
378     }
379 
380     void SetSymbol(const TabBarSymbol& symbol, uint32_t position, bool newTabBar = false)
381     {
382         if (symbolArray_.size() <= position) {
383             symbolArray_.emplace_back(symbol);
384             return;
385         }
386 
387         if (newTabBar) {
388             symbolArray_.insert(symbolArray_.begin() + position, symbol);
389             return;
390         }
391 
392         symbolArray_[position] = symbol;
393     }
394 
GetSymbol()395     std::vector<TabBarSymbol> GetSymbol()
396     {
397         return symbolArray_;
398     }
399 
IsMaskAnimationByCreate()400     bool IsMaskAnimationByCreate()
401     {
402         return isMaskAnimationByCreate_;
403     }
404 
SetMaskAnimationByCreate(bool isMaskAnimationByCreate)405     void SetMaskAnimationByCreate(bool isMaskAnimationByCreate)
406     {
407         isMaskAnimationByCreate_ = isMaskAnimationByCreate;
408     }
409 
IsMaskAnimationExecuted()410     bool IsMaskAnimationExecuted()
411     {
412         return isMaskAnimationExecuted_;
413     }
414 
SetMaskAnimationExecuted(bool isMaskAnimationExecuted)415     void SetMaskAnimationExecuted(bool isMaskAnimationExecuted)
416     {
417         isMaskAnimationExecuted_ = isMaskAnimationExecuted;
418     }
419 
SetImageColorOnIndex(int32_t index)420     void SetImageColorOnIndex(int32_t index)
421     {
422         imageColorOnIndex_ = index;
423     }
424 
GetImageColorOnIndex()425     std::optional<int32_t> GetImageColorOnIndex()
426     {
427         return imageColorOnIndex_;
428     }
429 
GetIndicator()430     int32_t GetIndicator()
431     {
432         return indicator_;
433     }
434 
435     bool IsAtTop() const;
436 
437     bool IsAtBottom() const;
438     std::string ProvideRestoreInfo() override;
439     void OnRestoreInfo(const std::string& restoreInfo) override;
440 
441     void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
442     void FromJson(const std::unique_ptr<JsonValue>& json) override;
443 
ResetIndicatorAnimationState()444     void ResetIndicatorAnimationState()
445     {
446         isAnimating_ = false;
447         animationTargetIndex_.reset();
448     }
449 
GetTouchingSwiper()450     bool GetTouchingSwiper() const
451     {
452         return isTouchingSwiper_;
453     }
454 
GetTabBarStyle(uint32_t position)455     TabBarStyle GetTabBarStyle(uint32_t position) const
456     {
457         if (position < 0 || position >= tabBarStyles_.size()) {
458             return TabBarStyle::NOSTYLE;
459         }
460         return tabBarStyles_[position];
461     }
462 
GetBottomTabBarStyle(uint32_t position)463     const BottomTabBarStyle& GetBottomTabBarStyle(uint32_t position) const
464     {
465         if (position < 0 || position >= bottomTabBarStyles_.size()) {
466             return bottomTabBarStyle_;
467         }
468         return bottomTabBarStyles_[position];
469     }
470 
GetBottomTabLabelStyle(int32_t tabBarItemId)471     LabelStyle GetBottomTabLabelStyle(int32_t tabBarItemId) const
472     {
473         auto iter = labelStyles_.find(tabBarItemId);
474         if (iter == labelStyles_.end()) {
475             LabelStyle labelStyle{};
476             return labelStyle;
477         }
478         return iter->second;
479     }
480 
481     void DumpAdvanceInfo() override;
482     void DumpAdvanceInfo(std::unique_ptr<JsonValue>& json) override;
483     void SetRegionInfo(std::unique_ptr<JsonValue>& json);
484 
GetAnimationDuration()485     std::optional<int32_t> GetAnimationDuration()
486     {
487         return animationDuration_;
488     }
489 
GetTabContentWillChangeFlag()490     bool GetTabContentWillChangeFlag()
491     {
492         return tabContentWillChangeFlag_;
493     }
494 
ResetTabContentWillChangeFlag()495     void ResetTabContentWillChangeFlag()
496     {
497         tabContentWillChangeFlag_ = false;
498     }
499 
500     void UpdateAnimationDuration();
501 
HasSurfaceChangedCallback()502     bool HasSurfaceChangedCallback()
503     {
504         return surfaceChangedCallbackId_.has_value();
505     }
506 
UpdateSurfaceChangedCallbackId(int32_t id)507     void UpdateSurfaceChangedCallbackId(int32_t id)
508     {
509         surfaceChangedCallbackId_ = id;
510     }
511 
512     bool ContentWillChange(int32_t comingIndex);
513     bool ContentWillChange(int32_t currentIndex, int32_t comingIndex);
514 
515     void AddTabBarItemClickAndTouchEvent(const RefPtr<FrameNode>& tabBarItem);
516     void AddTabBarItemCallBack(const RefPtr<FrameNode>& tabBarItem);
517 
RemoveTabBarItemInfo(int32_t tabBarItemId)518     void RemoveTabBarItemInfo(int32_t tabBarItemId)
519     {
520         clickEvents_.erase(tabBarItemId);
521         touchEvents_.erase(tabBarItemId);
522         labelStyles_.erase(tabBarItemId);
523     }
524 
SetIsExecuteBuilder(bool isExecuteBuilder)525     void SetIsExecuteBuilder(bool isExecuteBuilder)
526     {
527         isExecuteBuilder_ = isExecuteBuilder;
528     }
529 
530     void AddTabBarItemId(int32_t tabBarItemId, uint32_t position, bool newTabBar = false)
531     {
532         if (tabBarItemIds_.size() <= position) {
533             tabBarItemIds_.emplace_back(tabBarItemId);
534             return;
535         }
536 
537         if (newTabBar) {
538             tabBarItemIds_.insert(tabBarItemIds_.begin() + position, tabBarItemId);
539             return;
540         }
541 
542         tabBarItemIds_[position] = tabBarItemId;
543     }
544 
IsNewTabBar(int32_t tabBarItemId)545     bool IsNewTabBar(int32_t tabBarItemId) const
546     {
547         return std::find(tabBarItemIds_.begin(), tabBarItemIds_.end(), tabBarItemId) == tabBarItemIds_.end();
548     }
549 
550     void AdjustTabBarInfo();
551     bool CanScroll() const;
552 
SetTabBarFocusActive(bool isFocusActive)553     void SetTabBarFocusActive(bool isFocusActive)
554     {
555         isTabBarFocusActive_ = isFocusActive;
556     }
557 
SetFocusIndicator(int32_t focusIndicator)558     void SetFocusIndicator(int32_t focusIndicator)
559     {
560         focusIndicator_ = focusIndicator;
561     }
562 
563     void ResetOnForceMeasure(int32_t index);
564 
565 private:
566     void OnModifyDone() override;
567     void OnAttachToFrameNode() override;
568     void OnDetachFromFrameNode(FrameNode* node) override;
569     void BeforeCreateLayoutWrapper() override;
570     void SetTabBarFinishCallback();
571     void InitSurfaceChangedCallback();
572     bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
573     bool CustomizeExpandSafeArea() override;
574     void OnSyncGeometryNode(const DirtySwapConfig& config) override;
575 
576     void InitLongPressEvent(const RefPtr<GestureEventHub>& gestureHub);
577     void InitDragEvent(const RefPtr<GestureEventHub>& gestureHub);
578     void InitScrollableEvent(
579         const RefPtr<TabBarLayoutProperty>& layoutProperty, const RefPtr<GestureEventHub>& gestureHub);
580     void InitScrollable(const RefPtr<GestureEventHub>& gestureHub);
581     bool InsideTabBarRegion(const TouchLocationInfo& locationInfo);
582     void InitHoverEvent();
583     void InitMouseEvent();
584     void SetSurfaceChangeCallback();
585 
586     void HandleMouseEvent(const MouseInfo& info);
587     void HandleHoverEvent(bool isHover);
588     void HandleHoverOnEvent(int32_t index);
589     void HandleMoveAway(int32_t index);
590     RefPtr<FocusHub> GetCurrentFocusNode();
591     ScopeFocusAlgorithm GetScopeFocusAlgorithm() override;
592     WeakPtr<FocusHub> GetNextFocusNode(FocusStep step);
593     std::optional<int32_t> GetNextFocusIndicator(int32_t indicator, FocusStep step);
594     void HandleLongPressEvent(const GestureEvent& info);
595     void ShowDialogWithNode(int32_t index);
596     void CloseDialog();
597     void InitLongPressAndDragEvent();
598     void HandleClick(SourceType type, int32_t index);
599     void ClickTo(const RefPtr<FrameNode>& host, int32_t index);
600     void HandleTouchEvent(TouchType touchType, int32_t index);
601     void HandleSubTabBarClick(const RefPtr<TabBarLayoutProperty>& layoutProperty, int32_t index);
602     void HandleBottomTabBarClick(int32_t selectedIndex, int32_t unselectedIndex);
603     void ChangeMask(int32_t index, float imageSize, const OffsetF& originalMaskOffset, float opacity,
604         float radiusRatio, bool isSelected);
605     void PlayMaskAnimation(float selectedImageSize, const OffsetF& originalSelectedMaskOffset, int32_t selectedIndex,
606         float unselectedImageSize, const OffsetF& originalUnselectedMaskOffset, int32_t unselectedIndex);
607     static void MaskAnimationFinish(const RefPtr<FrameNode>& host, int32_t selectedIndex, bool isSelected);
608     void GetBottomTabBarImageSizeAndOffset(const std::vector<int32_t>& selectedIndexes,
609         int32_t maskIndex, float& selectedImageSize, float& unselectedImageSize, OffsetF& originalSelectedMaskOffset,
610         OffsetF& originalUnselectedMaskOffset);
611     void UpdateBottomTabBarImageColor(const std::vector<int32_t>& selectedIndexes, int32_t maskIndex);
612     void UpdateSymbolApply(const RefPtr<NG::FrameNode>& symbolNode, RefPtr<TextLayoutProperty>& symbolProperty,
613         int32_t index, std::string type);
614     bool CheckSvg(int32_t index) const;
615 
616     void HandleTouchDown(int32_t index);
617     void HandleTouchUp(int32_t index);
618     int32_t CalculateSelectedIndex(const Offset& info);
619 
620     void PlayPressAnimation(int32_t index, const Color& pressColor, AnimationType animationType);
621     void PlayTabBarTranslateAnimation(AnimationOption option, float targetCurrentOffset);
622     void PlayIndicatorTranslateAnimation(AnimationOption option, RectF originalPaintRect, RectF targetPaintRect,
623         float targetOffset);
624     void CreateIndicatorTranslateProperty(const RefPtr<FrameNode>& host, const std::string& propertyName);
625     void StopTranslateAnimation(bool isImmediately = false);
626     float CalculateTargetOffset(int32_t targetIndex);
627     void UpdateIndicatorCurrentOffset(float offset);
628 
629     void GetInnerFocusPaintRect(RoundRect& paintRect);
630     void PaintFocusState(bool needMarkDirty = true);
631     void FocusIndexChange(int32_t index);
632     void FocusCurrentOffset(int32_t index);
633     void UpdateGradientRegions(bool needMarkDirty = true);
634 
635     float GetSpace(int32_t indicator);
636     float CalculateFrontChildrenMainSize(int32_t indicator);
637     float CalculateBackChildrenMainSize(int32_t indicator);
638     void SetEdgeEffect(const RefPtr<GestureEventHub>& gestureHub);
639     void SetEdgeEffectCallback(const RefPtr<ScrollEdgeEffect>& scrollEffect);
640     bool IsOutOfBoundary();
641     void SetAccessibilityAction();
642     void TabBarClickEvent(int32_t index) const;
643     void OnCustomContentTransition(int32_t fromIndex, int32_t toIndex);
644     void ApplyTurnPageRateToIndicator(float turnPageRate);
645     bool CheckSwiperDisable() const;
646     void SetSwiperCurve(const RefPtr<Curve>& curve) const;
647     void InitTurnPageRateEvent();
648     void GetIndicatorStyle(IndicatorStyle& indicatorStyle, OffsetF& indicatorOffset, RectF& tabBarItemRect);
649     void CalculateIndicatorStyle(
650         int32_t startIndex, int32_t nextIndex, IndicatorStyle& indicatorStyle, OffsetF& indicatorOffset);
651     Color GetTabBarBackgroundColor() const;
652     SizeF GetContentSize() const;
653     float GetLeftPadding() const;
654     void HandleBottomTabBarAnimation(int32_t index);
655     void UpdatePaintIndicator(int32_t indicator, bool needMarkDirty);
656     std::pair<float, float> GetOverScrollInfo(const SizeF& size);
657     void RemoveTabBarEventCallback();
658     void AddTabBarEventCallback();
659     void AddMaskItemClickEvent();
660     bool IsValidIndex(int32_t index);
661     int32_t GetLoopIndex(int32_t originalIndex) const;
662     RefPtr<SwiperPattern> GetSwiperPattern() const;
663     void UpdateBackBlurStyle(const RefPtr<TabTheme>& tabTheme);
664     void UpdateChildrenClipEdge();
665 
666     void StartShowTabBar(int32_t delay = 0);
667     void StartShowTabBarImmediately();
668     void CancelShowTabBar();
669     void StartHideTabBar();
670     void StopHideTabBar();
671     void InitTabBarProperty();
672     void UpdateTabBarHiddenOffset(float offset);
673     void SetTabBarTranslate(const TranslateOptions& options);
674     void SetTabBarOpacity(float opacity);
675 
676     void AddIsFocusActiveUpdateEvent();
677     void RemoveIsFocusActiveUpdateEvent();
678     void HandleFocusEvent();
679     void HandleBlurEvent();
680     bool HandleKeyEvent(const KeyEvent& event);
681     void InitTabBarProperties(const RefPtr<TabTheme>& tabTheme);
682     void InitFocusEvent();
683     const Color& GetSubTabBarHoverColor(int32_t index) const;
684     void UpdateFocusToSelectedNode(bool isFocusActive);
685     void UpdateFocusTabBarPageState();
686     void UpdateSubTabBarItemStyles(const RefPtr<FrameNode>& columnNode, int32_t focusedColumnId,
687         int32_t selectedColumnId, OHOS::Ace::Axis axis, int32_t index);
688     void UpdateSelectedTextColor(const RefPtr<TabTheme>& tabTheme, OHOS::Ace::Axis axis,
689         RefPtr<TextLayoutProperty> textLayoutProperty, int32_t index, int32_t columnId);
690     void UpdateSubTabFocusedTextColor(const RefPtr<TabTheme>& tabTheme, int32_t isFocusedItem,
691         RefPtr<TextLayoutProperty> textLayoutProperty, int32_t index, bool isSelected);
692 
693     template<typename T>
694     void UpdateTabBarInfo(std::vector<T>& info, const std::set<int32_t>& retainedIndex);
695 
696     RefPtr<NodeAnimatablePropertyFloat> tabBarProperty_;
697     CancelableCallback<void()> showTabBarTask_;
698     bool isTabBarShowing_ = false;
699     bool isTabBarHiding_ = false;
700     TabBarState tabBarState_ = TabBarState::SHOW;
701 
702     std::map<int32_t, RefPtr<ClickEvent>> clickEvents_;
703     std::map<int32_t, RefPtr<TouchEventImpl>> touchEvents_;
704     RefPtr<LongPressEvent> longPressEvent_;
705     RefPtr<ScrollableEvent> scrollableEvent_;
706     RefPtr<InputEvent> mouseEvent_;
707     RefPtr<InputEvent> hoverEvent_;
708     RefPtr<SwiperController> swiperController_;
709     RefPtr<ScrollEdgeEffect> scrollEffect_;
710     RefPtr<FrameNode> dialogNode_;
711     RefPtr<DragEvent> dragEvent_;
712     AnimationStartEventPtr animationStartEvent_;
713     AnimationEndEventPtr animationEndEvent_;
714 
715     float bigScale_ = 0.0f;
716     float largeScale_ = 0.0f;
717     float maxScale_ = 0.0f;
718     int32_t indicator_ = 0;
719     int32_t focusIndicator_ = 0;
720     int32_t accessibilityFocusIndicator_ = 0;
721     Axis axis_ = Axis::HORIZONTAL;
722     std::unordered_map<int32_t, TabBarParamType> tabBarType_;
723     std::optional<int32_t> animationDuration_;
724 
725     std::shared_ptr<AnimationUtils::Animation> tabbarIndicatorAnimation_;
726     std::shared_ptr<AnimationUtils::Animation> translateAnimation_;
727     std::shared_ptr<AnimationUtils::Animation> maskAnimation_;
728 
729     bool indicatorAnimationIsRunning_ = false;
730     bool translateAnimationIsRunning_ = false;
731 
732     bool isRTL_ = false;
733     bool clipEdge_ = true;
734 
735     bool touching_ = false; // whether the item is in touching
736     bool isHover_ = false;
737     bool isMaskAnimationByCreate_ = false;
738     bool isMaskAnimationExecuted_ = false;
739     bool tabContentWillChangeFlag_ = false;
740     std::optional<int32_t> imageColorOnIndex_;
741     std::set<int32_t> touchingIndex_;
742     std::optional<int32_t> hoverIndex_;
743     std::optional<int32_t> moveIndex_;
744     TabBarStyle tabBarStyle_ = TabBarStyle::NOSTYLE;
745     float currentIndicatorOffset_ = 0.0f;
746     std::vector<SelectedMode> selectedModes_;
747     std::vector<IndicatorStyle> indicatorStyles_;
748     std::vector<TabBarStyle> tabBarStyles_;
749     std::vector<int32_t> tabBarItemIds_;
750     std::unordered_map<int32_t, LabelStyle> labelStyles_;
751     std::vector<IconStyle> iconStyles_;
752     std::vector<TabBarSymbol> symbolArray_;
753     bool isTouchingSwiper_ = false;
754     float indicatorStartPos_ = 0.0f;
755     float indicatorEndPos_ = 0.0f;
756     float turnPageRate_ = 0.0f;
757     int32_t swiperStartIndex_ = 0;
758     std::vector<BottomTabBarStyle> bottomTabBarStyles_;
759     BottomTabBarStyle bottomTabBarStyle_;
760 
761     RefPtr<TabBarModifier> tabBarModifier_;
762     std::vector<bool> gradientRegions_ = {false, false, false, false};
763     bool isAnimating_ = false;
764     bool changeByClick_ = false;
765     bool clickRepeat_ = false;
766     float scrollMargin_ = 0.0f;
767     bool isFirstLayout_ = true;
768     bool isExecuteBuilder_ = false;
769     std::optional<int32_t> animationTargetIndex_;
770     std::optional<int32_t> surfaceChangedCallbackId_;
771     std::optional<WindowSizeChangeReason> windowSizeChangeReason_;
772     std::pair<double, double> prevRootSize_;
773 
774     std::optional<int32_t> jumpIndex_;
775     std::optional<int32_t> targetIndex_;
776     std::optional<int32_t> focusIndex_;
777     float currentDelta_ = 0.0f;
778     float currentOffset_ = 0.0f;
779     float barGridMargin_ = 0.0f;
780     std::map<int32_t, ItemInfo> visibleItemPosition_;
781     bool canOverScroll_ = false;
782     bool isTabBarFocusActive_ = false;
783     std::function<void(bool)> isFocusActiveUpdateEvent_;
784     Color tabBarItemDefaultBgColor_ = Color::TRANSPARENT;
785     Color tabBarItemFocusBgColor_ = Color::TRANSPARENT;
786     Color tabBarItemHoverColor_ = Color::TRANSPARENT;
787     ACE_DISALLOW_COPY_AND_MOVE(TabBarPattern);
788 };
789 } // namespace OHOS::Ace::NG
790 
791 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TABS_TAB_BAR_PATTERN_H
792