• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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/picker/picker_base_component.h"
17 
18 #include "base/i18n/localization.h"
19 #include "core/components/picker/picker_base_element.h"
20 #include "core/components/picker/render_picker_base.h"
21 #include "core/components/triangle/triangle_component.h"
22 
23 namespace OHOS::Ace {
24 
25 const char PickerBaseComponent::PICKER_YEAR_COLUMN[] = "year";
26 const char PickerBaseComponent::PICKER_MONTH_COLUMN[] = "month";
27 const char PickerBaseComponent::PICKER_DAY_COLUMN[] = "day";
28 const char PickerBaseComponent::PICKER_HOUR_COLUMN[] = "hour";
29 const char PickerBaseComponent::PICKER_MINUTE_COLUMN[] = "minute";
30 const char PickerBaseComponent::PICKER_SECOND_COLUMN[] = "second";
31 const char PickerBaseComponent::PICKER_TEXT_COLUMN[] = "text";
32 const char PickerBaseComponent::PICKER_MONTHDAY_COLUMN[] = "monthDay";
33 const char PickerBaseComponent::PICKER_AMPM_COLUMN[] = "amPm";
34 
CreateRenderNode()35 RefPtr<RenderNode> PickerBaseComponent::CreateRenderNode()
36 {
37     return RenderPickerBase::Create();
38 }
39 
CreateElement()40 RefPtr<Element> PickerBaseComponent::CreateElement()
41 {
42     auto element = AceType::MakeRefPtr<PickerBaseElement>();
43     element->SetAutoAccessibility(false);
44     return element;
45 }
46 
ClearColumns()47 void PickerBaseComponent::ClearColumns()
48 {
49     auto accessibilityManager = accessibilityManager_.Upgrade();
50     if (accessibilityManager) {
51         for (const auto& column : columns_) {
52             accessibilityManager->RemoveAccessibilityNodeById(column->GetNodeId());
53             column->SetNodeId(-1); // reset to invalidate id.
54         }
55     } else {
56         LOGE("accessibility manager is null.");
57     }
58     columns_.clear();
59 }
60 
AppendColumn(const RefPtr<PickerColumnComponent> & column)61 void PickerBaseComponent::AppendColumn(const RefPtr<PickerColumnComponent>& column)
62 {
63     columns_.emplace_back(column);
64 }
65 
SetNeedVibrate(bool needVibrate)66 void PickerBaseComponent::SetNeedVibrate(bool needVibrate)
67 {
68     if (needVibrate_ == needVibrate) {
69         return;
70     }
71     needVibrate_ = needVibrate;
72     for (auto& column : columns_) {
73         column->SetNeedVibrate(needVibrate_);
74     }
75 }
76 
GetColumn(const std::string & tag) const77 RefPtr<PickerColumnComponent> PickerBaseComponent::GetColumn(const std::string& tag) const
78 {
79     auto iter = std::find_if(columns_.begin(), columns_.end(),
80         [&tag](const RefPtr<PickerColumnComponent>& column) { return column->GetColumnTag() == tag; });
81     return (iter == columns_.end()) ? nullptr : *iter;
82 }
83 
RemoveColumn(const std::string & tag)84 void PickerBaseComponent::RemoveColumn(const std::string& tag)
85 {
86     auto column = GetColumn(tag);
87     auto accessibilityManager = accessibilityManager_.Upgrade();
88     if (accessibilityManager && column) {
89         accessibilityManager->RemoveAccessibilityNodeById(column->GetNodeId());
90         column->SetNodeId(-1); // reset to invalidate id.
91     } else {
92         LOGE("accessibility manager is null or can not get the column.");
93     }
94     columns_.erase(std::remove_if(
95         columns_.begin(),
96         columns_.end(),
97         [tag](const RefPtr<PickerColumnComponent>& col) { return col->GetColumnTag() == tag; }),
98         columns_.end());
99 }
100 
SetFinishCallback(const ColumnFinishCallback & value)101 void PickerBaseComponent::SetFinishCallback(const ColumnFinishCallback& value)
102 {
103     for (const auto& column : columns_) {
104         column->SetFinishCallback(value);
105     }
106 }
107 
SetChangeCallback(const ColumnChangeCallback & value)108 void PickerBaseComponent::SetChangeCallback(const ColumnChangeCallback& value)
109 {
110     for (const auto& column : columns_) {
111         column->SetChangeCallback(value);
112     }
113 }
114 
ShowDialog(const RefPtr<StackElement> & stack,bool disableTouchEvent)115 void PickerBaseComponent::ShowDialog(const RefPtr<StackElement>& stack, bool disableTouchEvent)
116 {
117     if (!isDialog_) {
118         return;
119     }
120 
121     if (dialogShowed_) {
122         LOGW("dialog is showed already.");
123         return;
124     }
125 
126     if (!stack) {
127         LOGE("stack is null.");
128         return;
129     }
130 
131     stack_ = stack;
132     if (!stack_->PushDialog(AceType::Claim(this), disableTouchEvent)) {
133         LOGE("push dialog failed!");
134         return;
135     }
136     dialogShowed_ = true;
137 }
138 
HideDialog()139 bool PickerBaseComponent::HideDialog()
140 {
141     CloseDialog();
142     if (!isDialog_) {
143         return false;
144     }
145 
146     if (!dialogShowed_) {
147         LOGW("dialog not show.");
148         return false;
149     }
150 
151     if (!stack_) {
152         LOGE("stack is null.");
153         return false;
154     }
155 
156     if (!stack_->PopDialog()) {
157         LOGE("pop dialog failed!");
158         return false;
159     }
160     dialogShowed_ = false;
161     ClearAccessibilityNodes();
162     return true;
163 }
164 
OpenDialog(const DialogProperties & properties)165 void PickerBaseComponent::OpenDialog(const DialogProperties& properties)
166 {
167     if (!isCreateDialogComponent_) {
168         return;
169     }
170 
171     auto container = Container::Current();
172     if (!container) {
173         return;
174     }
175     auto context = AceType::DynamicCast<PipelineContext>(container->GetPipelineContext());
176     if (!context) {
177         return;
178     }
179 
180     auto executor = context->GetTaskExecutor();
181     if (!executor) {
182         return;
183     }
184 
185     executor->PostTask(
186         [context, dialogProperties = properties, weak = WeakClaim(this)]() mutable {
187             const auto& picker = weak.Upgrade();
188             if (context && picker) {
189                 picker->dialogComponent_ = context->ShowDialog(dialogProperties, false, picker->GetDialogName());
190             }
191         },
192         TaskExecutor::TaskType::UI, "ArkUIDialogShowPicker", TaskExecutor::GetPriorityTypeWithCheck(PriorityType::VIP));
193 }
194 
CloseDialog()195 void PickerBaseComponent::CloseDialog()
196 {
197     if (!isCreateDialogComponent_) {
198         return;
199     }
200 
201     auto container = Container::Current();
202     if (!container) {
203         return;
204     }
205     auto context = AceType::DynamicCast<PipelineContext>(container->GetPipelineContext());
206     if (!context) {
207         return;
208     }
209     const auto& lastStack = context->GetLastStack();
210     if (!lastStack) {
211         return;
212     }
213     auto executor = context->GetTaskExecutor();
214     if (!executor) {
215         return;
216     }
217     executor->PostTask(
218         [lastStack, dialogComponent = dialogComponent_]() {
219             if (!lastStack || !dialogComponent) {
220                 return;
221             }
222             auto dialogId = dialogComponent->GetDialogId();
223             lastStack->PopDialog(dialogId);
224         },
225         TaskExecutor::TaskType::UI, "ArkUIDialogClosePicker",
226         TaskExecutor::GetPriorityTypeWithCheck(PriorityType::VIP));
227 }
228 
OnTitleBuilding()229 void PickerBaseComponent::OnTitleBuilding()
230 {
231     SetHasLunar(false);
232 
233     auto theme = GetTheme();
234     if (!theme) {
235         LOGE("theme is null.");
236         return;
237     }
238     SetHasTitle(theme->GetShowButtons());
239     SetHasButtons(theme->GetShowButtons());
240 }
241 
InitializeTitle(std::list<RefPtr<Component>> & outChildren)242 void PickerBaseComponent::InitializeTitle(std::list<RefPtr<Component>>& outChildren)
243 {
244     if (!theme_) {
245         LOGE("theme is null.");
246         return;
247     }
248     if ((isDialog_ || isCreateDialogComponent_) && hasTitle_) {
249         auto triangle = AceType::MakeRefPtr<TriangleComponent>();
250         triangle->SetPadding(8.0_vp); // all padding
251         triangle->SetWidth(25.0_vp); // left padding + it width + right padding = 8dp + 9dp + 8dp
252         triangle->SetHeight(22.0_vp); // top padding + it height + bottom padding = 8dp + 6dp + 8dp
253         triangle->SetColor(theme_->GetTitleStyle().GetTextColor());
254         RefPtr<RowComponent> row = AceType::MakeRefPtr<RowComponent>(FlexAlign::CENTER,
255             FlexAlign::CENTER, std::list<RefPtr<Component>>());
256         title_->SetTextStyle(theme_->GetTitleStyle());
257         RefPtr<BoxComponent> titleBox = AceType::MakeRefPtr<BoxComponent>();
258         titleBox->SetChild(title_);
259         if (!GetHasTriangle()) {
260             row->AppendChild(AceType::MakeRefPtr<FlexItemComponent>(0.0, 1.0, 0.0, titleBox));
261         } else if (GetTextDirection() != TextDirection::RTL) {
262             row->AppendChild(AceType::MakeRefPtr<FlexItemComponent>(0.0, 1.0, 0.0, titleBox));
263             row->AppendChild(triangle);
264         } else {
265             row->AppendChild(triangle);
266             row->AppendChild(AceType::MakeRefPtr<FlexItemComponent>(0.0, 1.0, 0.0, titleBox));
267         }
268         auto titleComposed = GenerateAccessibilityComposed("picker-title", row, titleAccessibility_);
269         outChildren.emplace_back(titleComposed);
270 
271         RefPtr<BoxComponent> spaceBox = AceType::MakeRefPtr<BoxComponent>();
272         spaceBox->SetWidth(theme_->GetTitleBottomPadding().Value(), theme_->GetTitleBottomPadding().Unit());
273         spaceBox->SetHeight(theme_->GetTitleBottomPadding().Value(), theme_->GetTitleBottomPadding().Unit());
274         outChildren.emplace_back(spaceBox);
275     }
276 }
277 
InitializeColumns(std::list<RefPtr<Component>> & outChildren,const RefPtr<AccessibilityManager> & accessibilityManager)278 void PickerBaseComponent::InitializeColumns(
279     std::list<RefPtr<Component>>& outChildren, const RefPtr<AccessibilityManager>& accessibilityManager)
280 {
281     if (!theme_) {
282         LOGE("theme is null.");
283         return;
284     }
285 
286     std::list<RefPtr<Component>> columns;
287     for (const auto& column : columns_) {
288         column->SetTheme(theme_->clone());
289         column->SetTextDirection(GetTextDirection());
290         column->SetInDialog(isDialog_);
291         column->SetFixHeight(GetColumnHeight());
292         column->SetDefaultHeight(GetDefaultHeight());
293         auto id = column->GetNodeId();
294         if (id < 0) {
295             id = accessibilityManager->GenerateNextAccessibilityId();
296             // picker and picker-view accessibility parentNode different.
297             static const char* tag = "picker-column";
298             if (isDialog_) {
299                 accessibilityManager->CreateSpecializedNode(tag, id, rootAccessibilityId_);
300             } else {
301                 accessibilityManager->CreateSpecializedNode(tag, id, GetNodeId());
302             }
303             column->SetNodeId(id);
304         }
305         columns.emplace_back(column);
306     }
307     RefPtr<RowComponent> row = AceType::MakeRefPtr<RowComponent>(FlexAlign::FLEX_START, FlexAlign::FLEX_START, columns);
308     outChildren.emplace_back(row);
309 }
310 
InitializeChildAccessibility(const RefPtr<AccessibilityManager> & accessibilityManager)311 void PickerBaseComponent::InitializeChildAccessibility(const RefPtr<AccessibilityManager>& accessibilityManager)
312 {
313     if (!hasLunar_) {
314         if (lunarAccessibility_) {
315             accessibilityManager->RemoveAccessibilityNodes(lunarAccessibility_);
316             lunarAccessibility_ = nullptr;
317         }
318         if (switchAccessibility_) {
319             accessibilityManager->RemoveAccessibilityNodes(switchAccessibility_);
320             switchAccessibility_ = nullptr;
321         }
322         return;
323     }
324 }
325 
ClearAccessibilityNodes()326 void PickerBaseComponent::ClearAccessibilityNodes()
327 {
328     auto accessibilityManager = accessibilityManager_.Upgrade();
329     if (!accessibilityManager) {
330         LOGE("accessibilityManager is null");
331         return;
332     }
333 
334     if (rootAccessibility_) {
335         accessibilityManager->RemoveAccessibilityNodes(rootAccessibility_);
336         rootAccessibility_ = nullptr;
337         lunarAccessibility_ = nullptr;
338         switchAccessibility_ = nullptr;
339         titleAccessibility_ = nullptr;
340         cancelAccessibility_ = nullptr;
341         okAccessibility_ = nullptr;
342     }
343 
344     for (const auto& column : columns_) {
345         column->SetNodeId(-1); // reset id.
346     }
347 #if defined(PREVIEW)
348     if (accessibilityManager) {
349         auto node = accessibilityManager->GetAccessibilityNodeById(GetPickerBaseId());
350         if (node) {
351             node->SetZIndexToChild(0);
352         }
353     }
354 #endif
355 }
356 
GenerateAccessibilityComposed(const std::string & name,const RefPtr<Component> & child,RefPtr<AccessibilityNode> & node)357 RefPtr<Component> PickerBaseComponent::GenerateAccessibilityComposed(
358     const std::string& name, const RefPtr<Component>& child, RefPtr<AccessibilityNode>& node)
359 {
360     auto accessibilityManager = accessibilityManager_.Upgrade();
361     if (!accessibilityManager) {
362         return child;
363     }
364 
365     if (!node) {
366         int32_t parentNodeId = -1;
367         int32_t composedId = accessibilityManager->GenerateNextAccessibilityId();
368         if (isDialog_) {
369             parentNodeId = rootAccessibilityId_;
370         } else {
371             parentNodeId = GetNodeId();
372         }
373         node = accessibilityManager->CreateSpecializedNode(name, composedId, parentNodeId);
374     }
375     return child;
376 }
377 
InitializeLunar(std::list<RefPtr<Component>> & outChildren,const RefPtr<ThemeManager> & themeManager)378 void PickerBaseComponent::InitializeLunar(
379     std::list<RefPtr<Component>>& outChildren, const RefPtr<ThemeManager>& themeManager)
380 {
381     if (!theme_) {
382         LOGE("theme is null");
383         return;
384     }
385 
386     if (hasLunar_) {
387         RefPtr<BoxComponent> spaceBox = AceType::MakeRefPtr<BoxComponent>();
388         spaceBox->SetWidth(theme_->GetButtonTopPadding().Value(), theme_->GetButtonTopPadding().Unit());
389         spaceBox->SetHeight(theme_->GetButtonTopPadding().Value(), theme_->GetButtonTopPadding().Unit());
390         outChildren.emplace_back(spaceBox);
391         std::wstring lunarString { 0x663E, 0x793A, 0x519C, 0x5386 }; // the unicode encoding of chinese string of lunar.
392         RefPtr<TextComponent> lunarText = AceType::MakeRefPtr<TextComponent>(StringUtils::ToString(lunarString));
393         auto lunarStyle = theme_->GetOptionStyle(false, false);
394         if (GetIsDialog()) {
395             lunarStyle.SetLineHeight(theme_->GetLunarHeight());
396         }
397         lunarText->SetTextStyle(lunarStyle);
398         auto checkboxTheme = themeManager->GetTheme<CheckboxTheme>();
399         lunar_ = AceType::MakeRefPtr<CheckboxComponent>(checkboxTheme);
400         lunar_->SetHorizontalPadding(Dimension(0.0));
401         lunar_->SetHotZoneVerticalPadding(Dimension(0.0));
402         auto lunarSwitchComposed = GenerateAccessibilityComposed("lunar-switch", lunar_, switchAccessibility_);
403         RefPtr<BoxComponent> lunarBox = AceType::MakeRefPtr<BoxComponent>();
404         lunarBox->SetChild(lunarSwitchComposed);
405         lunarBox->SetWidth(theme_->GetLunarWidth().Value(), theme_->GetLunarWidth().Unit());
406         lunarBox->SetHeight(theme_->GetLunarHeight().Value(), theme_->GetLunarHeight().Unit());
407 
408         std::list<RefPtr<Component>> lunarChildren;
409         FlexAlign mainAlign = FlexAlign::AUTO;
410         if (GetTextDirection() == TextDirection::RTL) {
411             mainAlign = FlexAlign::FLEX_END;
412             lunarChildren.emplace_back(lunarText);
413             lunarChildren.emplace_back(lunarBox);
414         } else {
415             mainAlign = FlexAlign::FLEX_START;
416             lunarChildren.emplace_back(lunarBox);
417             lunarChildren.emplace_back(lunarText);
418         }
419         RefPtr<RowComponent> lunarRow =
420             AceType::MakeRefPtr<RowComponent>(mainAlign, FlexAlign::CENTER, lunarChildren);
421         RefPtr<DisplayComponent> display = AceType::MakeRefPtr<DisplayComponent>();
422         display->SetChild(lunarRow);
423         outChildren.emplace_back(display);
424     }
425 
426     if (GetSubsidiary() && GetMasterHasLunar()) {
427         RefPtr<BoxComponent> spaceBox = AceType::MakeRefPtr<BoxComponent>();
428         spaceBox->SetWidth(theme_->GetButtonTopPadding().Value(), theme_->GetButtonTopPadding().Unit());
429         spaceBox->SetHeight(theme_->GetButtonTopPadding().Value() + theme_->GetLunarHeight().Value(),
430             theme_->GetButtonTopPadding().Unit());
431         outChildren.emplace_back(spaceBox);
432     }
433 }
434 
InitializeButtons(std::list<RefPtr<Component>> & outChildren,const RefPtr<ThemeManager> & themeManager)435 void PickerBaseComponent::InitializeButtons(
436     std::list<RefPtr<Component>>& outChildren, const RefPtr<ThemeManager>& themeManager)
437 {
438     auto dialogTheme = themeManager->GetTheme<DialogTheme>();
439     if (!theme_ || !dialogTheme) {
440         LOGE("theme is null.");
441         return;
442     }
443 
444     auto buttonTheme = AceType::DynamicCast<ButtonTheme>(themeManager->GetTheme(ButtonTheme::TypeId()));
445     if (!buttonTheme) {
446         return;
447     }
448     auto buttonTextStyle = buttonTheme->GetTextStyle();
449     auto buttonFocusColor = theme_->GetFocusColor();
450     buttonTextStyle.SetTextColor(buttonFocusColor);
451 
452     if (isDialog_ || isCreateDialogComponent_) {
453         RefPtr<BoxComponent> topPaddingBox = AceType::MakeRefPtr<BoxComponent>();
454         topPaddingBox->SetWidth(theme_->GetButtonTopPadding().Value(), theme_->GetButtonTopPadding().Unit());
455         topPaddingBox->SetHeight(theme_->GetButtonTopPadding().Value(), theme_->GetButtonTopPadding().Unit());
456         outChildren.emplace_back(topPaddingBox);
457 
458         auto cancelButton = ButtonBuilder::Build(themeManager,
459             Localization::GetInstance()->GetEntryLetters("common.cancel"), buttonTextStyle, buttonFocusColor, true);
460         cancelButton->SetBackgroundColor(dialogTheme->GetButtonBackgroundColor());
461         cancelButton->SetClickedColor(dialogTheme->GetButtonClickedColor());
462         cancelButton->SetClickedEventId(onCancelClickId_);
463         cancelButton->SetType(ButtonType::CAPSULE);
464         cancelButton->SetHeight(theme_->GetButtonHeight());
465         auto cancelComposed = GenerateAccessibilityComposed("picker-button", cancelButton, cancelAccessibility_);
466         if (cancelAccessibility_) {
467             cancelAccessibility_->SetText(Localization::GetInstance()->GetEntryLetters("common.cancel"));
468         }
469 
470         auto okButton = ButtonBuilder::Build(themeManager, Localization::GetInstance()->GetEntryLetters("common.ok"),
471             buttonTextStyle, buttonFocusColor, true);
472         okButton->SetBackgroundColor(dialogTheme->GetButtonBackgroundColor());
473         okButton->SetClickedColor(dialogTheme->GetButtonClickedColor());
474         okButton->SetClickedEventId(onOkClickId_);
475         okButton->SetType(ButtonType::CAPSULE);
476         okButton->SetHeight(theme_->GetButtonHeight());
477         auto okComposed = GenerateAccessibilityComposed("picker-button", okButton, okAccessibility_);
478         if (okAccessibility_) {
479             okAccessibility_->SetText(Localization::GetInstance()->GetEntryLetters("common.ok"));
480         }
481 
482         auto dividerBox = AceType::MakeRefPtr<BoxComponent>();
483         dividerBox->SetWidth(dialogTheme->GetDividerWidth().Value(), dialogTheme->GetDividerWidth().Unit());
484         dividerBox->SetHeight(dialogTheme->GetDividerHeight().Value(), dialogTheme->GetDividerHeight().Unit());
485         auto backDecoration = AceType::MakeRefPtr<Decoration>();
486         backDecoration->SetBackgroundColor(dialogTheme->GetDividerColor());
487         dividerBox->SetBackDecoration(backDecoration);
488         dividerBox->SetMargin(dialogTheme->GetDividerPadding());
489 
490         std::list<RefPtr<Component>> buttons;
491         RefPtr<RowComponent> row =
492             AceType::MakeRefPtr<RowComponent>(FlexAlign::SPACE_AROUND, FlexAlign::FLEX_START, buttons);
493         row->SetTextDirection(GetTextDirection());
494         row->AppendChild(AceType::MakeRefPtr<FlexItemComponent>(1.0, 1.0, 0.0, cancelComposed));
495         row->AppendChild(AceType::MakeRefPtr<FlexItemComponent>(0.0, 0.0, 0.0, dividerBox));
496         row->AppendChild(AceType::MakeRefPtr<FlexItemComponent>(1.0, 1.0, 0.0, okComposed));
497         row->SetStretchToParent(true);
498 
499         auto display = AceType::MakeRefPtr<DisplayComponent>();
500         display->SetChild(row);
501         outChildren.emplace_back(display);
502     }
503 }
504 
InitializeContainer(const std::list<RefPtr<Component>> & outChildren)505 void PickerBaseComponent::InitializeContainer(const std::list<RefPtr<Component>>& outChildren)
506 {
507     if (!theme_) {
508         LOGE("theme is null.");
509         return;
510     }
511 
512     RefPtr<ColumnComponent> outColumn =
513         AceType::MakeRefPtr<ColumnComponent>(FlexAlign::CENTER, FlexAlign::FLEX_START, outChildren);
514     RefPtr<BoxComponent> box = AceType::MakeRefPtr<BoxComponent>();
515     box->SetDeliverMinToChild(false);
516     box->SetAlignment(Alignment::CENTER);
517     if (GetIsDialog()) {
518         RefPtr<FocusCollaborationComponent> collaboration = AceType::MakeRefPtr<FocusCollaborationComponent>();
519         collaboration->InsertChild(0, outColumn);
520         box->SetChild(collaboration);
521     } else {
522         box->SetChild(outColumn);
523     }
524 
525     RefPtr<BoxComponent> outBox = AceType::MakeRefPtr<BoxComponent>();
526     outBox->SetDeliverMinToChild(false);
527     outBox->SetAlignment(Alignment::CENTER);
528     outBox->SetChild(box);
529     if (GetTextDirection() == TextDirection::RTL) {
530         outColumn->SetCrossAxisAlign(FlexAlign::FLEX_END);
531         box->SetAlignment(Alignment::CENTER_RIGHT);
532     }
533     // picker need build outer composed component but picker-view don't need.
534     if (isDialog_) {
535         if (GetSubsidiary()) {
536             auto edge = theme_->GetPopupEdge();
537             edge.SetTop(0.0_vp);
538             edge.SetBottom(0.0_vp);
539             auto temp = AceType::MakeRefPtr<Decoration>();
540             temp->SetBackgroundColor(Color::TRANSPARENT);
541             box->SetBackDecoration(temp);
542             box->SetPadding(edge);
543             outBox->SetBackDecoration(temp);
544         } else {
545             box->SetBackDecoration(theme_->GetPopupDecoration(false));
546             box->SetPadding(theme_->GetPopupEdge());
547             outBox->SetBackDecoration(theme_->GetPopupDecoration(true));
548         }
549         SetChild(outBox);
550     } else {
551         SetChild(outBox);
552     }
553 }
554 
Initialize(const RefPtr<AccessibilityManager> & accessibilityManager,const RefPtr<ThemeManager> & themeManager)555 void PickerBaseComponent::Initialize(
556     const RefPtr<AccessibilityManager>& accessibilityManager, const RefPtr<ThemeManager>& themeManager)
557 {
558     if (!themeManager) {
559         return;
560     }
561 
562     if (!theme_) {
563         theme_ = themeManager->GetTheme<PickerTheme>();
564     }
565     accessibilityManager_ = accessibilityManager;
566     OnColumnsBuilding();
567     OnTitleBuilding();
568 
569     // picker need build rootAccessibilityNode but picker-view don't need.
570     if (!rootAccessibility_ && isDialog_) {
571         rootAccessibilityId_ = accessibilityManager->GenerateNextAccessibilityId();
572 #if defined(PREVIEW)
573         rootAccessibility_ = accessibilityManager->CreateAccessibilityNode(
574             "picker-dialog", rootAccessibilityId_, GetPickerBaseId(), -1);
575 #else
576         rootAccessibility_ = accessibilityManager->CreateSpecializedNode("picker-dialog", rootAccessibilityId_, -1);
577 #endif
578     }
579     std::list<RefPtr<Component>> outChildren;
580     InitializeTitle(outChildren);
581     InitializeColumns(outChildren, accessibilityManager);
582     InitializeLunar(outChildren, themeManager);
583     InitializeButtons(outChildren, themeManager);
584     InitializeContainer(outChildren);
585     InitializeChildAccessibility(accessibilityManager);
586 }
587 
588 } // namespace OHOS::Ace
589