• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: 'Select', path: 'SelectIndex' },
29    { name: 'Button', path: 'ButtonIndex' },
30    { name: 'Toggle', path: 'ToggleIndex' },
31    { name: 'Checkbox', path: 'CheckboxIndex' },
32    { name: 'Rating', path: 'RatingIndex' },
33    { name: 'Slider', path: 'SliderIndex' },
34    { name: 'Radio', path: 'RadioIndex' },
35    { name: 'Form', path:'FormIndex'}
36  ]
37
38  build() {
39    NavDestination() {
40      NavList({
41        pages: this.paths,
42        onPathChange: (item: NavListItem) => {
43          this.pathStack.pushPath( { name: item.path } )
44        }
45      })
46    }
47    .title('表单')
48    .height('100%')
49    .width('100%')
50    .onBackPressed(() => {
51      this.pathStack.pop()
52      return true
53    })
54    .onReady((context: NavDestinationContext) => {
55      this.pathStack = context.pathStack;
56    })
57  }
58}