• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PATTERNS_APP_BAR_VIEW_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_APP_BAR_VIEW_H
18 
19 #include <cstddef>
20 #include <optional>
21 
22 #include "base/utils/macros.h"
23 #include "core/components_ng/base/frame_node.h"
24 #include "core/components/common/properties/text_style.h"
25 
26 namespace OHOS::Ace::NG {
27 /**
28  * The structure of Atomic Service (install free):
29  * |--AtomicService(Column)
30  *   |--JsView
31  *     |--Stage
32  *     |--MenuBarRow
33  *       |--MenuBar
34  *          |--menuButton
35  *          |--divider
36  *          |--closeButton
37  * |--ModalPage(UEC)
38  */
39 
40 class ACE_FORCE_EXPORT AppBarView : public Referenced {
41 public:
42     AppBarView() = default;
43     RefPtr<FrameNode> Create(const RefPtr<FrameNode>& stage);
44     RefPtr<Pattern> GetAtomicServicePattern();
SetVisible(bool visible)45     void SetVisible(bool visible) {}
SetRowColor(const std::optional<Color> & color)46     void SetRowColor(const std::optional<Color>& color) {}
SetContent(const std::string & content)47     void SetContent(const std::string& content) {}
SetFontStyle(Ace::FontStyle fontStyle)48     void SetFontStyle(Ace::FontStyle fontStyle) {}
SetIconColor(const std::optional<Color> & color)49     void SetIconColor(const std::optional<Color>& color) {}
50     void SetStatusBarItemColor(bool isLight);
51     std::optional<RectF> GetAppBarRect();
52     void OnMenuClick();
53     void OnCloseClick();
54     void RequestAtomicServiceTerminate();
55     void SetOnBackPressedConsumed();
56     void CreateServicePanel(const std::string& appGalleryBundleName, const std::string& abilityName,
57         std::map<std::string, std::string>& params);
58     static void BuildAppbar(RefPtr<PipelineBase> pipleline);
59     static void RegistAppBarNodeBuilder(
60         std::function<RefPtr<FrameNode>(NG::AppBarView* appBar, const RefPtr<FrameNode>& stage)> appBarNodeBuilder);
61     static int32_t AddRectChangeListener(
62         const RefPtr<PipelineContext>& pipelineContext, std::function<void(const RectF& rect)>&& listener);
63     static void RemoveRectChangeListener(const RefPtr<PipelineContext>& pipelineContext, int32_t id);
64 private:
65     RefPtr<FrameNode> BuildMenuBarRow();
66     RefPtr<FrameNode> BuildMenuBar();
67     RefPtr<FrameNode> BuildButton(bool isMenuButton);
68     RefPtr<FrameNode> BuildIcon(bool isMenuIcon);
69     RefPtr<FrameNode> BuildDivider();
70     void BindJSContainer();
71     void BindMenuCallback(const RefPtr<FrameNode>& menuButton);
72     void BindCloseCallback(const RefPtr<FrameNode>& closeButton);
73     void CreateServicePanel(bool firstTry);
74     void DestroyServicePanel();
75     static void InitUIExtensionNode(const RefPtr<FrameNode>& uiExtNode);
76     static void InitAccessibility(RefPtr<UINode> uiNode);
77     int32_t sessionId_ = 0;
78 
79     WeakPtr<FrameNode> atomicService_;
80     RefPtr<FrameNode> contentStage_;
81     static std::function<RefPtr<FrameNode>(NG::AppBarView* appBar, const RefPtr<FrameNode>& stage)> appBarNodeBuilder_;
82 };
83 } // namespace OHOS::Ace::NG
84 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_APP_BAR_VIEW_H
85