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_OPTION_OPTION_VIEW_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OPTION_OPTION_VIEW_H 18 19 #include <string> 20 21 #include "base/utils/macros.h" 22 #include "core/components_ng/base/frame_node.h" 23 #include "core/components_ng/pattern/select/select_model.h" 24 25 namespace OHOS::Ace::NG { 26 struct OptionValueInfo { 27 std::string value; 28 bool isPasteOption = false; 29 }; 30 31 class ACE_EXPORT OptionView { 32 public: 33 static RefPtr<FrameNode> CreateMenuOption(bool optionsHasIcon, const OptionValueInfo& value, 34 const std::function<void()>& onClickFunc, int32_t index, const std::string& icon = ""); 35 static RefPtr<FrameNode> CreateMenuOption(bool optionsHasIcon, std::vector<OptionParam>& params, int32_t index); 36 37 static RefPtr<FrameNode> CreateSelectOption(const SelectParam& param, int32_t index); 38 39 static RefPtr<FrameNode> CreateText(const std::string& value, const RefPtr<FrameNode>& parent); 40 static RefPtr<FrameNode> CreateIcon(const std::string& icon, const RefPtr<FrameNode>& parent, 41 const RefPtr<FrameNode>& child = nullptr); 42 static void CreatePasteButton(bool optionsHasIcon, const RefPtr<FrameNode>& option, const RefPtr<FrameNode>& row, 43 const std::function<void()>& onClickFunc, const std::string& icon = ""); 44 static RefPtr<FrameNode> CreateSymbol(const std::function<void(WeakPtr<NG::FrameNode>)>& symbol, 45 const RefPtr<FrameNode>& parent, const RefPtr<FrameNode>& child = nullptr, 46 const std::optional<Dimension>& symbolUserDefinedIdealFontSize = std::nullopt); 47 static void CreateOption(bool optionsHasIcon, const std::string& value, const std::string& icon, 48 const RefPtr<FrameNode>& row, const RefPtr<FrameNode>& option, const std::function<void()>& onClickFunc); 49 static void CreateOption(bool optionsHasIcon, std::vector<OptionParam>& params, int32_t index, 50 const RefPtr<FrameNode>& row, const RefPtr<FrameNode>& option); 51 }; 52 53 } // namespace OHOS::Ace::NG 54 55 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OPTION_VIEW_H 56