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 { Log } from '../../utils/Log'; 17import { ColumnSize, ScreenManager } from '../../model/common/ScreenManager'; 18import { Constants } from '../../model/common/Constants'; 19 20const TAG: string = 'common_CopyOrMoveDialog'; 21 22@Observed 23export class OperateParam { 24 public moveFunc: Function = (): void => {}; 25 public copyFunc: Function = (): void => {}; 26} 27 28@CustomDialog 29export struct CopyOrMoveDialog { 30 static readonly INTERNAL_PREFIX_NUM = 3; 31 static readonly EXTERNAL_PREFIX_NUM = 2; 32 @StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal(); 33 @StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar(); 34 @StorageLink('leftBlank') leftBlank: number[] = 35 [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()]; 36 controller?: CustomDialogController; 37 dataTime: string = ''; 38 @Consume operateParam: OperateParam; 39 private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE; 40 41 aboutToAppear() { 42 43 } 44 45 build() { 46 Column() { 47 Row() { 48 Text($r('app.string.copy_or_move')) 49 .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle')) 50 .fontWeight(FontWeight.Medium) 51 .fontColor($r('sys.color.ohos_id_color_text_primary')) 52 }.alignItems(VerticalAlign.Center) 53 .height($r('app.float.dialog_title_height')) 54 55 56 Row() { 57 Column() { 58 Text($r('app.string.add')) 59 .fontSize($r('sys.float.ohos_id_text_size_sub_title2')) 60 .fontFamily($r('app.string.id_text_font_family_regular')) 61 .fontColor($r('sys.color.ohos_id_color_text_primary')) 62 } 63 } 64 .height($r('app.float.dialog_list_card_height')) 65 .width('100%') 66 .key('Copy') 67 .onClick(() => { 68 this.controller?.close(); 69 this.operateParam.copyFunc(); 70 }) 71 72 73 Divider() 74 .vertical(false) 75 .color($r('sys.color.ohos_id_color_list_separator')) 76 .width('100%') 77 78 Row() { 79 Column() { 80 Text($r('app.string.move')) 81 .fontSize($r('sys.float.ohos_id_text_size_sub_title2')) 82 .fontFamily($r('app.string.id_text_font_family_regular')) 83 .fontColor($r('sys.color.ohos_id_color_text_primary')) 84 } 85 86 } 87 .height($r('app.float.dialog_list_card_height')) 88 .width('100%') 89 .onClick(() => { 90 this.controller?.close(); 91 this.operateParam.moveFunc(); 92 }) 93 94 Stack({ alignContent: Alignment.Top }) { 95 Button() { 96 Text($r('app.string.cancel_button')) 97 .fontSize($r('sys.float.ohos_id_text_size_button1')) 98 .fontColor($r('app.color.color_control_highlight')) 99 .width('100%') 100 .textAlign(TextAlign.Center) 101 .fontWeight(FontWeight.Medium) 102 } 103 .backgroundColor(this.isPcDevice ? 104 $r('sys.color.ohos_id_color_button_normal') : $r('app.color.transparent')) 105 .height($r('app.float.details_dialog_button_height')) 106 .key('Cancel') 107 .onClick(() => { 108 this.controller?.close(); 109 }) 110 .margin({ 111 left: $r('app.float.dialog_single_button_indent_margin'), 112 right: $r('app.float.dialog_single_button_indent_margin') 113 }) 114 }.width('100%') 115 .height($r('app.float.details_dialog_button_area_height')) 116 } 117 .padding({ left: $r('app.float.dialog_content_margin'), right: $r('app.float.dialog_content_margin') }) 118 .alignItems(HorizontalAlign.Start) 119 .borderRadius($r('sys.float.ohos_id_corner_radius_default_l')) 120 .width(this.isPcDevice ? $r('app.float.pc_dialog_width') : ScreenManager.getInstance() 121 .getColumnsWidth(ColumnSize.COLUMN_FOUR)) 122 .backgroundColor($r('app.color.white')) 123 .margin({ 124 right: $r('app.float.dialog_content_margin'), 125 left: $r('app.float.dialog_content_margin'), 126 bottom: this.isHorizontal || this.isSidebar ? 0 : Constants.DIALOG_BOTTOM_OFFSET + this.leftBlank[3] 127 }) 128 .shadow({ 129 radius: $r('app.float.dialog_defult_shadow_m_radio'), 130 color: $r('app.color.dialog_defult_shadow_m_color'), 131 offsetX: $r('app.float.dialog_defult_shadow_m_offsetX'), 132 offsetY: $r('app.float.dialog_defult_shadow_m_offsetY') 133 }) 134 } 135} 136