• 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 
25 namespace OHOS::Ace::NG {
26 /**
27  * The structure of Atomic Service (install free):
28  * |--AtomicService(Column)
29  *   |--AppBar(Row)
30  *
31  *   |--Stage
32  *     |--Page
33  */
34 
35 /**
36  * The structure of AppBar:+
37  * |--AppBar
38  *   |--row
39  *     |--BackButton
40  *     |--Title
41  *   |FaButton
42  */
43 class ACE_FORCE_EXPORT AppBarView : public Referenced {
44 public:
45     AppBarView() = default;
AppBarView(const RefPtr<FrameNode> & atom)46     explicit AppBarView(const RefPtr<FrameNode>& atom)
47     {
48         atom_ = atom;
49     }
50     static RefPtr<FrameNode> Create(RefPtr<FrameNode>& content);
51     void SetVisible(bool visible);
52     void SetRowColor(const std::optional<Color>& color);
53     void SetContent(const std::string& content);
54     void SetFontStyle(Ace::FontStyle fontStyle);
55     void SetIconColor(const std::optional<Color>& color);
56     void iniBehavior();
57     void SetRowWidth(const Dimension& positionX);
58     void IniColor();
59     void ReverseBackButton();
60     void UpdateRowLayout();
61 
62 private:
63     static RefPtr<FrameNode> BuildBarTitle();
64     static RefPtr<FrameNode> BuildBarLabel();
65     static RefPtr<FrameNode> BuildIconButton(
66         InternalResource::ResourceId icon, GestureEventFunc&& clickCallback, bool isBackButton);
67     static void BindContentCover(const RefPtr<FrameNode>& targetNode);
68     static RefPtr<FrameNode> BuildFaButton();
69     static void SetEachIconColor(
70         RefPtr<FrameNode> icon, const std::optional<Color>& color, InternalResource::ResourceId image);
71     RefPtr<FrameNode> atom_;
72     RefPtr<FrameNode> GetFaButton();
73     RefPtr<FrameNode> GetBackButton();
74 
75     bool isVisibleSetted = false;
76     bool isRowColorSetted = false;
77     bool isIconColorSetted = false;
78     bool isRtlSetted = false;
79 };
80 } // namespace OHOS::Ace::NG
81 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_APP_BAR_VIEW_H
82