• 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 struct_index {
33  scroll: Scroller = new Scroller()
34  @State arr: TextList[] = [
35    new TextList(1, '01-style', 'pages/01-style/Index',),
36    new TextList(2, '02-layout', 'pages/02-layout/Index',),
37    new TextList(3, '03-menuHandleSelect', 'pages/03-menuHandleSelect/Index',),
38    new TextList(5, '05-focusKeyboard', 'pages/05-focusKeyboard/Index',),
39    new TextList(6, '06-password', 'pages/06-password/Index',),
40    new TextList(7, '07-content', 'pages/07-content/Index',),
41    new TextList(8, '08-event', 'pages/08-event/Index',),
42    new TextList(9, '09-font', 'pages/09-font/Index',),
43  ]
44  @State fontSize: Resource | undefined = undefined
45
46  build() {
47    Column() {
48      Scroll(this.scroll) {
49        Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
50          ForEach(this.arr, (item: TextList) => {
51            Button(item.text)
52              .width(300)
53              .height(50)
54              .margin(10)
55              .padding({ top: 5, bottom: 5 })
56              .onClick(() => {
57                router.pushUrl({ url: item.url })
58              })
59          }, (item: TextList) => JSON.stringify(item.id))
60        }
61        .width('100%')
62      }
63      .scrollBar(BarState.Off)
64    }
65  }
66}