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 enum class TabBarParamType { 131 NORMAL = 0, 132 CUSTOM_BUILDER, 133 COMPONENT_CONTENT 134 }; 135 136 class TabBarPattern : public Pattern { 137 DECLARE_ACE_TYPE(TabBarPattern, Pattern); 138 139 public: 140 explicit TabBarPattern(const RefPtr<SwiperController>& swiperController); 141 ~TabBarPattern() override = default; 142 IsAtomicNode()143 bool IsAtomicNode() const override 144 { 145 return false; 146 } 147 CreateLayoutProperty()148 RefPtr<LayoutProperty> CreateLayoutProperty() override 149 { 150 return MakeRefPtr<TabBarLayoutProperty>(); 151 } 152 CreateLayoutAlgorithm()153 RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override 154 { 155 auto layoutAlgorithm = MakeRefPtr<TabBarLayoutAlgorithm>(); 156 layoutAlgorithm->SetCurrentDelta(currentDelta_); 157 layoutAlgorithm->SetTabBarStyle(tabBarStyle_); 158 if (targetIndex_) { 159 layoutAlgorithm->SetTargetIndex(targetIndex_); 160 } else if (jumpIndex_) { 161 layoutAlgorithm->SetJumpIndex(jumpIndex_); 162 } else if (focusIndex_) { 163 layoutAlgorithm->SetFocusIndex(focusIndex_); 164 } 165 layoutAlgorithm->SetVisibleItemPosition(visibleItemPosition_); 166 layoutAlgorithm->SetCanOverScroll(canOverScroll_); 167 return layoutAlgorithm; 168 } 169 CreatePaintProperty()170 RefPtr<PaintProperty> CreatePaintProperty() override 171 { 172 return MakeRefPtr<TabBarPaintProperty>(); 173 } 174 175 RefPtr<NodePaintMethod> CreateNodePaintMethod() override; 176 CreateAccessibilityProperty()177 RefPtr<AccessibilityProperty> CreateAccessibilityProperty() override 178 { 179 return MakeRefPtr<TabBarAccessibilityProperty>(); 180 } 181 GetFocusPattern()182 FocusPattern GetFocusPattern() const override 183 { 184 return { FocusType::SCOPE, true }; 185 } 186 SetIndicator(int32_t indicator)187 void SetIndicator(int32_t indicator) 188 { 189 indicator_ = indicator; 190 } 191 192 void OnTabBarIndexChange(int32_t index); 193 194 void UpdateCurrentOffset(float offset); 195 196 void UpdateIndicator(int32_t indicator); 197 198 void UpdateTextColorAndFontWeight(int32_t indicator); 199 200 void UpdateImageColor(int32_t indicator); 201 202 void UpdateSymbolStats(int32_t index, int32_t preIndex); 203 void AdjustSymbolStats(int32_t index); 204 205 void UpdateSymbolEffect(int32_t index); 206 207 void UpdateSubTabBoard(int32_t index); 208 209 SelectedMode GetSelectedMode() const; 210 AddTabBarItemType(int32_t tabBarItemId,TabBarParamType type)211 void AddTabBarItemType(int32_t tabBarItemId, TabBarParamType type) 212 { 213 tabBarType_.emplace(std::make_pair(tabBarItemId, type)); 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 RectF GetOriginalPaintRect(int32_t currentIndex); 247 248 void HandleBottomTabBarChange(int32_t index); 249 GetChangeByClick()250 bool GetChangeByClick() const 251 { 252 return changeByClick_; 253 } 254 SetChangeByClick(bool changeByClick)255 void SetChangeByClick(bool changeByClick) 256 { 257 changeByClick_ = changeByClick; 258 } 259 GetClickRepeat()260 bool GetClickRepeat() const 261 { 262 return clickRepeat_; 263 } 264 SetClickRepeat(bool clickRepeat)265 void SetClickRepeat(bool clickRepeat) 266 { 267 clickRepeat_ = clickRepeat; 268 } 269 SetSelectedMode(SelectedMode selectedMode,uint32_t position)270 void SetSelectedMode(SelectedMode selectedMode, uint32_t position) 271 { 272 if (selectedModes_.size() <= position) { 273 selectedModes_.emplace_back(selectedMode); 274 } else { 275 selectedModes_[position] = selectedMode; 276 } 277 } 278 SetIndicatorStyle(const IndicatorStyle & indicatorStyle,uint32_t position)279 void SetIndicatorStyle(const IndicatorStyle& indicatorStyle, uint32_t position) 280 { 281 if (indicatorStyles_.size() <= position) { 282 indicatorStyles_.emplace_back(indicatorStyle); 283 } else { 284 indicatorStyles_[position] = indicatorStyle; 285 } 286 } 287 SetTabBarStyle(TabBarStyle tabBarStyle,uint32_t position)288 void SetTabBarStyle(TabBarStyle tabBarStyle, uint32_t position) 289 { 290 if (tabBarStyles_.size() <= position) { 291 tabBarStyles_.emplace_back(tabBarStyle); 292 } else { 293 tabBarStyles_[position] = tabBarStyle; 294 } 295 } 296 SetBottomTabBarStyle(const BottomTabBarStyle & bottomTabBarStyle,uint32_t position)297 void SetBottomTabBarStyle(const BottomTabBarStyle& bottomTabBarStyle, uint32_t position) 298 { 299 if (bottomTabBarStyles_.size() <= position) { 300 bottomTabBarStyles_.emplace_back(bottomTabBarStyle); 301 } else { 302 bottomTabBarStyles_[position] = bottomTabBarStyle; 303 } 304 } 305 SetLabelStyle(int32_t tabBarItemId,const LabelStyle & labelStyle)306 void SetLabelStyle(int32_t tabBarItemId, const LabelStyle& labelStyle) 307 { 308 labelStyles_[tabBarItemId] = labelStyle; 309 } 310 SetIconStyle(const IconStyle & iconStyle,uint32_t position)311 void SetIconStyle(const IconStyle& iconStyle, uint32_t position) 312 { 313 if (iconStyles_.size() <= position) { 314 iconStyles_.emplace_back(iconStyle); 315 } else { 316 iconStyles_[position] = iconStyle; 317 } 318 } 319 GetIconStyle()320 std::vector<IconStyle> GetIconStyle() 321 { 322 return iconStyles_; 323 } 324 SetSymbol(const TabBarSymbol & symbol,uint32_t position)325 void SetSymbol(const TabBarSymbol& symbol, uint32_t position) 326 { 327 if (symbolArray_.size() <= position) { 328 symbolArray_.emplace_back(symbol); 329 } else { 330 symbolArray_[position] = symbol; 331 } 332 } 333 GetSymbol()334 std::vector<TabBarSymbol> GetSymbol() 335 { 336 return symbolArray_; 337 } 338 IsMaskAnimationByCreate()339 bool IsMaskAnimationByCreate() 340 { 341 return isMaskAnimationByCreate_; 342 } 343 SetMaskAnimationByCreate(bool isMaskAnimationByCreate)344 void SetMaskAnimationByCreate(bool isMaskAnimationByCreate) 345 { 346 isMaskAnimationByCreate_ = isMaskAnimationByCreate; 347 } 348 IsMaskAnimationExecuted()349 bool IsMaskAnimationExecuted() 350 { 351 return isMaskAnimationExecuted_; 352 } 353 SetMaskAnimationExecuted(bool isMaskAnimationExecuted)354 void SetMaskAnimationExecuted(bool isMaskAnimationExecuted) 355 { 356 isMaskAnimationExecuted_ = isMaskAnimationExecuted; 357 } 358 SetImageColorOnIndex(int32_t index)359 void SetImageColorOnIndex(int32_t index) 360 { 361 imageColorOnIndex_ = index; 362 } 363 GetImageColorOnIndex()364 std::optional<int32_t> GetImageColorOnIndex() 365 { 366 return imageColorOnIndex_; 367 } 368 GetIndicator()369 int32_t GetIndicator() 370 { 371 return indicator_; 372 } 373 374 bool IsAtTop() const; 375 376 bool IsAtBottom() const; 377 std::string ProvideRestoreInfo() override; 378 void OnRestoreInfo(const std::string& restoreInfo) override; 379 380 void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override; 381 void FromJson(const std::unique_ptr<JsonValue>& json) override; 382 ResetIndicatorAnimationState()383 void ResetIndicatorAnimationState() 384 { 385 isAnimating_ = false; 386 animationTargetIndex_.reset(); 387 } 388 GetTouchingSwiper()389 bool GetTouchingSwiper() const 390 { 391 return isTouchingSwiper_; 392 } 393 GetTabBarStyle(uint32_t position)394 TabBarStyle GetTabBarStyle(uint32_t position) const 395 { 396 if (position < 0 || position >= tabBarStyles_.size()) { 397 return TabBarStyle::NOSTYLE; 398 } 399 return tabBarStyles_[position]; 400 } 401 GetBottomTabBarStyle(uint32_t position)402 const BottomTabBarStyle& GetBottomTabBarStyle(uint32_t position) const 403 { 404 if (position < 0 || position >= bottomTabBarStyles_.size()) { 405 return bottomTabBarStyle_; 406 } 407 return bottomTabBarStyles_[position]; 408 } 409 GetBottomTabLabelStyle(int32_t tabBarItemId)410 LabelStyle GetBottomTabLabelStyle(int32_t tabBarItemId) const 411 { 412 auto iter = labelStyles_.find(tabBarItemId); 413 if (iter == labelStyles_.end()) { 414 LabelStyle labelStyle{}; 415 return labelStyle; 416 } 417 return iter->second; 418 } 419 420 void DumpAdvanceInfo() override; 421 GetAnimationDuration()422 std::optional<int32_t> GetAnimationDuration() 423 { 424 return animationDuration_; 425 } 426 GetTabContentWillChangeFlag()427 bool GetTabContentWillChangeFlag() 428 { 429 return tabContentWillChangeFlag_; 430 } 431 ResetTabContentWillChangeFlag()432 void ResetTabContentWillChangeFlag() 433 { 434 tabContentWillChangeFlag_ = false; 435 } 436 437 void UpdateAnimationDuration(); 438 HasSurfaceChangedCallback()439 bool HasSurfaceChangedCallback() 440 { 441 return surfaceChangedCallbackId_.has_value(); 442 } 443 UpdateSurfaceChangedCallbackId(int32_t id)444 void UpdateSurfaceChangedCallbackId(int32_t id) 445 { 446 surfaceChangedCallbackId_ = id; 447 } 448 449 bool ContentWillChange(int32_t comingIndex); 450 bool ContentWillChange(int32_t currentIndex, int32_t comingIndex); 451 452 void AddTabBarItemClickEvent(const RefPtr<FrameNode>& tabBarItem); 453 void AddTabBarItemCallBack(const RefPtr<FrameNode>& tabBarItem); 454 RemoveTabBarItemInfo(int32_t tabBarItemId)455 void RemoveTabBarItemInfo(int32_t tabBarItemId) 456 { 457 clickEvents_.erase(tabBarItemId); 458 labelStyles_.erase(tabBarItemId); 459 } 460 SetIsExecuteBuilder(bool isExecuteBuilder)461 void SetIsExecuteBuilder(bool isExecuteBuilder) 462 { 463 isExecuteBuilder_ = isExecuteBuilder; 464 } 465 SetFocusIndicator(int32_t focusIndicator)466 void SetFocusIndicator(int32_t focusIndicator) 467 { 468 focusIndicator_ = focusIndicator; 469 } 470 471 private: 472 void OnModifyDone() override; 473 void OnAttachToFrameNode() override; 474 void OnDetachFromFrameNode(FrameNode* node) override; 475 void BeforeCreateLayoutWrapper() override; 476 void InitSurfaceChangedCallback(); 477 bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override; 478 bool CustomizeExpandSafeArea() override; 479 void OnSyncGeometryNode(const DirtySwapConfig& config) override; 480 481 void InitLongPressEvent(const RefPtr<GestureEventHub>& gestureHub); 482 void InitDragEvent(const RefPtr<GestureEventHub>& gestureHub); 483 void InitScrollableEvent( 484 const RefPtr<TabBarLayoutProperty>& layoutProperty, const RefPtr<GestureEventHub>& gestureHub); 485 void InitScrollable(const RefPtr<GestureEventHub>& gestureHub); 486 void InitTouch(const RefPtr<GestureEventHub>& gestureHub); 487 void InitHoverEvent(); 488 void InitMouseEvent(); 489 void SetSurfaceChangeCallback(); 490 491 void HandleMouseEvent(const MouseInfo& info); 492 void HandleHoverEvent(bool isHover); 493 void HandleHoverOnEvent(int32_t index); 494 void HandleMoveAway(int32_t index); 495 RefPtr<FocusHub> GetCurrentFocusNode(); 496 ScopeFocusAlgorithm GetScopeFocusAlgorithm() override; 497 WeakPtr<FocusHub> GetNextFocusNode(FocusStep step); 498 std::optional<int32_t> GetNextFocusIndicator(int32_t indicator, FocusStep step); 499 void HandleLongPressEvent(const GestureEvent& info); 500 void ShowDialogWithNode(int32_t index); 501 void CloseDialog(); 502 void InitLongPressAndDragEvent(); 503 void HandleClick(SourceType type, int32_t index); 504 void ClickTo(const RefPtr<FrameNode>& host, int32_t index); 505 void HandleTouchEvent(const TouchLocationInfo& info); 506 void HandleSubTabBarClick(const RefPtr<TabBarLayoutProperty>& layoutProperty, int32_t index); 507 void HandleBottomTabBarClick(int32_t selectedIndex, int32_t unselectedIndex); 508 void ChangeMask(int32_t index, float imageSize, const OffsetF& originalMaskOffset, float opacity, 509 float radiusRatio, bool isSelected); 510 void PlayMaskAnimation(float selectedImageSize, const OffsetF& originalSelectedMaskOffset, int32_t selectedIndex, 511 float unselectedImageSize, const OffsetF& originalUnselectedMaskOffset, int32_t unselectedIndex); 512 static void MaskAnimationFinish(const RefPtr<FrameNode>& host, int32_t selectedIndex, bool isSelected); 513 void GetBottomTabBarImageSizeAndOffset(const std::vector<int32_t>& selectedIndexes, 514 int32_t maskIndex, float& selectedImageSize, float& unselectedImageSize, OffsetF& originalSelectedMaskOffset, 515 OffsetF& originalUnselectedMaskOffset); 516 void UpdateBottomTabBarImageColor(const std::vector<int32_t>& selectedIndexes, int32_t maskIndex); 517 void UpdateSymbolApply(const RefPtr<NG::FrameNode>& symbolNode, RefPtr<TextLayoutProperty>& symbolProperty, 518 int32_t index, std::string type); 519 bool CheckSvg(int32_t index) const; 520 521 void HandleTouchDown(int32_t index); 522 void HandleTouchUp(int32_t index); 523 int32_t CalculateSelectedIndex(const Offset& info); 524 525 void PlayPressAnimation(int32_t index, const Color& pressColor, AnimationType animationType); 526 void PlayTabBarTranslateAnimation(AnimationOption option, float targetCurrentOffset); 527 void PlayIndicatorTranslateAnimation(AnimationOption option, RectF originalPaintRect, RectF targetPaintRect, 528 float targetOffset); 529 void StopTranslateAnimation(); 530 float CalculateTargetOffset(int32_t targetIndex); 531 void UpdateIndicatorCurrentOffset(float offset); 532 533 void GetInnerFocusPaintRect(RoundRect& paintRect); 534 void PaintFocusState(bool needMarkDirty = true); 535 void FocusIndexChange(int32_t index); 536 void FocusCurrentOffset(int32_t index); 537 void UpdateGradientRegions(bool needMarkDirty = true); 538 539 float GetSpace(int32_t indicator); 540 float CalculateFrontChildrenMainSize(int32_t indicator); 541 float CalculateBackChildrenMainSize(int32_t indicator); 542 void SetEdgeEffect(const RefPtr<GestureEventHub>& gestureHub); 543 void SetEdgeEffectCallback(const RefPtr<ScrollEdgeEffect>& scrollEffect); 544 bool IsOutOfBoundary(); 545 void SetAccessibilityAction(); 546 void TabBarClickEvent(int32_t index) const; 547 void OnCustomContentTransition(int32_t fromIndex, int32_t toIndex); 548 void ApplyTurnPageRateToIndicator(float turnPageRate); 549 bool CheckSwiperDisable() const; 550 void SetSwiperCurve(const RefPtr<Curve>& curve) const; 551 void InitTurnPageRateEvent(); 552 void GetIndicatorStyle(IndicatorStyle& indicatorStyle, OffsetF& indicatorOffset, RectF& tabBarItemRect); 553 void CalculateIndicatorStyle( 554 int32_t startIndex, int32_t nextIndex, IndicatorStyle& indicatorStyle, OffsetF& indicatorOffset); 555 Color GetTabBarBackgroundColor() const; 556 SizeF GetContentSize() const; 557 float GetLeftPadding() const; 558 void HandleBottomTabBarAnimation(int32_t index); 559 void UpdatePaintIndicator(int32_t indicator, bool needMarkDirty); 560 std::pair<float, float> GetOverScrollInfo(const SizeF& size); 561 void RemoveTabBarEventCallback(); 562 void AddTabBarEventCallback(); 563 void AddMaskItemClickEvent(); 564 bool IsValidIndex(int32_t index); 565 bool CanScroll() const; 566 int32_t GetLoopIndex(int32_t originalIndex) const; 567 RefPtr<SwiperPattern> GetSwiperPattern() const; 568 void UpdateChildrenClipEdge(); 569 570 void StartShowTabBar(int32_t delay = 0); 571 void StopShowTabBar(); 572 void InitTabBarProperty(); 573 void UpdateTabBarHiddenRatio(float ratio); 574 void SetTabBarTranslate(const TranslateOptions& options); 575 void SetTabBarOpacity(float opacity); 576 577 void AddIsFocusActiveUpdateEvent(); 578 void RemoveIsFocusActiveUpdateEvent(); 579 void HandleFocusEvent(); 580 void HandleBlurEvent(); 581 void InitFocusEvent(); 582 void UpdateFocusToSelectedNode(bool isFocusActive); 583 584 RefPtr<NodeAnimatablePropertyFloat> showTabBarProperty_; 585 bool isTabBarShowing_ = false; 586 587 std::map<int32_t, RefPtr<ClickEvent>> clickEvents_; 588 RefPtr<LongPressEvent> longPressEvent_; 589 RefPtr<TouchEventImpl> touchEvent_; 590 RefPtr<ScrollableEvent> scrollableEvent_; 591 RefPtr<InputEvent> mouseEvent_; 592 RefPtr<InputEvent> hoverEvent_; 593 RefPtr<SwiperController> swiperController_; 594 RefPtr<ScrollEdgeEffect> scrollEffect_; 595 RefPtr<FrameNode> dialogNode_; 596 RefPtr<DragEvent> dragEvent_; 597 AnimationStartEventPtr animationStartEvent_; 598 AnimationEndEventPtr animationEndEvent_; 599 600 float bigScale_ = 0.0f; 601 float largeScale_ = 0.0f; 602 float maxScale_ = 0.0f; 603 int32_t indicator_ = 0; 604 int32_t focusIndicator_ = 0; 605 Axis axis_ = Axis::HORIZONTAL; 606 std::unordered_map<int32_t, TabBarParamType> tabBarType_; 607 std::optional<int32_t> animationDuration_; 608 609 std::shared_ptr<AnimationUtils::Animation> tabbarIndicatorAnimation_; 610 std::shared_ptr<AnimationUtils::Animation> translateAnimation_; 611 std::shared_ptr<AnimationUtils::Animation> maskAnimation_; 612 613 bool indicatorAnimationIsRunning_ = false; 614 bool translateAnimationIsRunning_ = false; 615 616 bool isRTL_ = false; 617 bool clipEdge_ = true; 618 619 bool touching_ = false; // whether the item is in touching 620 bool isHover_ = false; 621 bool isMaskAnimationByCreate_ = false; 622 bool isMaskAnimationExecuted_ = false; 623 bool tabContentWillChangeFlag_ = false; 624 std::optional<int32_t> imageColorOnIndex_; 625 std::optional<int32_t> touchingIndex_; 626 std::optional<int32_t> hoverIndex_; 627 std::optional<int32_t> moveIndex_; 628 TabBarStyle tabBarStyle_ = TabBarStyle::NOSTYLE; 629 float currentIndicatorOffset_ = 0.0f; 630 std::vector<SelectedMode> selectedModes_; 631 std::vector<IndicatorStyle> indicatorStyles_; 632 std::vector<TabBarStyle> tabBarStyles_; 633 std::unordered_map<int32_t, LabelStyle> labelStyles_; 634 std::vector<IconStyle> iconStyles_; 635 std::vector<TabBarSymbol> symbolArray_; 636 bool isTouchingSwiper_ = false; 637 float indicatorStartPos_ = 0.0f; 638 float indicatorEndPos_ = 0.0f; 639 float turnPageRate_ = 0.0f; 640 int32_t swiperStartIndex_ = 0; 641 std::vector<BottomTabBarStyle> bottomTabBarStyles_; 642 BottomTabBarStyle bottomTabBarStyle_; 643 644 RefPtr<TabBarModifier> tabBarModifier_; 645 std::vector<bool> gradientRegions_ = {false, false, false, false}; 646 bool isAnimating_ = false; 647 bool changeByClick_ = false; 648 bool clickRepeat_ = false; 649 float scrollMargin_ = 0.0f; 650 bool isFirstLayout_ = true; 651 bool isExecuteBuilder_ = false; 652 std::optional<int32_t> animationTargetIndex_; 653 std::optional<int32_t> surfaceChangedCallbackId_; 654 std::optional<WindowSizeChangeReason> windowSizeChangeReason_; 655 std::pair<double, double> prevRootSize_; 656 657 std::optional<int32_t> jumpIndex_; 658 std::optional<int32_t> targetIndex_; 659 std::optional<int32_t> focusIndex_; 660 float currentDelta_ = 0.0f; 661 float currentOffset_ = 0.0f; 662 float barGridMargin_ = 0.0f; 663 std::map<int32_t, ItemInfo> visibleItemPosition_; 664 bool canOverScroll_ = false; 665 bool accessibilityScroll_ = false; 666 std::function<void(bool)> isFocusActiveUpdateEvent_; 667 ACE_DISALLOW_COPY_AND_MOVE(TabBarPattern); 668 }; 669 } // namespace OHOS::Ace::NG 670 671 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TABS_TAB_BAR_PATTERN_H 672