1/* 2 * Copyright (c) 2022-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 16import { BroadCast } from '../../utils/BroadCast'; 17import { Log } from '../../utils/Log'; 18import { ColumnSize, ScreenManager } from '../../model/common/ScreenManager'; 19import { Constants } from '../../model/common/Constants'; 20 21const TAG: string = 'common_CancelOperationDialog'; 22 23@Observed 24export class CancelParam { 25 public continueFunc: Function = (): void => {}; 26 public cancelFunc: Function = (): void => {}; 27} 28 29@CustomDialog 30export struct CancelOperationDialog { 31 @StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal(); 32 @StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar(); 33 @StorageLink('leftBlank') leftBlank: number[] = 34 [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()]; 35 controller?: CustomDialogController; 36 @Consume cancelMessage: Resource; 37 @Consume broadCast: BroadCast; 38 @Consume deleteProgress: number; 39 @Consume cancelParam: CancelParam; 40 private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE; 41 42 build() { 43 Column() { 44 Stack({ alignContent: Alignment.Center }) { 45 Text(this.cancelMessage) 46 .fontSize($r('sys.float.ohos_id_text_size_body1')) 47 .fontWeight(FontWeight.Regular) 48 .fontColor($r('sys.color.ohos_id_color_text_primary')) 49 }.width('100%') 50 .margin({ 51 top: $r('app.float.dialog_content_margin'), 52 bottom: $r('sys.float.ohos_id_elements_margin_vertical_l') 53 }) 54 55 Stack({ alignContent: Alignment.Top }) { 56 Row() { 57 Column() { 58 Button() { 59 Text($r('app.string.continue')) 60 .fontSize($r('sys.float.ohos_id_text_size_button1')) 61 .fontColor($r('app.color.color_control_highlight')) 62 .fontWeight(FontWeight.Medium) 63 .width('100%') 64 .textAlign(TextAlign.Center) 65 } 66 .onClick(() => { 67 Log.info(TAG, 'click continue') 68 this.cancelParam.continueFunc(); 69 this.controller?.close(); 70 }) 71 .margin({ 72 right: $r('app.float.dialog_double_buttons_margin_right') 73 }) 74 .backgroundColor($r('sys.color.ohos_id_color_button_normal')) 75 .borderRadius($r('sys.float.ohos_id_corner_radius_button')) 76 .height($r('app.float.details_dialog_button_height')) 77 }.width('50%') 78 79 Column() { 80 Button() { 81 Text($r('app.string.stop')) 82 .fontSize($r('sys.float.ohos_id_text_size_button1')) 83 .fontColor($r('sys.color.ohos_id_color_warning')) 84 .fontWeight(FontWeight.Medium) 85 .width('100%') 86 .textAlign(TextAlign.Center) 87 } 88 .onClick(() => { 89 Log.info(TAG, 'click cancel') 90 this.cancelParam.cancelFunc(); 91 this.controller?.close(); 92 }) 93 .margin({ 94 left: $r('app.float.dialog_double_buttons_margin_left') 95 }) 96 .backgroundColor($r('sys.color.ohos_id_color_button_normal')) 97 .borderRadius($r('sys.float.ohos_id_corner_radius_button')) 98 .height($r('app.float.details_dialog_button_height')) 99 }.width('50%') 100 } 101 }.width('100%') 102 .height($r('app.float.details_dialog_button_area_height')) 103 } 104 .borderRadius($r('sys.float.ohos_id_corner_radius_default_l')) 105 .width(this.isPcDevice ? $r('app.float.pc_dialog_width') : ScreenManager.getInstance() 106 .getColumnsWidth(ColumnSize.COLUMN_FOUR)) 107 .backgroundColor($r('app.color.white')) 108 .margin({ 109 right: $r('app.float.dialog_content_margin'), 110 left: $r('app.float.dialog_content_margin'), 111 bottom: this.isHorizontal || this.isSidebar ? 0 : Constants.DIALOG_BOTTOM_OFFSET + this.leftBlank[3] 112 }) 113 .padding({ 114 left: $r('app.float.dialog_double_buttons_padding'), 115 right: $r('app.float.dialog_double_buttons_padding') 116 }) 117 .alignItems(HorizontalAlign.Start) 118 .shadow({ 119 radius: $r('app.float.dialog_defult_shadow_m_radio'), 120 color: $r('app.color.dialog_defult_shadow_m_color'), 121 offsetX: $r('app.float.dialog_defult_shadow_m_offsetX'), 122 offsetY: $r('app.float.dialog_defult_shadow_m_offsetY') 123 }) 124 } 125} 126