• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2023 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
16@CustomDialog
17export struct SelectDialog {
18  private menus: Array<string> = [];
19  private doOperation: (index: number) => void = () => {
20  };
21  controller?: CustomDialogController;
22
23  build() {
24    Column() {
25      ForEach(this.menus, (item: string, index: number) => {
26        Row() {
27          Button() {
28            Text(item)
29              .fontSize(18)
30              .fontWeight(FontWeight.Medium)
31              .fontColor($r("app.color.list_content"))
32          }
33          .width('100%')
34          .height(48)
35          .type(ButtonType.Normal)
36          .backgroundColor($r("app.color.white"))
37          .onClick(() => {
38            this.controller?.close();
39            this.doOperation(index);
40          })
41        }
42        .width('100%')
43        .justifyContent(FlexAlign.Start)
44      }, (index: string) => index)
45    }
46    .borderRadius(20)
47    .width('100%')
48  }
49}