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_v2/indexer/popup_list_component.h" 17 18 #include "core/components_v2/indexer/popup_list_element.h" 19 #include "core/components_v2/indexer/render_popup_list.h" 20 21 namespace OHOS::Ace::V2 { CreateElement()22RefPtr<Element> PopupListComponent::CreateElement() 23 { 24 return AceType::MakeRefPtr<PopupListElement>(); 25 } 26 CreateRenderNode()27RefPtr<RenderNode> PopupListComponent::CreateRenderNode() 28 { 29 return RenderPopupList::Create(); 30 } 31 BuildBackground()32void PopupListComponent::BuildBackground() 33 { 34 RefPtr<BoxComponent> boxComponent = AceType::MakeRefPtr<BoxComponent>(); 35 boxComponent->SetFlex(BoxFlex::FLEX_NO); 36 boxComponent->SetAlignment(Alignment::CENTER); 37 boxComponent->SetWidth(POPUP_ZERO_SIZE, DimensionUnit::VP); 38 boxComponent->SetHeight(POPUP_ZERO_SIZE, DimensionUnit::VP); 39 40 Border border; 41 Radius radiusTop = Radius(Dimension(POPUP_BOX_RADIUS_SIZE, DimensionUnit::VP)); 42 Radius radiusBottom = Radius(Dimension(POPUP_BORDER_RADIUS_SIZE, DimensionUnit::VP)); 43 border.SetTopLeftRadius(radiusTop); 44 border.SetTopRightRadius(radiusTop); 45 border.SetBottomLeftRadius(radiusBottom); 46 border.SetBottomRightRadius(radiusBottom); 47 48 RefPtr<Decoration> boxDecoration = AceType::MakeRefPtr<Decoration>(); 49 boxDecoration->SetBorder(border); 50 boxDecoration->SetBackgroundColor(Color(POPUP_BG_COLOR).BlendOpacity(POPUP_BG_OPACITY)); 51 boxComponent->SetBackDecoration(boxDecoration); 52 53 AppendChild(boxComponent); 54 } 55 } // namespace OHOS::Ace::V2 56