• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (C) 2024 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 Logger from '../common/utils/Logger';
17
18@Builder
19export function PageOneBuilder(name: string, param: Object) {
20  PageOne()
21}
22
23const COLUMN_SPACE: number = 12;
24
25@Component
26export struct PageOne {
27  pageInfos: NavPathStack = new NavPathStack();
28
29  build() {
30    NavDestination() {
31      Column({ space: COLUMN_SPACE }) {
32        Button($r('app.string.entry_index'), { stateEffect: true, type: ButtonType.Capsule })
33          .width($r('app.string.button_width'))
34          .height($r('app.string.button_height'))
35          .onClick(() => {
36            //Clear all pages in the stack.
37            this.pageInfos.clear();
38          })
39        Button($r('app.string.entry_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
40          .width($r('app.string.button_width'))
41          .height($r('app.string.button_height'))
42          .onClick(() => {
43            //Push the NavDestination page information specified by name onto the stack, and pass the data as param.
44            this.pageInfos.pushPathByName('pageTwo', null);
45          })
46        Button($r('app.string.harA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
47          .width($r('app.string.button_width'))
48          .height($r('app.string.button_height'))
49          .onClick(() => {
50            //Push the NavDestination page information specified by name onto the stack, and pass the data as param.
51            this.pageInfos.pushPathByName('HarAPageOne', null);
52          })
53        Button($r('app.string.harA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
54          .width($r('app.string.button_width'))
55          .height($r('app.string.button_height'))
56          .onClick(() => {
57            //Push the NavDestination page information specified by name onto the stack, and pass the data as param.
58            this.pageInfos.pushPathByName('HarAPageTwo', null);
59          })
60        Button($r('app.string.harB_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
61          .width($r('app.string.button_width'))
62          .height($r('app.string.button_height'))
63          .onClick(() => {
64            //Push the NavDestination page information specified by name onto the stack, and pass the data as param.
65            this.pageInfos.pushPathByName('HarBPageOne', null);
66          })
67        Button($r('app.string.harB_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
68          .width($r('app.string.button_width'))
69          .height($r('app.string.button_height'))
70          .onClick(() => {
71            //Push the NavDestination page information specified by name onto the stack, and pass the data as param.
72            this.pageInfos.pushPathByName('HarBPageTwo', null);
73          })
74      }
75      .width($r('app.string.navDestination_width'))
76      .height($r('app.string.navDestination_height'))
77      .justifyContent(FlexAlign.End)
78      .padding({
79        bottom: $r('app.string.column_padding'),
80        left: $r('app.string.column_padding'),
81        right: $r('app.string.column_padding')
82      })
83    }
84    .title('entry-pageOne')
85    .onReady((context: NavDestinationContext) => {
86      this.pageInfos = context.pathStack;
87      Logger.info('current page config info is ' + JSON.stringify(context.getConfigInRouteMap()));
88    })
89  }
90}