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); SetVisible(bool visible)44 void SetVisible(bool visible) {} SetRowColor(const std::optional<Color> & color)45 void SetRowColor(const std::optional<Color>& color) {} SetContent(const std::string & content)46 void SetContent(const std::string& content) {} SetFontStyle(Ace::FontStyle fontStyle)47 void SetFontStyle(Ace::FontStyle fontStyle) {} SetIconColor(const std::optional<Color> & color)48 void SetIconColor(const std::optional<Color>& color) {} 49 void SetStatusBarItemColor(bool isLight); 50 std::optional<RectF> GetAppBarRect(); 51 void OnMenuClick(); 52 void OnCloseClick(); 53 void CreateServicePanel(const std::string& appGalleryBundleName, const std::string& abilityName, 54 std::map<std::string, std::string>& params); 55 static void BuildAppbar(RefPtr<PipelineBase> pipleline); 56 private: 57 RefPtr<FrameNode> BuildMenuBarRow(); 58 RefPtr<FrameNode> BuildMenuBar(); 59 RefPtr<FrameNode> BuildButton(bool isMenuButton); 60 RefPtr<FrameNode> BuildIcon(bool isMenuIcon); 61 RefPtr<FrameNode> BuildDivider(); 62 void BindJSContainer(); 63 void BindMenuCallback(const RefPtr<FrameNode>& menuButton); 64 void BindCloseCallback(const RefPtr<FrameNode>& closeButton); 65 void CreateServicePanel(bool firstTry); 66 void DestroyServicePanel(); 67 static void InitUIExtensionNode(const RefPtr<FrameNode>& uiExtNode); 68 int32_t sessionId_ = 0; 69 70 WeakPtr<FrameNode> atomicService_; 71 RefPtr<FrameNode> contentStage_; 72 }; 73 } // namespace OHOS::Ace::NG 74 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_APP_BAR_VIEW_H 75