• 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 router from '@ohos.router';
17
18class TextList {
19  public id: number;
20  public text: string;
21  public url: string;
22
23  constructor(id: number, text: string, url: string) {
24    this.id = id;
25    this.text = text;
26    this.url = url;
27  }
28}
29
30@Entry
31@Component
32struct IndexPage {
33  scroll: Scroller = new Scroller()
34  @State arr: TextList[] = [
35    new TextList(1, 'ScrollableMainPage', 'pages/scrollable/ScrollableMainPage'),
36    new TextList(2, 'TabsMainPage', 'pages/Tabs/TabsMainPage'),
37    new TextList(3, 'WaterFlowMainPage', 'pages/waterflow/WaterFlowMainPage'),
38    new TextList(4, 'SwiperMainPage', 'pages/Swiper/SwiperMainPage'),
39    new TextList(5, 'ListMainPage', 'pages/List/ListMainPage'),
40    new TextList(6, 'AlphabetIndexer', 'pages/alphabetIndexer/AlphabetIndexerMainPage'),
41    new TextList(7, 'Refresh', 'pages/refresh/RefreshMainPage'),
42    new TextList(8, 'GridMainPage', 'pages/grid/GridMainPage'),
43    new TextList(9, 'Scroll', 'pages/Scroll/ScrollMainPage'),
44    new TextList(10, 'LazyVGridLayout', 'pages/Scroll/LazyVGridLayoutMainPage'),
45  ]
46  @State fontSize: Resource | undefined = undefined
47  build() {
48    Column() {
49      Scroll(this.scroll) {
50        Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
51          ForEach(this.arr, (item: TextList) => {
52            Button(item.text)
53              .width(300)
54              .height(50)
55              .margin(10)
56              .padding({ top: 5, bottom: 5 })
57              .onClick(() => {
58                router.pushUrl({ url: item.url })
59              })
60          }, (item: TextList) => JSON.stringify(item.id))
61        }
62        .width('100%')
63      }
64      .scrollBar(BarState.Off)
65    }
66  }
67}