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_DeleteProgressDialog';
21
22@Observed
23export class DeleteProgressParam {
24  public currentCount: number = 0;
25  public totalCount: number = 0;
26  public message?: Resource
27}
28
29@CustomDialog
30export struct DeleteProgressDialog {
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 deleteProgress: number;
37  @Consume deleteProgressParam: DeleteProgressParam;
38  private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
39
40  build() {
41    Column() {
42      Row() {
43        Text(this.deleteProgressParam.message)
44          .fontSize($r('sys.float.ohos_id_text_size_body2'))
45          .fontFamily($r('app.string.id_text_font_family_regular'))
46          .fontColor($r('sys.color.ohos_id_color_text_primary'))
47          .textOverflow({ overflow: TextOverflow.Ellipsis })
48        Text(`${this.deleteProgressParam.currentCount}/${this.deleteProgressParam.totalCount}`)
49          .fontSize($r('sys.float.ohos_id_text_size_body2'))
50          .fontFamily($r('app.string.id_text_font_family_regular'))
51          .flexGrow(1)
52          .fontColor($r('sys.color.ohos_id_color_text_primary'))
53          .textOverflow({ overflow: TextOverflow.Ellipsis })
54        Text(`${this.deleteProgress}%`)
55          .fontSize($r('sys.float.ohos_id_text_size_body2'))
56          .fontFamily($r('app.string.id_text_font_family_regular'))
57          .fontColor($r('sys.color.ohos_id_color_text_secondary'))
58      }
59      .width('100%')
60      .margin({
61        top: $r('app.float.process_bar_text_margin_top'),
62        bottom: $r('app.float.process_bar_text_margin_bottom')
63      })
64
65      Row() {
66        Progress({ value: 0, total: 100, style: ProgressStyle.Linear })
67          .value(this.deleteProgress)
68          .color($r('app.color.color_control_highlight'))
69      }
70      .width('100%')
71      .margin({
72        top: $r('app.float.process_bar_progress_margin_top'),
73        bottom: $r('app.float.process_bar_progress_margin_bottom')
74      })
75    }
76    .padding({
77      left: $r('app.float.max_padding_start'),
78      right: $r('app.float.max_padding_end'),
79      top: $r('app.float.max_padding_start'),
80      bottom: $r('app.float.max_padding_end'),
81    })
82    .backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
83    .borderRadius($r('sys.float.ohos_id_corner_radius_default_l'))
84    .width(this.isPcDevice ? $r('app.float.pc_dialog_width') : ScreenManager.getInstance()
85                                                                 .getColumnsWidth(ColumnSize.COLUMN_FOUR))
86    .margin({
87      right: $r('app.float.dialog_content_margin'),
88      left: $r('app.float.dialog_content_margin'),
89      bottom: this.isHorizontal || this.isSidebar ? 0 : Constants.DIALOG_BOTTOM_OFFSET + this.leftBlank[3]
90    })
91    .shadow({
92      radius: $r('app.float.dialog_defult_shadow_m_radio'),
93      color: $r('app.color.dialog_defult_shadow_m_color'),
94      offsetX: $r('app.float.dialog_defult_shadow_m_offsetX'),
95      offsetY: $r('app.float.dialog_defult_shadow_m_offsetY')
96    })
97  }
98}
99