1 /* 2 * Copyright (c) 2021 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/stack/stack_component.h" 17 18 #ifndef WEARABLE_PRODUCT 19 #include "core/components/navigation_bar/navigation_container_component.h" 20 #endif 21 22 namespace OHOS::Ace { 23 SetNavigationBar(const RefPtr<Component> & navigationBar)24void StackComponent::SetNavigationBar(const RefPtr<Component>& navigationBar) 25 { 26 navigationBar_ = navigationBar; 27 auto rootChild = GetChildren().front(); 28 #ifndef WEARABLE_PRODUCT 29 auto container = AceType::MakeRefPtr<NavigationContainerComponent>(navigationBar, rootChild); 30 #else 31 auto container = AceType::MakeRefPtr<ColumnComponent>( 32 FlexAlign::FLEX_START, FlexAlign::STRETCH, std::list<RefPtr<Component>>()); 33 container->SetContainsNavigation(true); 34 container->SetMainAxisSize(MainAxisSize::MIN); 35 container->AppendChild(navigationBar_); 36 container->AppendChild(rootChild); 37 #endif 38 RemoveChild(rootChild); 39 InsertChild(0, container); 40 } 41 42 } // namespace OHOS::Ace 43