1 /* 2 * Copyright (c) 2025 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_SHEET_SIDE_SHEET_SIDE_OBJECT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SHEET_SIDE_SHEET_SIDE_OBJECT_H 18 19 #include "core/components_ng/pattern/sheet/sheet_object.h" 20 21 namespace OHOS::Ace::NG { 22 23 class SheetSideObject : public SheetObject { 24 DECLARE_ACE_TYPE(SheetSideObject, SheetObject); 25 26 public: SheetSideObject(SheetType sheetType)27 SheetSideObject(SheetType sheetType) : SheetObject(sheetType) {} 28 NG::BorderWidthProperty PostProcessBorderWidth(const NG::BorderWidthProperty& borderWidth) override; 29 void DirtyLayoutProcess(const RefPtr<LayoutAlgorithmWrapper>& layoutAlgorithmWrapper) override; 30 RefPtr<InterpolatingSpring> GetSheetTransitionCurve(float dragVelocity) const override; 31 std::function<void()> GetSheetTransitionFinishEvent(bool isTransitionIn) override; 32 std::function<void()> GetSheetAnimationEvent(bool isTransitionIn, float offset) override; 33 void ClipSheetNode() override; 34 void InitAnimationForOverlay(bool isTransitionIn, bool isFirstTransition) override; 35 void SetFinishEventForAnimationOption( 36 AnimationOption& option, bool isTransitionIn, bool isFirstTransition) override; 37 AnimationOption GetAnimationOptionForOverlay(bool isTransitionIn, bool isFirstTransition) override; 38 std::function<void()> GetAnimationPropertyCallForOverlay(bool isTransitionIn) override; 39 void OnLanguageConfigurationUpdate() override; 40 PaddingPropertyF GetSheetSafeAreaPadding() const override; 41 void HandleDragStart() override; 42 void HandleDragUpdate(const GestureEvent& info) override; 43 void HandleDragEnd(float dragVelocity) override; 44 void ModifyFireSheetTransition(float dragVelocity) override; 45 void CreatePropertyCallback() override; 46 void BeforeCreateLayoutWrapper() override; 47 SheetKeyboardAvoidMode GetAvoidKeyboardModeByDefault() const override; AvoidKeyboardInDirtyLayoutProcess()48 void AvoidKeyboardInDirtyLayoutProcess() override {}; 49 void AvoidKeyboard(bool forceAvoid) override; 50 51 ScrollResult HandleScroll(float scrollOffset, int32_t source, NestedState state, float velocity = 0.f) override 52 { 53 return { scrollOffset, true }; 54 } 55 void OnScrollStartRecursive(float position, float dragVelocity = 0.0f) override {}; OnScrollEndRecursive(const std::optional<float> & velocity)56 void OnScrollEndRecursive(const std::optional<float>& velocity) override {}; HandleScrollVelocity(float velocity)57 bool HandleScrollVelocity(float velocity) override 58 { 59 return false; 60 } 61 GetPanDirection()62 uint32_t GetPanDirection() const override 63 { 64 return PanDirection::HORIZONTAL; 65 } 66 CheckIfNeedSetOuterBorderProp()67 bool CheckIfNeedSetOuterBorderProp() const override 68 { 69 return false; 70 } 71 CheckIfNeedShadowByDefault()72 bool CheckIfNeedShadowByDefault() const override 73 { 74 return false; 75 } 76 GetResizeDecreasedHeight()77 float GetResizeDecreasedHeight() const 78 { 79 return resizeDecreasedHeight_; 80 } 81 CheckIfUpdateObject(SheetType newType)82 bool CheckIfUpdateObject(SheetType newType) override 83 { 84 return newType != SheetType::SHEET_SIDE; 85 } 86 IsSheetObjectBase()87 bool IsSheetObjectBase() const override 88 { 89 return false; 90 } 91 92 void FireHeightDidChange() override; 93 94 private: 95 void UpdateSidePosition(); 96 void UpdateDragBarStatus(); 97 void HandleDragEndForLTR(float dragVelocity); 98 void HandleDragEndForRTL(float dragVelocity); 99 void HandleDragUpdateForLTR(const GestureEvent& info); 100 void HandleDragUpdateForRTL(const GestureEvent& info); 101 void TransformTranslateEnter(); 102 void TransformTranslateExit(); 103 void DecreaseScrollHeightInSideSheet(uint32_t decreaseHeight); 104 float GetUpOffsetCaretNeed(); 105 106 float resizeDecreasedHeight_ = 0.0f; 107 }; 108 } // namespace OHOS::Ace::NG 109 110 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SHEET_SIDE_SHEET_SIDE_OBJECT_H 111