1/* 2 * Copyright (c) 2025 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 16import { NavList, NavListItem } from './utils/navigationList' 17 18@Builder 19export function NavIndexBuilder(name: string, param: Object) { 20 NavIndex() 21} 22 23@Entry 24@Component 25struct NavIndex { 26 pathStack: NavPathStack = new NavPathStack() 27 paths: NavListItem[] = [ 28 { name: 'Dialog', path: 'DialogIndex' }, 29 { name: 'Menu', path: 'MenuIndex' }, 30 { name: 'Popup', path: 'PopupIndex' }, 31 { name: 'Toast', path: 'ToastIndex' }, 32 { name: 'Overlay', path: 'OverlayIndex' }, 33 ] 34 35 build() { 36 NavDestination() { 37 NavList({ 38 pages: this.paths, 39 onPathChange: (item: NavListItem) => { 40 this.pathStack.pushPath( { name: item.path } ) 41 } 42 }) 43 } 44 .title('Overlay') 45 .height('100%') 46 .width('100%') 47 .onBackPressed(() => { 48 this.pathStack.pop() 49 return true 50 }) 51 .onReady((context: NavDestinationContext) => { 52 this.pathStack = context.pathStack; 53 }) 54 } 55}