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 { BroadCastConstants } from '../../model/common/BroadCastConstants'; 17import { BroadCast } from '../../utils/BroadCast'; 18import { ColumnSize, ScreenManager } from '../../model/common/ScreenManager'; 19import { Constants } from '../../model/common/Constants'; 20 21@CustomDialog 22export struct SaveImageDialog { 23 @Consume broadCast: BroadCast 24 @StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal(); 25 @StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar(); 26 @StorageLink('leftBlank') leftBlank: number[] = 27 [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()]; 28 controller?: CustomDialogController; 29 private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE; 30 31 controllerClose() { 32 this.controller?.close(); 33 } 34 35 aboutToAppear() { 36 this.broadCast.on(BroadCastConstants.EXIT_SAVE_PROGRESS_CLOSE, (): void => this.controllerClose()); 37 } 38 39 aboutToDisappear(): void { 40 this.broadCast.off(BroadCastConstants.EXIT_SAVE_PROGRESS_CLOSE, (): void => {}); 41 } 42 43 build() { 44 Column() { 45 Row() { 46 Text($r('app.string.edit_save_picture_text')).fontSize($r('sys.float.ohos_id_text_size_body1')) 47 .flexGrow(1) 48 LoadingProgress() 49 .width($r('app.float.loading_progress_size')) 50 .height($r('app.float.loading_progress_size')) 51 .margin({ 52 left: $r('app.float.loading_progress_left_margin') 53 }) 54 } 55 .margin({ bottom: $r('app.float.dialog_content_margin'), top: $r('app.float.dialog_content_margin') }) 56 .height(48) 57 .width('100%') 58 } 59 .alignItems(HorizontalAlign.Start) 60 .width(this.isPcDevice ? $r('app.float.pc_dialog_width') : ScreenManager.getInstance() 61 .getColumnsWidth(ColumnSize.COLUMN_FOUR)) 62 .backgroundColor($r('app.color.white')) 63 .borderRadius($r('sys.float.ohos_id_corner_radius_default_l')) 64 .margin({ 65 right: $r('app.float.dialog_content_margin'), 66 left: $r('app.float.dialog_content_margin'), 67 bottom: this.isHorizontal || this.isSidebar ? 0 : Constants.DIALOG_BOTTOM_OFFSET + this.leftBlank[3] 68 }) 69 .padding({ left: $r('app.float.dialog_content_margin'), right: $r('app.float.dialog_content_margin') }) 70 .shadow({ 71 radius: $r('app.float.dialog_defult_shadow_m_radio'), 72 color: $r('app.color.dialog_defult_shadow_m_color'), 73 offsetX: $r('app.float.dialog_defult_shadow_m_offsetX'), 74 offsetY: $r('app.float.dialog_defult_shadow_m_offsetY') 75 }) 76 } 77}