1 /* 2 * Copyright (c) 2021 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_COMMON_TEXT_FIELD_MANAGER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_TEXT_FIELD_MANAGER_H 18 19 #include "base/geometry/offset.h" 20 #include "base/memory/ace_type.h" 21 #include "base/utils/macros.h" 22 #include "core/common/manager_interface.h" 23 #include "core/components/stack/stack_element.h" 24 #include "core/components/text_field/render_text_field.h" 25 26 namespace OHOS::Ace { 27 28 class ACE_EXPORT TextFieldManager : public ManagerInterface { 29 DECLARE_ACE_TYPE(TextFieldManager, ManagerInterface); 30 31 public: 32 TextFieldManager() = default; 33 ~TextFieldManager() override = default; 34 35 void SetClickPosition(const Offset& position) override; 36 const Offset& GetClickPosition() override; 37 void MovePage(int32_t pageId, const Offset& rootRect, double offsetHeight) override; 38 void SetScrollElement(int32_t pageId, const WeakPtr<ScrollElement>& scrollElement) override; 39 void RemovePageId(int32_t pageId) override; 40 GetOnFocusTextField()41 WeakPtr<RenderTextField>& GetOnFocusTextField() 42 { 43 return onFocusTextField_; 44 } 45 SetOnFocusTextField(const WeakPtr<RenderTextField> & onFocusTextField)46 void SetOnFocusTextField(const WeakPtr<RenderTextField>& onFocusTextField) 47 { 48 onFocusTextField_ = onFocusTextField; 49 } 50 51 void ClearOnFocusTextField(); 52 53 bool ResetSlidingPanelParentHeight(); 54 55 bool UpdatePanelForVirtualKeyboard(double offsetY, double fullHeight); 56 void SetHeight(float height); 57 58 float GetHeight() const; 59 60 private: 61 bool hasMove_ = false; 62 Offset position_; 63 float height_ = 0.0f; 64 std::unordered_map<int32_t, WeakPtr<ScrollElement>> scrollMap_; 65 WeakPtr<RenderTextField> onFocusTextField_; 66 }; 67 68 } // namespace OHOS::Ace 69 70 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_TEXT_FIELD_MANAGER_H 71