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_QRCODE_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_QRCODE_COMPONENT_H
18 
19 #include "base/geometry/dimension.h"
20 #include "core/components/common/layout/constants.h"
21 #include "core/pipeline/base/sole_child_component.h"
22 #include "core/components/declaration/qrcode/qrcode_declaration.h"
23 
24 namespace OHOS::Ace {
25 
26 class ACE_EXPORT QrcodeComponent : public SoleChildComponent {
27     DECLARE_ACE_TYPE(QrcodeComponent, SoleChildComponent);
28 
29 public:
30     QrcodeComponent();
31     ~QrcodeComponent() override = default;
32 
33     RefPtr<RenderNode> CreateRenderNode() override;
34     RefPtr<Element> CreateElement() override;
35 
36     const std::string& GetValue() const;
37     const Color& GetBackgroundColor() const;
38     const Color& GetQrcodeColor() const;
39     QrcodeType GetType() const;
40     const Dimension& GetQrcodeWidth() const;
41     const Dimension& GetQrcodeHeight() const;
42     bool IsWidthDefined() const;
43     bool IsHeightDefined() const;
44     void SetValue(const std::string& value);
45     void SetBackgroundColor(const Color& backgroundColor);
46     void SetQrcodeColor(const Color& qrcodeColor);
47     void SetQrcodeType(QrcodeType qrcodeType);
48     void SetQrcodeWidth(const Dimension& qrcodeWidth);
49     void SetQrcodeHeight(const Dimension& qrcodeHeight);
50     void SetWidthDefined(bool isWidthDefined);
51     void SetHeightDefined(bool isHeightDefined);
52 
53     void SetDeclaration(const RefPtr<QrcodeDeclaration>& declaration);
54 
55 private:
56     RefPtr<QrcodeDeclaration> declaration_;
57 };
58 
59 } // namespace OHOS::Ace
60 
61 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_QRCODE_COMPONENT_H
62