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 */ 15 16import screenManager from '@ohos/base/src/main/ets/manager/ScreenManager'; 17import { Constants } from '../../model/common/Constants'; 18 19@Observed 20export class MultiSelectDetails { 21 count: number; 22 size: number 23} 24 25@CustomDialog 26export struct MultiSelectDialog { 27 @StorageLink('isHorizontal') isHorizontal: boolean = screenManager.isHorizontal(); 28 @StorageLink('isSidebar') isSidebar: boolean = screenManager.isSidebar(); 29 @StorageLink('leftBlank') leftBlank: [number, number, number, number] = [0, 0, 0, 0]; 30 controller: CustomDialogController; 31 @Consume multiSelectDetails: MultiSelectDetails; 32 33 aboutToAppear() { 34 } 35 36 build() { 37 Column() { 38 Row() { 39 Text($r('app.string.details')) 40 .fontSize($r('sys.float.ohos_id_text_size_headline7')) 41 .fontWeight(FontWeight.Medium) 42 .fontColor($r('sys.color.ohos_id_color_text_primary')) 43 } 44 .alignItems(VerticalAlign.Center) 45 .height($r('app.float.dialog_title_height')) 46 47 Row() { 48 Column() { 49 Text($r('app.string.count')) 50 .fontSize($r('sys.float.ohos_id_text_size_body2')) 51 .fontFamily($r('app.string.id_text_font_family_regular')) 52 .fontColor($r('sys.color.ohos_id_color_text_primary')) 53 } 54 55 Column() { 56 Text($r('app.string.items', this.multiSelectDetails.count)) 57 .fontSize($r('sys.float.ohos_id_text_size_body2')) 58 .fontFamily($r('app.string.id_text_font_family_regular')) 59 .fontColor($r('sys.color.ohos_id_color_text_secondary')) 60 .textOverflow({ overflow: TextOverflow.Ellipsis }) 61 } 62 }.margin({ 63 bottom: $r('sys.float.ohos_id_text_paragraph_margin_s') }) 64 65 Row() { 66 Column() { 67 Text($r('app.string.size')) 68 .fontSize($r('sys.float.ohos_id_text_size_body2')) 69 .fontFamily($r('app.string.id_text_font_family_regular')) 70 .fontColor($r('sys.color.ohos_id_color_text_primary')) 71 } 72 73 Column() { 74 Text(`${(this.multiSelectDetails.size / Constants.BYTE_TO_MB).toFixed(2)}MB`) 75 .fontSize($r('sys.float.ohos_id_text_size_body2')) 76 .fontFamily($r('app.string.id_text_font_family_regular')) 77 .fontColor($r('sys.color.ohos_id_color_text_secondary')) 78 .textOverflow({ overflow: TextOverflow.Ellipsis }) 79 } 80 } 81 .margin({ 82 bottom: $r('sys.float.ohos_id_text_paragraph_margin_s') 83 }) 84 85 Stack({ alignContent: Alignment.Top }) { 86 Button() { 87 Text($r('app.string.detail_dialog_confirm')) 88 .fontSize($r('sys.float.ohos_id_text_size_button1')) 89 .fontColor($r('app.color.color_control_highlight')) 90 .width('100%') 91 .fontWeight(FontWeight.Medium) 92 .textAlign(TextAlign.Center) 93 } 94 .backgroundColor($r('app.color.transparent')) 95 .height($r('app.float.details_dialog_button_height')) 96 .onClick(() => { 97 this.controller.close() 98 }) 99 } 100 .width('100%') 101 .height($r('app.float.details_dialog_button_area_height')) 102 } 103 .borderRadius($r('app.float.dialog_border_radius')) 104 .width(screenManager.getColumnsWidth(4)) 105 .backgroundColor($r('app.color.white')) 106 .margin({ 107 right: $r('app.float.dialog_window_margin'), 108 left: $r('app.float.dialog_window_margin'), 109 bottom: this.isHorizontal || this.isSidebar ? 0 : Constants.DIALOG_BOTTOM_OFFSET + px2vp(this.leftBlank[3]) 110 }) 111 .padding({ left: $r('app.float.dialog_content_margin'), right: $r('app.float.dialog_content_margin') }) 112 .alignItems(HorizontalAlign.Start) 113 } 114} 115