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 build() { 40 Flex({ direction: FlexDirection.Column, justifyContent: this.isPad ? FlexAlign.Center : FlexAlign.End }) { 41 Column() { 42 Row() { 43 Text(this.dialogName) 44 .width(StyleConstants.PERCENTAGE_70) 45 .fontSize(StyleConstants.DEFAULT_FORM_FONT_CONTENT_SIZE) 46 .fontWeight(StyleConstants.DEFAULT_FORM_FONT_TITLE_WEIGHT) 47 } 48 .alignItems(VerticalAlign.Center) 49 .margin({ top: StyleConstants.DEFAULT_20 }) 50 51 Row() { 52 Text($r('app.string.remove_form_dialog_content')) 53 .width(StyleConstants.PERCENTAGE_70) 54 .fontSize(StyleConstants.DEFAULT_FORM_FONT_TITLE_SIZE) 55 .fontWeight(StyleConstants.DEFAULT_FORM_FONT_CONTENT_WEIGHT) 56 } 57 .alignItems(VerticalAlign.Center) 58 .margin({ top: StyleConstants.DEFAULT_20 }) 59 60 Flex({ justifyContent: FlexAlign.SpaceEvenly }) { 61 Button() { 62 Text($r('app.string.cancel')) 63 .fontSize(StyleConstants.DEFAULT_BADGE_FONT_SIZE) 64 .fontColor(StyleConstants.BUTTON_FONT_COLOR) 65 } 66 .backgroundColor(StyleConstants.DEFAULT_BG_COLOR) 67 .height(StyleConstants.DEFAULT_BUTTON_HEIGHT) 68 .width(StyleConstants.DEFAULT_BUTTON_WIDTH) 69 .onClick(() => { 70 this.controller.close(); 71 this.cancel() 72 }) 73 74 Divider() 75 .vertical(true) 76 .color(StyleConstants.DEFAULT_DIVIDER_COLOR) 77 .height(StyleConstants.DEFAULT_BUTTON_HEIGHT) 78 79 Button() { 80 Text($r('app.string.delete_form')) 81 .fontSize(StyleConstants.DEFAULT_BADGE_FONT_SIZE) 82 .fontColor(StyleConstants.DEFAULT_COLOR_ERROR) 83 } 84 .backgroundColor(StyleConstants.DEFAULT_BG_COLOR) 85 .height(StyleConstants.DEFAULT_BUTTON_HEIGHT) 86 .width(StyleConstants.DEFAULT_BUTTON_WIDTH) 87 .onClick(() => { 88 this.controller.close(); 89 this.confirm() 90 }) 91 } 92 } 93 .backgroundColor($r("app.color.default_dialog_background")) 94 .backgroundBlurStyle(BlurStyle.Regular) 95 .padding({ 96 bottom: StyleConstants.DEFAULT_DIALOG_BOTTOM_MARGIN 97 }) 98 .border({ 99 radius: StyleConstants.DEFAULT_DIALOG_RADIUS 100 }) 101 .width(this.mRemoveFormDialogWidth) 102 } 103 .margin({ bottom: this.navigationBarStatusValue ? StyleConstants.DEFAULT_12 : StyleConstants.DEFAULT_40 }) 104 .padding({ left: StyleConstants.DEFAULT_12, right: StyleConstants.DEFAULT_12 }) 105 } 106}