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 #include "core/components_ng/pattern/app_bar/app_bar_view.h"
17 #include <cstdint>
18 #include "ui/base/geometry/dimension.h"
19 #include "ui/base/utils/utils.h"
20
21 #include "bridge/declarative_frontend/view_stack_processor.h"
22 #include "core/common/app_bar_helper.h"
23 #include "core/common/container.h"
24 #include "core/common/container_scope.h"
25 #include "core/components_ng/base/view_stack_processor.h"
26 #include "core/components_ng/event/focus_hub.h"
27 #include "core/components_ng/layout/layout_property.h"
28 #include "core/components_ng/pattern/app_bar/atomic_service_pattern.h"
29 #include "core/components_ng/pattern/button/button_layout_property.h"
30 #include "core/components_ng/pattern/button/button_pattern.h"
31 #include "core/components_ng/pattern/divider/divider_pattern.h"
32 #include "core/components_ng/pattern/linear_layout/linear_layout_property.h"
33 #include "core/components_ng/pattern/text/text_pattern.h"
34 #include "core/components_ng/pattern/app_bar/app_bar_utils.h"
35 #include "core/components_ng/base/inspector.h"
36
37 namespace OHOS::Ace::NG {
38 namespace {
39
40 constexpr int32_t ATOMIC_SERVICE_MENU_BAR_WIDTH = 96;
41 constexpr int32_t ATOMIC_SERVICE_MENU_BAR_MARGIN_RIGHT = 8;
42 constexpr int32_t ATOMIC_SERVICE_MENU_BAR_MARGIN_LEFT = 12;
43
GetAppBarTheme()44 RefPtr<AppBarTheme> GetAppBarTheme()
45 {
46 auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck();
47 CHECK_NULL_RETURN(pipeline, nullptr);
48 return pipeline->GetTheme<AppBarTheme>();
49 }
50
51 #ifndef PREVIEW
AssembleUiExtensionParams(bool firstTry,std::string & appGalleryBundleName,std::map<std::string,std::string> & params)52 void AssembleUiExtensionParams(
53 bool firstTry, std::string& appGalleryBundleName, std::map<std::string, std::string>& params)
54 {
55 auto missionId = AceApplicationInfo::GetInstance().GetMissionId();
56 params.try_emplace("bundleName", AceApplicationInfo::GetInstance().GetProcessName());
57 params.try_emplace("abilityName", AceApplicationInfo::GetInstance().GetAbilityName());
58 params.try_emplace("module", Container::Current()->GetModuleName());
59 if (missionId != -1) {
60 params.try_emplace("missionId", std::to_string(missionId));
61 }
62
63 if (firstTry) {
64 params.try_emplace("ability.want.params.uiExtensionType", "sysDialog/atomicServicePanel");
65 appGalleryBundleName = OHOS::Ace::SystemProperties::GetAtomicServiceBundleName();
66 } else {
67 params.try_emplace("ability.want.params.uiExtensionType", "sys/commonUI");
68 appGalleryBundleName = OHOS::Ace::AppBarHelper::QueryAppGalleryBundleName();
69 }
70 }
71 #endif
72 } // namespace
73
Create(const RefPtr<FrameNode> & stage)74 RefPtr<FrameNode> AppBarView::Create(const RefPtr<FrameNode>& stage)
75 {
76 auto atom = FrameNode::CreateFrameNode(V2::ATOMIC_SERVICE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
77 AceType::MakeRefPtr<AtomicServicePattern>());
78 // add children
79 contentStage_ = stage;
80 atomicService_ = atom;
81 BindJSContainer();
82 // init
83 atom->GetLayoutProperty()->UpdateMeasureType(MeasureType::MATCH_PARENT);
84 stage->GetLayoutProperty()->UpdateMeasureType(MeasureType::MATCH_PARENT);
85 return atom;
86 }
87
BindJSContainer()88 void AppBarView::BindJSContainer()
89 {
90 auto atom = atomicService_.Upgrade();
91 CHECK_NULL_VOID(atom);
92 auto isSucc = ExecuteCustomAppBarAbc();
93 if (!isSucc) {
94 return;
95 }
96 auto customAppBarNode = NG::ViewStackProcessor::GetInstance()->GetCustomAppBarNode();
97 CHECK_NULL_VOID(customAppBarNode);
98 atom->AddChild(customAppBarNode);
99 auto pattern = atom->GetPattern<AtomicServicePattern>();
100 CHECK_NULL_VOID(pattern);
101 pattern->AppInfoCallBack();
102 pattern->AppScreenCallBack();
103 pattern->AppBgColorCallBack();
104 }
105
BuildAppbar(RefPtr<PipelineBase> pipleline)106 void AppBarView::BuildAppbar(RefPtr<PipelineBase> pipleline)
107 {
108 CHECK_NULL_VOID(pipleline);
109 auto pipelineContext = AceType::DynamicCast<PipelineContext>(pipleline);
110 CHECK_NULL_VOID(pipelineContext);
111 auto container = Container::GetContainer(pipelineContext->GetInstanceId());
112 CHECK_NULL_VOID(container);
113 auto appbar = container->GetAppBar();
114 CHECK_NULL_VOID(appbar);
115 auto atom = appbar->atomicService_.Upgrade();
116 CHECK_NULL_VOID(atom);
117 auto customAppBarNode = NG::ViewStackProcessor::GetInstance()->GetCustomAppBarNode();
118 CHECK_NULL_VOID(customAppBarNode);
119 customAppBarNode->Build(nullptr);
120 auto stageNodeWrapperNode = Inspector::GetInspectorByKey(atom, "AtomicServiceStageId");
121 CHECK_NULL_VOID(stageNodeWrapperNode);
122 auto stageNodeWrapper = AceType::DynamicCast<FrameNode>(stageNodeWrapperNode);
123 CHECK_NULL_VOID(stageNodeWrapper);
124 CHECK_NULL_VOID(appbar->contentStage_);
125 stageNodeWrapper->AddChild(appbar->contentStage_);
126 stageNodeWrapper->MarkModifyDone();
127 stageNodeWrapper->MarkDirtyNode();
128 }
129
BuildMenuBarRow()130 RefPtr<FrameNode> AppBarView::BuildMenuBarRow()
131 {
132 auto menuBarRow = FrameNode::CreateFrameNode(V2::APP_BAR_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
133 AceType::MakeRefPtr<LinearLayoutPattern>(false));
134 auto theme = GetAppBarTheme();
135 CHECK_NULL_RETURN(theme, nullptr);
136
137 auto menuBar = BuildMenuBar();
138 menuBarRow->AddChild(menuBar);
139
140 auto layoutProperty = menuBarRow->GetLayoutProperty<LinearLayoutProperty>();
141 auto renderContext = menuBarRow->GetRenderContext();
142 // size
143 layoutProperty->UpdateUserDefinedIdealSize(
144 CalcSize(CalcLength(1.0, DimensionUnit::PERCENT), CalcLength(theme->GetMenuBarHeight())));
145 // main axis align
146 layoutProperty->UpdateMainAxisAlign(FlexAlign::FLEX_END);
147 // position
148 renderContext->UpdatePosition(OffsetT<Dimension>(0.0_vp, theme->GetMenuBarTopMargin()));
149 // background color
150 renderContext->UpdateBackgroundColor(Color::TRANSPARENT);
151 // hit test mode
152 menuBarRow->SetHitTestMode(HitTestMode::HTMTRANSPARENT_SELF);
153
154 menuBarRow->MarkModifyDone();
155 return menuBarRow;
156 }
157
BuildMenuBar()158 RefPtr<FrameNode> AppBarView::BuildMenuBar()
159 {
160 auto menuBar = FrameNode::CreateFrameNode(V2::ROW_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
161 AceType::MakeRefPtr<LinearLayoutPattern>(false));
162 auto theme = GetAppBarTheme();
163 CHECK_NULL_RETURN(theme, nullptr);
164
165 auto menuButton = BuildButton(true);
166 BindMenuCallback(menuButton);
167 menuBar->AddChild(menuButton);
168 auto divider = BuildDivider();
169 menuBar->AddChild(divider);
170 auto closeButton = BuildButton(false);
171 BindCloseCallback(closeButton);
172 menuBar->AddChild(closeButton);
173
174 auto layoutProperty = menuBar->GetLayoutProperty<LinearLayoutProperty>();
175 auto renderContext = menuBar->GetRenderContext();
176 // main axis align
177 layoutProperty->UpdateMainAxisAlign(FlexAlign::FLEX_START);
178 // border width
179 BorderWidthProperty borderWidth;
180 borderWidth.SetBorderWidth(theme->GetBorderWidth());
181 layoutProperty->UpdateBorderWidth(borderWidth);
182 renderContext->UpdateBorderWidth(borderWidth);
183 // border radius
184 auto bent = theme->GetBentRadius();
185 renderContext->UpdateBorderRadius(BorderRadiusProperty(bent));
186
187 menuBar->MarkModifyDone();
188 return menuBar;
189 }
190
BuildButton(bool isMenuButton)191 RefPtr<FrameNode> AppBarView::BuildButton(bool isMenuButton)
192 {
193 auto button = FrameNode::CreateFrameNode(
194 V2::BUTTON_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ButtonPattern>());
195 auto renderContext = button->GetRenderContext();
196 renderContext->UpdateBackgroundColor(Color::TRANSPARENT);
197 auto theme = GetAppBarTheme();
198 CHECK_NULL_RETURN(theme, nullptr);
199
200 auto icon = BuildIcon(isMenuButton);
201 button->AddChild(icon);
202
203 auto layoutProperty = button->GetLayoutProperty<ButtonLayoutProperty>();
204 // type
205 layoutProperty->UpdateType(ButtonType::NORMAL);
206 // size
207 layoutProperty->UpdateUserDefinedIdealSize(
208 CalcSize(CalcLength(theme->GetButtonWidth()), CalcLength(theme->GetButtonHeight())));
209 // focus style type
210 auto focusHub = button->GetFocusHub();
211 CHECK_NULL_RETURN(focusHub, nullptr);
212 focusHub->SetFocusStyleType(FocusStyleType::INNER_BORDER);
213 // focus border width
214 auto buttonPattern = button->GetPattern<ButtonPattern>();
215 CHECK_NULL_RETURN(buttonPattern, nullptr);
216 buttonPattern->SetFocusBorderWidth(theme->GetFocusedOutlineWidth());
217
218 button->MarkModifyDone();
219 return button;
220 }
221
BuildIcon(bool isMenuIcon)222 RefPtr<FrameNode> AppBarView::BuildIcon(bool isMenuIcon)
223 {
224 auto icon = FrameNode::CreateFrameNode(
225 V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
226 auto theme = GetAppBarTheme();
227 CHECK_NULL_RETURN(theme, nullptr);
228
229 ImageSourceInfo imageSourceInfo;
230 imageSourceInfo.SetResourceId(
231 isMenuIcon ? InternalResource::ResourceId::APP_BAR_MENU_SVG : InternalResource::ResourceId::APP_BAR_CLOSE_SVG);
232 auto layoutProperty = icon->GetLayoutProperty<ImageLayoutProperty>();
233 layoutProperty->UpdateImageSourceInfo(imageSourceInfo);
234 // size
235 layoutProperty->UpdateUserDefinedIdealSize(
236 CalcSize(CalcLength(theme->GetNewIconSize()), CalcLength(theme->GetNewIconSize())));
237 // focusable
238 auto focusHub = icon->GetFocusHub();
239 CHECK_NULL_RETURN(focusHub, nullptr);
240 focusHub->SetFocusable(true);
241
242 icon->MarkModifyDone();
243 return icon;
244 }
245
BuildDivider()246 RefPtr<FrameNode> AppBarView::BuildDivider()
247 {
248 auto divider = FrameNode::CreateFrameNode(
249 V2::DIVIDER_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<DividerPattern>());
250 auto theme = GetAppBarTheme();
251 CHECK_NULL_RETURN(theme, nullptr);
252
253 auto layoutProperty = divider->GetLayoutProperty<DividerLayoutProperty>();
254 // size
255 layoutProperty->UpdateUserDefinedIdealSize(
256 CalcSize(CalcLength(theme->GetDividerWidth()), CalcLength(theme->GetDividerHeight())));
257 // direction
258 layoutProperty->UpdateVertical(true);
259 // stroke width
260 layoutProperty->UpdateStrokeWidth(theme->GetDividerWidth());
261 // marigin
262 MarginProperty margin;
263 margin.left = CalcLength(-(theme->GetDividerWidth()));
264 auto renderProperty = divider->GetPaintProperty<DividerRenderProperty>();
265 // line cap
266 renderProperty->UpdateLineCap(LineCap::ROUND);
267
268 divider->MarkModifyDone();
269 return divider;
270 }
271
BindMenuCallback(const RefPtr<FrameNode> & menuButton)272 void AppBarView::BindMenuCallback(const RefPtr<FrameNode>& menuButton)
273 {
274 auto clickCallback = [wp = WeakClaim(this)](GestureEvent& info) {
275 #ifdef PREVIEW
276 LOGW("[Engine Log] Unable to show the SharePanel in the Previewer. "
277 "Perform this operation on the emulator or a real device instead.");
278 #else
279 auto appbarView = wp.Upgrade();
280 CHECK_NULL_VOID(appbarView);
281 auto node = appbarView->atomicService_.Upgrade();
282 auto pipeline = node->GetContext();
283 CHECK_NULL_VOID(pipeline);
284 auto theme = pipeline->GetTheme<AppBarTheme>();
285 CHECK_NULL_VOID(theme);
286 if (SystemProperties::GetExtSurfaceEnabled()) {
287 LOGI("start panel bundleName is %{public}s, abilityName is %{public}s", theme->GetBundleName().c_str(),
288 theme->GetAbilityName().c_str());
289 pipeline->FireSharePanelCallback(theme->GetBundleName(), theme->GetAbilityName());
290 } else {
291 appbarView->CreateServicePanel(true);
292 }
293 #endif
294 };
295 auto eventHub = menuButton->GetOrCreateGestureEventHub();
296 if (eventHub) {
297 eventHub->AddClickEvent(AceType::MakeRefPtr<ClickEvent>(std::move(clickCallback)));
298 }
299 }
300
BindCloseCallback(const RefPtr<FrameNode> & closeButton)301 void AppBarView::BindCloseCallback(const RefPtr<FrameNode>& closeButton)
302 {
303 auto clickCallback = [](GestureEvent& info) {
304 auto pipeline = PipelineContext::GetCurrentContext();
305 CHECK_NULL_VOID(pipeline);
306 auto container = Container::Current();
307 CHECK_NULL_VOID(container);
308 if (container->IsUIExtensionWindow()) {
309 container->TerminateUIExtension();
310 } else {
311 auto windowManager = pipeline->GetWindowManager();
312 CHECK_NULL_VOID(windowManager);
313 windowManager->WindowPerformBack();
314 }
315 };
316 auto eventHub = closeButton->GetOrCreateGestureEventHub();
317 if (eventHub) {
318 eventHub->AddClickEvent(AceType::MakeRefPtr<ClickEvent>(std::move(clickCallback)));
319 }
320 }
321
DestroyServicePanel()322 void AppBarView::DestroyServicePanel()
323 {
324 auto node = atomicService_.Upgrade();
325 auto pipeline = node->GetContext();
326 CHECK_NULL_VOID(pipeline);
327 auto overlayManager = pipeline->GetOverlayManager();
328 CHECK_NULL_VOID(overlayManager);
329 ContainerScope scope(pipeline->GetInstanceId());
330 overlayManager->CloseModalUIExtension(sessionId_);
331 LOGI("ServicePanel release session:%{public}d", sessionId_);
332 }
333
CreateServicePanel(const std::string & appGalleryBundleName,const std::string & abilityName,std::map<std::string,std::string> & params)334 void AppBarView::CreateServicePanel(
335 const std::string& appGalleryBundleName, const std::string& abilityName, std::map<std::string, std::string>& params)
336 {
337 #ifndef PREVIEW
338 if (OHOS::Ace::SystemProperties::GetAtomicServiceBundleName().empty() &&
339 OHOS::Ace::AppBarHelper::QueryAppGalleryBundleName().empty()) {
340 LOGE("UIExtension BundleName is empty.");
341 return;
342 }
343
344 auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck();
345 CHECK_NULL_VOID(pipeline);
346 auto overlayManager = pipeline->GetOverlayManager();
347 CHECK_NULL_VOID(overlayManager);
348
349 ModalUIExtensionCallbacks callbacks;
350 callbacks.onRelease = [wp = WeakClaim(this)](int32_t releaseCode) {
351 auto bar = wp.Upgrade();
352 bar->DestroyServicePanel();
353 };
354 callbacks.onError = [wp = WeakClaim(this)](int32_t code, const std::string& name, const std::string& message) {
355 auto bar = wp.Upgrade();
356 bar->DestroyServicePanel();
357 };
358 auto wantWrap = WantWrap::CreateWantWrap(appGalleryBundleName, abilityName);
359 wantWrap->SetWantParam(params);
360 LOGI("ServicePanel request bundle: %{public}s, ability: %{public}s. "
361 "UIExtension bundle: %{public}s, ability: %{public}s, module: %{public}s",
362 appGalleryBundleName.c_str(), abilityName.c_str(), params["bundleName"].c_str(), params["abilityName"].c_str(),
363 params["module"].c_str());
364 ModalUIExtensionConfig config;
365 sessionId_ = overlayManager->CreateModalUIExtension(wantWrap, callbacks, config);
366 #endif
367 }
368
CreateServicePanel(bool firstTry)369 void AppBarView::CreateServicePanel(bool firstTry)
370 {
371 #ifndef PREVIEW
372 if (OHOS::Ace::SystemProperties::GetAtomicServiceBundleName().empty() &&
373 OHOS::Ace::AppBarHelper::QueryAppGalleryBundleName().empty()) {
374 LOGE("UIExtension BundleName is empty.");
375 return;
376 }
377
378 auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck();
379 CHECK_NULL_VOID(pipeline);
380 auto overlayManager = pipeline->GetOverlayManager();
381 CHECK_NULL_VOID(overlayManager);
382
383 ModalUIExtensionCallbacks callbacks;
384 callbacks.onRelease = [wp = WeakClaim(this)](int32_t releaseCode) {
385 auto bar = wp.Upgrade();
386 bar->DestroyServicePanel();
387 };
388 callbacks.onError = [wp = WeakClaim(this), firstTry](
389 int32_t code, const std::string& name, const std::string& message) {
390 auto bar = wp.Upgrade();
391 bar->DestroyServicePanel();
392 if (firstTry) {
393 bar->CreateServicePanel(false);
394 }
395 };
396 std::string abilityName;
397 auto theme = pipeline->GetTheme<AppBarTheme>();
398 if (theme) {
399 abilityName = theme->GetStageAbilityName();
400 }
401 std::string appGalleryBundleName;
402 std::map<std::string, std::string> params;
403 AssembleUiExtensionParams(firstTry, appGalleryBundleName, params);
404 auto wantWrap = WantWrap::CreateWantWrap(appGalleryBundleName, abilityName);
405 wantWrap->SetWantParam(params);
406 LOGI("ServicePanel request bundle: %{public}s, ability: %{public}s. "
407 "UIExtension bundle: %{public}s, ability: %{public}s, module: %{public}s",
408 appGalleryBundleName.c_str(), abilityName.c_str(), params["bundleName"].c_str(), params["abilityName"].c_str(),
409 params["module"].c_str());
410 ModalUIExtensionConfig config;
411 sessionId_ = overlayManager->CreateModalUIExtension(wantWrap, callbacks, config);
412 #endif
413 }
414
InitUIExtensionNode(const RefPtr<FrameNode> & uiExtNode)415 void AppBarView::InitUIExtensionNode(const RefPtr<FrameNode>& uiExtNode)
416 {
417 CHECK_NULL_VOID(uiExtNode);
418 // Update ideal size of UIExtension.
419 auto layoutProperty = uiExtNode->GetLayoutProperty();
420 layoutProperty->UpdateUserDefinedIdealSize(CalcSize(
421 CalcLength(Dimension(1.0, DimensionUnit::PERCENT)), CalcLength(Dimension(1.0, DimensionUnit::PERCENT))));
422 uiExtNode->MarkModifyDone();
423 }
424
GetAppBarRect()425 std::optional<RectF> AppBarView::GetAppBarRect()
426 {
427 auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck();
428 if (!pipeline || !pipeline->GetInstallationFree()) {
429 return std::nullopt;
430 }
431 auto theme = GetAppBarTheme();
432 CHECK_NULL_RETURN(theme, std::nullopt);
433 auto atom = atomicService_.Upgrade();
434 CHECK_NULL_RETURN(atom, std::nullopt);
435 auto pattern = atom->GetPattern<AtomicServicePattern>();
436 CHECK_NULL_RETURN(pattern, std::nullopt);
437 auto menuBar = pattern->GetMenuBar();
438 CHECK_NULL_RETURN(menuBar, std::nullopt);
439 auto size = menuBar->GetGeometryNode()->GetMarginFrameSize();
440 auto offset = menuBar->GetGeometryNode()->GetMarginFrameOffset();
441 auto parent = menuBar->GetParent();
442 while (parent) {
443 auto frameNode = AceType::DynamicCast<FrameNode>(parent);
444 if (frameNode) {
445 offset += frameNode->GetGeometryNode()->GetFrameOffset();
446 }
447 parent = parent->GetParent();
448 }
449 auto atomRect = atom->GetGeometryNode()->GetFrameRect();
450 bool isRtl = AceApplicationInfo::GetInstance().IsRightToLeft();
451 auto left = Dimension(ATOMIC_SERVICE_MENU_BAR_MARGIN_LEFT, DimensionUnit::VP).ConvertToPx();
452 auto right = Dimension(ATOMIC_SERVICE_MENU_BAR_MARGIN_RIGHT, DimensionUnit::VP).ConvertToPx();
453 if (LessOrEqual(offset.GetX(), 0.0) && atomRect.Width() > 0) {
454 auto width = Dimension(ATOMIC_SERVICE_MENU_BAR_WIDTH, DimensionUnit::VP).ConvertToPx();
455 offset.SetX(isRtl ? (right) : (atomRect.Width() - width - left));
456 } else {
457 size.AddWidth((left + right));
458 offset.AddX(isRtl ? 0 : -left);
459 }
460 return RectF(offset, size);
461 }
462
SetStatusBarItemColor(bool isLight)463 void AppBarView::SetStatusBarItemColor(bool isLight)
464 {
465 auto atom = atomicService_.Upgrade();
466 CHECK_NULL_VOID(atom);
467 auto pattern = atom->GetPattern<AtomicServicePattern>();
468 CHECK_NULL_VOID(pattern);
469 auto theme = GetAppBarTheme();
470 auto menuBar = pattern->GetMenuBar();
471 pattern->settedColorMode = isLight;
472 pattern->ColorConfigurationCallBack();
473 }
474
OnMenuClick()475 void AppBarView::OnMenuClick()
476 {
477 auto atom = atomicService_.Upgrade();
478 CHECK_NULL_VOID(atom);
479 auto pipeline = atom->GetContext();
480 CHECK_NULL_VOID(pipeline);
481 auto theme = pipeline->GetTheme<AppBarTheme>();
482 CHECK_NULL_VOID(theme);
483 if (SystemProperties::GetExtSurfaceEnabled()) {
484 LOGI("start panel bundleName is %{public}s, abilityName is %{public}s", theme->GetBundleName().c_str(),
485 theme->GetAbilityName().c_str());
486 pipeline->FireSharePanelCallback(theme->GetBundleName(), theme->GetAbilityName());
487 } else {
488 CreateServicePanel(true);
489 }
490 }
491
OnCloseClick()492 void AppBarView::OnCloseClick()
493 {
494 auto atom = atomicService_.Upgrade();
495 CHECK_NULL_VOID(atom);
496 auto pipeline = atom->GetContext();
497 CHECK_NULL_VOID(pipeline);
498 auto container = Container::Current();
499 CHECK_NULL_VOID(container);
500 TAG_LOGI(AceLogTag::ACE_APPBAR, "AppBar OnCloseClick");
501 if (container->IsUIExtensionWindow()) {
502 container->TerminateUIExtension();
503 } else {
504 auto windowManager = pipeline->GetWindowManager();
505 CHECK_NULL_VOID(windowManager);
506 windowManager->WindowPerformBack();
507 }
508 }
509 } // namespace OHOS::Ace::NG
510