• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 DeleteProgressParam {
21    currentCount: number
22    totalCount: number
23    message: Resource
24    deleteProgress: number
25}
26
27@CustomDialog
28export struct DeleteProgressDialog {
29    @StorageLink('isHorizontal') isHorizontal: boolean = screenManager.isHorizontal();
30    @StorageLink('isSidebar') isSidebar: boolean = screenManager.isSidebar();
31    @StorageLink('leftBlank') leftBlank: [number, number, number, number] = [0, 0, 0, 0];
32    controller: CustomDialogController
33    @Consume deleteProgressParam: DeleteProgressParam;
34
35    build() {
36        Column() {
37            Row() {
38                Text(this.deleteProgressParam.message)
39                    .fontSize($r('sys.float.ohos_id_text_size_body2'))
40                    .fontFamily($r('app.string.id_text_font_family_regular'))
41                    .fontColor($r('sys.color.ohos_id_color_text_primary'))
42                    .textOverflow({ overflow: TextOverflow.Ellipsis })
43                Text(`${this.deleteProgressParam.currentCount}/${this.deleteProgressParam.totalCount}`)
44                    .fontSize($r('sys.float.ohos_id_text_size_body2'))
45                    .fontFamily($r('app.string.id_text_font_family_regular'))
46                    .flexGrow(1)
47                    .fontColor($r('sys.color.ohos_id_color_text_primary'))
48                    .textOverflow({ overflow: TextOverflow.Ellipsis })
49                Text(`${this.deleteProgressParam.deleteProgress}%`)
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_secondary'))
53                    .margin({
54                        left: $r('app.float.process_bar_margin_left'),
55                        right: $r('app.float.delete_process_bar_margin_right'),
56                    })
57            }
58            .width('100%')
59
60            Row() {
61                Progress({ value: 0, total: Constants.PROGRESS_MAX, style: ProgressStyle.Linear })
62                    .value(this.deleteProgressParam.deleteProgress)
63                    .color($r('app.color.color_control_highlight'))
64                    .flexGrow(1)
65                    .padding({
66                        right: $r('app.float.progress_padding_right')
67                    })
68            }
69            .width('100%')
70            .margin({ top: $r('app.float.id_icon_margin_horizontal') })
71        }
72        .padding({
73            left: $r('app.float.max_padding_start'),
74            right: $r('app.float.max_padding_end'),
75            top: $r('app.float.max_padding_start'),
76            bottom: $r('app.float.max_padding_end'),
77        })
78        .border({ radius: $r('sys.float.ohos_id_corner_radius_default_l') })
79        .backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
80        .borderRadius($r('app.float.dialog_border_radius'))
81        .width(screenManager.getColumnsWidth(4))
82        .margin({
83            right: $r('app.float.dialog_window_margin'),
84            left: $r('app.float.dialog_window_margin'),
85            bottom: this.isHorizontal || this.isSidebar ? 0 : Constants.DIALOG_BOTTOM_OFFSET + px2vp(this.leftBlank[3])
86        })
87    }
88}
89