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 Dimension& GetBadgePositionX() const;
42     const Dimension& GetBadgePositionY() const;
43     bool IsPositionXy() const;
44     const Edge& GetPadding() const;
45     const Dimension& GetBadgeCircleSize() const;
46     const std::optional<std::string>& GetBadgeLabel() const;
47     void SetPadding(const Edge& padding);
48     int64_t GetMessageCount() const;
49     bool IsShowMessage() const;
50     int64_t GetMaxCount() const;
51     bool IsBadgeCircleSizeDefined() const;
52     void SetBadgeCircleSizeDefined(bool badgeCircleSizeDefined);
53     void SetMaxCount(int64_t maxCount);
54     void SetShowMessage(bool showMessage);
55     void SetMessageCount(int64_t messageCount);
56     void SetBadgePosition(BadgePosition badgePostion);
57     void SetBadgePositionX(const Dimension& badgePostionX);
58     void SetBadgePositionY(const Dimension& badgePostionY);
59     void SetIsPositionXy(bool isPositionXy);
60     void SetBadgeTextColor(const Color& badgeTextColor);
61     void SetBadgeFontSize(const Dimension& badgeFontSize);
62     void SetBadgeColor(const Color& color);
63     void SetClickEvent(const EventMarker& event);
64     void SetBadgeCircleSize(const Dimension& badgeCircleSize);
65     void SetBadgeLabel(const std::string& badgeLabel);
66 
67     void SetDeclaration(const RefPtr<BadgeDeclaration>& declaration);
68 
69 private:
70     RefPtr<BadgeDeclaration> declaration_;
71 };
72 
73 } // namespace OHOS::Ace
74 
75 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BADGE_BADGE_COMPONENT_H
76