• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2021-2022 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 { StyleConstants } from '../constants/StyleConstants';
17import { LayoutViewModel } from '../viewmodel/LayoutViewModel';
18
19@CustomDialog
20export struct RemoveFormDialog {
21  @StorageLink('isPad') isPad: boolean = false;
22  @StorageLink('NavigationBarStatusValue') navigationBarStatusValue: boolean = false;
23  mRemoveFormDialogWidth: string;
24  controller: CustomDialogController;
25  cancel: () => void
26  confirm: () => void
27  dialogName: string;
28  private mLayoutViewModel: LayoutViewModel;
29
30  private async updateScreenSize() {
31    this.mRemoveFormDialogWidth = this.mLayoutViewModel.getCommonDialogWidth();
32  }
33
34  aboutToAppear(): void  {
35    this.mLayoutViewModel = LayoutViewModel.getInstance();
36    this.updateScreenSize();
37  }
38
39  aboutToDisappear(): void {
40    this.controller = null;
41    this.confirm = null;
42    this.cancel = null;
43  }
44
45  build() {
46    Flex({ direction: FlexDirection.Column, justifyContent: this.isPad ? FlexAlign.Center : FlexAlign.End }) {
47        Column() {
48          Row() {
49            Text(this.dialogName)
50              .width(StyleConstants.PERCENTAGE_70)
51              .fontSize(StyleConstants.DEFAULT_FORM_FONT_CONTENT_SIZE)
52              .fontWeight(StyleConstants.DEFAULT_FORM_FONT_TITLE_WEIGHT)
53          }
54          .alignItems(VerticalAlign.Center)
55          .margin({ top: StyleConstants.DEFAULT_20 })
56
57          Row() {
58            Text($r('app.string.remove_form_dialog_content'))
59              .width(StyleConstants.PERCENTAGE_70)
60              .fontSize(StyleConstants.DEFAULT_FORM_FONT_TITLE_SIZE)
61              .fontWeight(StyleConstants.DEFAULT_FORM_FONT_CONTENT_WEIGHT)
62          }
63          .alignItems(VerticalAlign.Center)
64          .margin({ top: StyleConstants.DEFAULT_20 })
65
66          Flex({ justifyContent: FlexAlign.SpaceEvenly }) {
67            Button() {
68              Text($r('app.string.cancel'))
69                .fontSize(StyleConstants.DEFAULT_BADGE_FONT_SIZE)
70                .fontColor(StyleConstants.BUTTON_FONT_COLOR)
71            }
72            .backgroundColor(StyleConstants.DEFAULT_BG_COLOR)
73            .height(StyleConstants.DEFAULT_BUTTON_HEIGHT)
74            .width(StyleConstants.DEFAULT_BUTTON_WIDTH)
75            .onClick(() => {
76              this.controller.close();
77              this.cancel()
78            })
79
80            Divider()
81              .vertical(true)
82              .color(StyleConstants.DEFAULT_DIVIDER_COLOR)
83              .height(StyleConstants.DEFAULT_BUTTON_HEIGHT)
84
85            Button() {
86              Text($r('app.string.delete_form'))
87                .fontSize(StyleConstants.DEFAULT_BADGE_FONT_SIZE)
88                .fontColor(StyleConstants.DEFAULT_COLOR_ERROR)
89            }
90            .backgroundColor(StyleConstants.DEFAULT_BG_COLOR)
91            .height(StyleConstants.DEFAULT_BUTTON_HEIGHT)
92            .width(StyleConstants.DEFAULT_BUTTON_WIDTH)
93            .onClick(() => {
94              this.controller.close();
95              this.confirm()
96            })
97          }
98        }
99        .backgroundColor($r("app.color.default_dialog_background"))
100        .backgroundBlurStyle(BlurStyle.Regular)
101        .padding({
102          bottom: StyleConstants.DEFAULT_DIALOG_BOTTOM_MARGIN
103        })
104        .border({
105          radius: StyleConstants.DEFAULT_DIALOG_RADIUS
106        })
107        .width(this.mRemoveFormDialogWidth)
108      }
109    .margin({ bottom: this.navigationBarStatusValue ? StyleConstants.DEFAULT_12 : StyleConstants.DEFAULT_40 })
110    .padding({ left: StyleConstants.DEFAULT_12, right: StyleConstants.DEFAULT_12 })
111  }
112}