1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TABS_TABS_LAYOUT_ALGORITHM_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TABS_TABS_LAYOUT_ALGORITHM_H 18 19 #include "core/components_ng/layout/layout_algorithm.h" 20 21 namespace OHOS::Ace::NG { 22 23 class ACE_EXPORT StepperLayoutAlgorithm : public LayoutAlgorithm { 24 DECLARE_ACE_TYPE(StepperLayoutAlgorithm, LayoutAlgorithm); 25 26 public: StepperLayoutAlgorithm(bool layoutLeftButton)27 explicit StepperLayoutAlgorithm(bool layoutLeftButton) : layoutLeftButton_(layoutLeftButton) {}; 28 ~StepperLayoutAlgorithm() override = default; 29 30 void Measure(LayoutWrapper* layoutWrapper) override; 31 void Layout(LayoutWrapper* layoutWrapper) override; 32 33 private: 34 void MeasureSwiper(LayoutWrapper* layoutWrapper, LayoutConstraintF swiperLayoutConstraint, float rightButtonHeight, 35 float leftButtonHeight); 36 void MeasureLeftButton(LayoutWrapper* layoutWrapper, LayoutConstraintF buttonLayoutConstraint); 37 void MeasureRightButton(LayoutWrapper* layoutWrapper, LayoutConstraintF buttonLayoutConstraint); 38 void MeasureText( 39 const RefPtr<LayoutWrapper>& layoutWrapper, const LayoutConstraintF& buttonLayoutConstraint, bool isLeft); 40 static LayoutConstraintF CreateButtonLayoutConstraint(const LayoutConstraintF& childLayoutConstraint, bool isLeft); 41 void LayoutSwiper(LayoutWrapper* layoutWrapper); 42 void LayoutLeftButton(LayoutWrapper* layoutWrapper); 43 void LayoutRightButton(LayoutWrapper* layoutWrapper); 44 float CaluateButtonHeight(LayoutWrapper* layoutWrapper, bool isRight); 45 void SuitAgeLayoutButton( 46 LayoutWrapper* layoutWrapper, float rightButtonHeight, float leftButtonHeight, bool isRight); 47 bool layoutLeftButton_ = true; 48 bool isLoadingButton_ = false; 49 ACE_DISALLOW_COPY_AND_MOVE(StepperLayoutAlgorithm); 50 }; 51 52 } // namespace OHOS::Ace::NG 53 54 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TABS_TABS_LAYOUT_ALGORITHM_H 55