1 /* 2 * Copyright (c) 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_PATTERN_SECURITY_COMPONENT_SECURITY_COMPONENT_MODEL_NG_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SECURITY_COMPONENT_SECURITY_COMPONENT_MODEL_NG_H 18 19 #include "core/components_ng/base/frame_node.h" 20 #include "core/components_ng/base/view_abstract_model.h" 21 #include "core/components_ng/pattern/security_component/security_component_common.h" 22 #include "core/components_ng/pattern/security_component/security_component_theme.h" 23 #include "core/components/common/layout/constants.h" 24 #include "core/components/common/properties/text_style.h" 25 #include "core/gestures/gesture_info.h" 26 27 namespace OHOS::Ace::NG { 28 class ACE_EXPORT SecurityComponentModelNG { 29 public: 30 virtual ~SecurityComponentModelNG() = default; 31 virtual void Create(int32_t text, int32_t icon, 32 int32_t backgroundType) = 0; 33 void CreateCommon(const std::string& tag, int32_t text, int32_t icon, 34 int32_t backgroundType, 35 const std::function<RefPtr<Pattern>(void)>& patternCreator); 36 static void SetIconSize(const Dimension& value); 37 static void SetIconColor(const Color& value); 38 static void SetFontSize(const Dimension& value); 39 static void SetFontStyle(const Ace::FontStyle& value); 40 static void SetFontWeight(const FontWeight& value); 41 static void SetFontFamily(const std::vector<std::string>& fontFamilies); 42 static void SetFontColor(const Color& value); 43 static void SetBackgroundColor(const Color& value); 44 static void SetBackgroundBorderWidth(const Dimension& value); 45 static void SetBackgroundBorderColor(const Color& value); 46 static void SetBackgroundBorderStyle(const BorderStyle& value); 47 static void SetBackgroundBorderRadius(const Dimension& value); 48 static void SetBackgroundPadding(const std::optional<Dimension>& left, const std::optional<Dimension>& right, 49 const std::optional<Dimension>& top, const std::optional<Dimension>& bottom); 50 static void SetBackgroundPadding(const std::optional<Dimension>& padding); 51 static void SetTextIconSpace(const Dimension& value); 52 static void SetTextIconLayoutDirection(const SecurityComponentLayoutDirection& value); 53 GetIconResource(int32_t iconStyle,InternalResource::ResourceId & id)54 virtual bool GetIconResource(int32_t iconStyle, InternalResource::ResourceId& id) 55 { 56 return false; 57 } 58 GetTextResource(int32_t textStyle,std::string & text)59 virtual bool GetTextResource(int32_t textStyle, std::string& text) 60 { 61 return false; 62 } 63 64 protected: 65 static RefPtr<SecurityComponentTheme> GetTheme(); 66 67 private: 68 static void SetDefaultIconStyle(const RefPtr<FrameNode>& imageNode, InternalResource::ResourceId id, 69 bool isButtonVisible); 70 static void SetInvisibleBackgroundButton(const RefPtr<FrameNode>& buttonNode); 71 static bool IsBackgroundVisible(); 72 static void SetDefaultBackgroundButton(const RefPtr<FrameNode>& buttonNode, 73 int32_t type); 74 static void SetDefaultTextStyle(const RefPtr<FrameNode>& textNode, const std::string& text, bool isButtonVisible); 75 static void InitLayoutProperty(RefPtr<FrameNode>& node, int32_t text, int32_t icon, 76 int32_t backgroundType); 77 }; 78 } // namespace OHOS::Ace::NG 79 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SECURITY_COMPONENT_SECURITY_COMPONENT_MODEL_NG_H 80