1/* 2 * Copyright (c) 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 */ 15import { DialogCallback } from '../../model/common/DialogUtil'; 16import { Log } from '../../utils/Log'; 17import { ColumnSize, ScreenManager } from '../../model/common/ScreenManager'; 18import { Constants } from '../../model/common/Constants'; 19 20@CustomDialog 21export struct ThirdDeleteDialog { 22 private TAG: string = 'DeleteDialog' 23 @StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal(); 24 @StorageLink('leftBlank') leftBlank: number[] 25 = [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()]; 26 @Consume dialogCallback: DialogCallback; 27 @Consume dialogMessage: Resource; 28 @StorageLink('confirmText') confirmText: Resource = $r('app.string.dialog_delete'); 29 controller?: CustomDialogController; 30 31 private uris: string[] = []; 32 private thirdAppName: string | undefined = ''; 33 34 aboutToAppear() { 35 let stored = AppStorage.get<string[]>('uris'); 36 this.uris = stored === undefined ? [] : stored; 37 this.thirdAppName = AppStorage.get<string>('appName'); 38 } 39 40 build() { 41 Column() { 42 Column() { 43 Stack({ alignContent: Alignment.Bottom}) { 44 45 if(this.uris.length > 1) { 46 Image(this.uris[1]) 47 .objectFit(ImageFit.Cover) 48 .border({ radius: $r('sys.float.ohos_id_corner_radius_default_m')}) 49 .height($r('app.float.third_delete_dialog_ico_height')) 50 .width('100%') 51 .opacity(0.4) 52 .padding({ left: $r('app.float.third_delete_dialog_second_ico_margin'), 53 right: $r('app.float.third_delete_dialog_second_ico_margin')}) 54 } 55 56 Image(this.uris[0]) 57 .objectFit(ImageFit.Cover) 58 .border({ radius: $r('sys.float.ohos_id_corner_radius_default_m')}) 59 .height(this.uris.length > 1 ? $r('app.float.third_delete_dialog_ico_height_multi'): 60 $r('app.float.third_delete_dialog_ico_height')) 61 .width('100%') 62 .margin({ bottom: this.uris.length > 1 ? $r('app.float.dialog_button_and_text_margin') : 63 $r('app.float.dialog_offset_bottom')}) 64 } 65 66 Text($r('app.string.third_delete_dialog_message', this.thirdAppName, this.uris.length)) 67 .textAlign(TextAlign.Center) 68 .fontSize($r('sys.float.ohos_id_text_size_body1')) 69 .fontWeight(FontWeight.Regular) 70 .fontColor($r('sys.color.ohos_id_color_text_primary')) 71 .margin({ top: $r('app.float.first_delete_dialog_ico_margin_bottom')}) 72 } 73 .alignItems(HorizontalAlign.Center) 74 .width('100%') 75 .margin({ 76 top: $r('app.float.dialog_content_margin'), 77 bottom: $r('app.float.dialog_button_and_text_margin'), 78 }) 79 80 Stack({ alignContent: Alignment.Top }) { 81 Row() { 82 Column() { 83 Button() { 84 Text($r('app.string.dialog_cancel')) 85 .fontSize($r('sys.float.ohos_id_text_size_button1')) 86 .fontColor($r('app.color.color_control_highlight')) 87 .fontWeight(FontWeight.Medium) 88 .width('100%') 89 .textAlign(TextAlign.Center) 90 } 91 .margin({ 92 right: $r('app.float.dialog_double_buttons_margin') 93 }) 94 .backgroundColor($r('app.color.transparent')) 95 .height($r('app.float.details_dialog_button_height')) 96 .onClick(() => { 97 Log.debug(this.TAG, `cancelCallback`); 98 this.controller?.close(); 99 this.dialogCallback && this.dialogCallback.cancelCallback(); 100 }) 101 }.width('50%') 102 103 104 Divider() 105 .vertical(true) 106 .height(Constants.DEFAULT_DIVIDER_HEIGHT) 107 .color(Constants.DEFAULT_DIVIDER_COLOR) 108 109 Column() { 110 Button() { 111 Text(this.confirmText) 112 .fontSize($r('sys.float.ohos_id_text_size_button1')) 113 .fontColor($r('sys.color.ohos_id_color_warning')) 114 .fontWeight(FontWeight.Medium) 115 .width('100%') 116 .textAlign(TextAlign.Center) 117 } 118 .margin({ 119 left: $r('app.float.dialog_double_buttons_margin'), 120 }) 121 .backgroundColor($r('app.color.transparent')) 122 .height($r('app.float.details_dialog_button_height')) 123 .onClick(() => { 124 Log.debug(this.TAG, `confirmCallback`); 125 this.controller?.close(); 126 this.dialogCallback && this.dialogCallback.confirmCallback(); 127 }) 128 }.width('50%') 129 130 } 131 } 132 .width('100%') 133 .height($r('app.float.details_dialog_button_area_height')) 134 } 135 .borderRadius($r('sys.float.ohos_id_corner_radius_default_m')) 136 .width(ScreenManager.getInstance().getColumnsWidth(ColumnSize.COLUMN_FOUR)) 137 .backgroundColor($r('app.color.white')) 138 .margin({ 139 right: $r('app.float.dialog_window_margin'), 140 left: $r('app.float.dialog_window_margin'), 141 bottom: this.isHorizontal ? 0 : Constants.DIALOG_BOTTOM_OFFSET + px2vp(this.leftBlank[3]) 142 }) 143 .padding({ left: $r('app.float.dialog_content_margin'), right: $r('app.float.dialog_content_margin') }) 144 .alignItems(HorizontalAlign.Center) 145 .shadow({ 146 radius: $r('app.float.dialog_defult_shadow_m_radio'), 147 color: $r('app.color.dialog_defult_shadow_m_color'), 148 offsetX: $r('app.float.dialog_defult_shadow_m_offsetX'), 149 offsetY: $r('app.float.dialog_defult_shadow_m_offsetY') 150 }) 151 } 152} 153