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 476 void InitLongPressEvent(const RefPtr<GestureEventHub>& gestureHub); 477 void InitDragEvent(const RefPtr<GestureEventHub>& gestureHub); 478 void InitScrollableEvent( 479 const RefPtr<TabBarLayoutProperty>& layoutProperty, const RefPtr<GestureEventHub>& gestureHub); 480 void InitScrollable(const RefPtr<GestureEventHub>& gestureHub); 481 void InitTouch(const RefPtr<GestureEventHub>& gestureHub); 482 void InitHoverEvent(); 483 void InitMouseEvent(); 484 void SetSurfaceChangeCallback(); 485 486 void HandleMouseEvent(const MouseInfo& info); 487 void HandleHoverEvent(bool isHover); 488 void HandleHoverOnEvent(int32_t index); 489 void HandleMoveAway(int32_t index); 490 void InitOnKeyEvent(const RefPtr<FocusHub>& focusHub); 491 bool OnKeyEvent(const KeyEvent& event); 492 bool OnKeyEventWithoutClick(const KeyEvent& event); 493 bool OnKeyEventWithoutClick(const RefPtr<FrameNode>& host, const KeyEvent& event); 494 void HandleLongPressEvent(const GestureEvent& info); 495 void ShowDialogWithNode(int32_t index); 496 void CloseDialog(); 497 void InitLongPressAndDragEvent(); 498 void HandleClick(SourceType type, int32_t index); 499 void ClickTo(const RefPtr<FrameNode>& host, int32_t index); 500 void HandleTouchEvent(const TouchLocationInfo& info); 501 void HandleSubTabBarClick(const RefPtr<TabBarLayoutProperty>& layoutProperty, int32_t index); 502 void HandleBottomTabBarClick(int32_t selectedIndex, int32_t unselectedIndex); 503 void ChangeMask(int32_t index, float imageSize, const OffsetF& originalMaskOffset, float opacity, 504 float radiusRatio, bool isSelected); 505 void PlayMaskAnimation(float selectedImageSize, const OffsetF& originalSelectedMaskOffset, int32_t selectedIndex, 506 float unselectedImageSize, const OffsetF& originalUnselectedMaskOffset, int32_t unselectedIndex); 507 static void MaskAnimationFinish(const RefPtr<FrameNode>& host, int32_t selectedIndex, bool isSelected); 508 void GetBottomTabBarImageSizeAndOffset(const std::vector<int32_t>& selectedIndexes, 509 int32_t maskIndex, float& selectedImageSize, float& unselectedImageSize, OffsetF& originalSelectedMaskOffset, 510 OffsetF& originalUnselectedMaskOffset); 511 void UpdateBottomTabBarImageColor(const std::vector<int32_t>& selectedIndexes, int32_t maskIndex); 512 void UpdateSymbolApply(const RefPtr<NG::FrameNode>& symbolNode, RefPtr<TextLayoutProperty>& symbolProperty, 513 int32_t index, std::string type); 514 bool CheckSvg(int32_t index) const; 515 516 void HandleTouchDown(int32_t index); 517 void HandleTouchUp(int32_t index); 518 int32_t CalculateSelectedIndex(const Offset& info); 519 520 void PlayPressAnimation(int32_t index, const Color& pressColor, AnimationType animationType); 521 void PlayTabBarTranslateAnimation(AnimationOption option, float targetCurrentOffset); 522 void PlayIndicatorTranslateAnimation(AnimationOption option, RectF originalPaintRect, RectF targetPaintRect, 523 float targetOffset); 524 void StopTranslateAnimation(); 525 float CalculateTargetOffset(int32_t targetIndex); 526 void UpdateIndicatorCurrentOffset(float offset); 527 528 void GetInnerFocusPaintRect(RoundRect& paintRect); 529 void PaintFocusState(bool needMarkDirty = true); 530 void FocusIndexChange(int32_t index); 531 void UpdateGradientRegions(bool needMarkDirty = true); 532 533 float GetSpace(int32_t indicator); 534 float CalculateFrontChildrenMainSize(int32_t indicator); 535 float CalculateBackChildrenMainSize(int32_t indicator); 536 void SetEdgeEffect(const RefPtr<GestureEventHub>& gestureHub); 537 void SetEdgeEffectCallback(const RefPtr<ScrollEdgeEffect>& scrollEffect); 538 bool IsOutOfBoundary(); 539 void SetAccessibilityAction(); 540 void TabBarClickEvent(int32_t index) const; 541 void OnCustomContentTransition(int32_t fromIndex, int32_t toIndex); 542 void ApplyTurnPageRateToIndicator(float turnPageRate); 543 bool CheckSwiperDisable() const; 544 void SetSwiperCurve(const RefPtr<Curve>& curve) const; 545 void InitTurnPageRateEvent(); 546 void GetIndicatorStyle(IndicatorStyle& indicatorStyle, OffsetF& indicatorOffset); 547 void CalculateIndicatorStyle( 548 int32_t startIndex, int32_t nextIndex, IndicatorStyle& indicatorStyle, OffsetF& indicatorOffset); 549 Color GetTabBarBackgroundColor() const; 550 float GetLeftPadding() const; 551 void HandleBottomTabBarAnimation(int32_t index); 552 void UpdatePaintIndicator(int32_t indicator, bool needMarkDirty); 553 std::pair<float, float> GetOverScrollInfo(const SizeF& size); 554 void RemoveTabBarEventCallback(); 555 void AddTabBarEventCallback(); 556 void AddMaskItemClickEvent(); 557 bool ParseTabsIsRtl(); 558 bool IsValidIndex(int32_t index); 559 bool CanScroll() const; 560 int32_t GetLoopIndex(int32_t originalIndex) const; 561 RefPtr<SwiperPattern> GetSwiperPattern() const; 562 563 void StartShowTabBar(int32_t delay = 0); 564 void StopShowTabBar(); 565 void InitTabBarProperty(); 566 void UpdateTabBarHiddenRatio(float ratio); 567 void SetTabBarTranslate(const TranslateOptions& options); 568 void SetTabBarOpacity(float opacity); 569 570 RefPtr<NodeAnimatablePropertyFloat> showTabBarProperty_; 571 bool isTabBarShowing_ = false; 572 573 std::map<int32_t, RefPtr<ClickEvent>> clickEvents_; 574 RefPtr<LongPressEvent> longPressEvent_; 575 RefPtr<TouchEventImpl> touchEvent_; 576 RefPtr<ScrollableEvent> scrollableEvent_; 577 RefPtr<InputEvent> mouseEvent_; 578 RefPtr<InputEvent> hoverEvent_; 579 RefPtr<SwiperController> swiperController_; 580 RefPtr<ScrollEdgeEffect> scrollEffect_; 581 RefPtr<FrameNode> dialogNode_; 582 RefPtr<DragEvent> dragEvent_; 583 AnimationStartEventPtr animationStartEvent_; 584 AnimationEndEventPtr animationEndEvent_; 585 586 float bigScale_ = 0.0f; 587 float largeScale_ = 0.0f; 588 float maxScale_ = 0.0f; 589 int32_t indicator_ = 0; 590 int32_t focusIndicator_ = 0; 591 Axis axis_ = Axis::HORIZONTAL; 592 std::unordered_map<int32_t, bool> tabBarType_; 593 std::optional<int32_t> animationDuration_; 594 595 std::shared_ptr<AnimationUtils::Animation> tabbarIndicatorAnimation_; 596 std::shared_ptr<AnimationUtils::Animation> translateAnimation_; 597 std::shared_ptr<AnimationUtils::Animation> maskAnimation_; 598 599 bool indicatorAnimationIsRunning_ = false; 600 bool translateAnimationIsRunning_ = false; 601 602 bool isRTL_ = false; 603 604 bool touching_ = false; // whether the item is in touching 605 bool isHover_ = false; 606 bool isMaskAnimationByCreate_ = false; 607 bool isMaskAnimationExecuted_ = false; 608 bool tabContentWillChangeFlag_ = false; 609 std::optional<int32_t> imageColorOnIndex_; 610 std::optional<int32_t> touchingIndex_; 611 std::optional<int32_t> hoverIndex_; 612 std::optional<int32_t> moveIndex_; 613 TabBarStyle tabBarStyle_ = TabBarStyle::NOSTYLE; 614 float currentIndicatorOffset_ = 0.0f; 615 std::vector<SelectedMode> selectedModes_; 616 std::vector<IndicatorStyle> indicatorStyles_; 617 std::vector<TabBarStyle> tabBarStyles_; 618 std::unordered_map<int32_t, LabelStyle> labelStyles_; 619 std::vector<IconStyle> iconStyles_; 620 std::vector<TabBarSymbol> symbolArray_; 621 bool isFirstFocus_ = true; 622 bool isTouchingSwiper_ = false; 623 float indicatorStartPos_ = 0.0f; 624 float indicatorEndPos_ = 0.0f; 625 float turnPageRate_ = 0.0f; 626 int32_t swiperStartIndex_ = 0; 627 std::vector<BottomTabBarStyle> bottomTabBarStyles_; 628 BottomTabBarStyle bottomTabBarStyle_; 629 630 RefPtr<TabBarModifier> tabBarModifier_; 631 std::vector<bool> gradientRegions_ = {false, false, false, false}; 632 bool isAnimating_ = false; 633 bool changeByClick_ = false; 634 bool clickRepeat_ = false; 635 float scrollMargin_ = 0.0f; 636 bool isFirstLayout_ = true; 637 bool isExecuteBuilder_ = false; 638 std::optional<int32_t> animationTargetIndex_; 639 std::optional<int32_t> surfaceChangedCallbackId_; 640 std::optional<WindowSizeChangeReason> windowSizeChangeReason_; 641 std::pair<double, double> prevRootSize_; 642 643 std::optional<int32_t> jumpIndex_; 644 std::optional<int32_t> targetIndex_; 645 float currentDelta_ = 0.0f; 646 float currentOffset_ = 0.0f; 647 std::map<int32_t, ItemInfo> visibleItemPosition_; 648 bool canOverScroll_ = false; 649 ACE_DISALLOW_COPY_AND_MOVE(TabBarPattern); 650 }; 651 } // namespace OHOS::Ace::NG 652 653 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TABS_TAB_BAR_PATTERN_H 654