• 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 PageTwoBuilder(name: string, param: Object) {
20  PageTwo()
21}
22
23const COLUMN_SPACE: number = 12;
24
25@Component
26export struct PageTwo {
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            this.pageInfos.clear(); //Clear all pages in the stack
37          })
38        Button($r('app.string.entry_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
39          .width($r('app.string.button_width'))
40          .height($r('app.string.button_height'))
41          .onClick(() => {
42            //Push the NavDestination page information specified by name onto the stack, and pass the data as param.
43            this.pageInfos.pushPathByName('pageOne', null);
44          })
45        Button($r('app.string.hspA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
46          .width($r('app.string.button_width'))
47          .height($r('app.string.button_height'))
48          .onClick(() => {
49            //Push the NavDestination page information specified by name onto the stack, and pass the data as param.
50            this.pageInfos.pushPathByName('HspAPageOne', null);
51          })
52        Button($r('app.string.hspA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
53          .width($r('app.string.button_width'))
54          .height($r('app.string.button_height'))
55          .onClick(() => {
56            //Push the NavDestination page information specified by name onto the stack, and pass the data as param.
57            this.pageInfos.pushPathByName('HspAPageTwo', null);
58          })
59        Button($r('app.string.hspB_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
60          .width($r('app.string.button_width'))
61          .height($r('app.string.button_height'))
62          .onClick(() => {
63            //Push the NavDestination page information specified by name onto the stack, and pass the data as param.
64            this.pageInfos.pushPathByName('HspBPageOne', null);
65          })
66        Button($r('app.string.hspB_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
67          .width($r('app.string.button_width'))
68          .height($r('app.string.button_height'))
69          .onClick(() => {
70            //Push the NavDestination page information specified by name onto the stack, and pass the data as param.
71            this.pageInfos.pushPathByName('HspBPageTwo', null);
72          })
73      }
74      .width($r('app.string.navDestination_width'))
75      .height($r('app.string.navDestination_height'))
76      .justifyContent(FlexAlign.End)
77      .padding({
78        bottom: $r('app.string.column_padding'),
79        left: $r('app.string.column_padding'),
80        right: $r('app.string.column_padding')
81      })
82    }
83    .title('entry-pageTwo')
84    .onReady((context: NavDestinationContext) => {
85      this.pageInfos = context.pathStack
86      Logger.info('current page config info is ' + JSON.stringify(context.getConfigInRouteMap()));
87    })
88  }
89}