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_COMPONENTS_BADGE_BADGE_COMPONENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BADGE_BADGE_COMPONENT_H 18 19 #include "base/geometry/dimension.h" 20 #include "core/components/common/properties/edge.h" 21 #include "core/pipeline/base/sole_child_component.h" 22 #include "core/components/declaration/badge/badge_declaration.h" 23 24 namespace OHOS::Ace { 25 26 class ACE_EXPORT BadgeComponent : public SoleChildComponent { 27 DECLARE_ACE_TYPE(BadgeComponent, SoleChildComponent); 28 29 public: 30 BadgeComponent(); 31 ~BadgeComponent() override = default; 32 33 RefPtr<RenderNode> CreateRenderNode() override; 34 RefPtr<Element> CreateElement() override; 35 36 const Color& GetBadgeColor() const; 37 const Color& GetBadgeTextColor() const; 38 const Dimension& GetBadgeFontSize() const; 39 const EventMarker& GetClickEvent() const; 40 BadgePosition GetBadgePosition() const; 41 const Edge& GetPadding() const; 42 const Dimension& GetBadgeCircleSize() const; 43 const std::optional<std::string>& GetBadgeLabel() const; 44 void SetPadding(const Edge& padding); 45 int64_t GetMessageCount() const; 46 bool IsShowMessage() const; 47 int64_t GetMaxCount() const; 48 bool IsBadgeCircleSizeDefined() const; 49 void SetBadgeCircleSizeDefined(bool badgeCircleSizeDefined); 50 void SetMaxCount(int64_t maxCount); 51 void SetShowMessage(bool showMessage); 52 void SetMessageCount(int64_t messageCount); 53 void SetBadgePosition(BadgePosition badgePostion); 54 void SetBadgeTextColor(const Color& badgeTextColor); 55 void SetBadgeFontSize(const Dimension& badgeFontSize); 56 void SetBadgeColor(const Color& color); 57 void SetClickEvent(const EventMarker& event); 58 void SetBadgeCircleSize(const Dimension& badgeCircleSize); 59 void SetBadgeLabel(const std::string& badgeLabel); 60 61 void SetDeclaration(const RefPtr<BadgeDeclaration>& declaration); 62 63 private: 64 RefPtr<BadgeDeclaration> declaration_; 65 }; 66 67 } // namespace OHOS::Ace 68 69 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BADGE_BADGE_COMPONENT_H 70