• 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 { Broadcast } from '@ohos/base/src/main/ets/utils/Broadcast';
17import { Log } from '@ohos/base/src/main/ets/utils/Log';
18import  screenManager  from '@ohos/base/src/main/ets/manager/ScreenManager';
19import { Constants } from '../../model/common/Constants';
20
21@Observed
22export class CancelParam {
23    continueFunc: Function
24    cancelFunc: Function
25}
26
27@CustomDialog
28export struct CancelOperationDialog {
29    private TAG: string = 'CancelOperationDialog'
30    @StorageLink('isHorizontal') isHorizontal: boolean = screenManager.isHorizontal();
31    @StorageLink('isSidebar') isSidebar: boolean = screenManager.isSidebar();
32    @StorageLink('leftBlank') leftBlank: [number, number, number, number] = [0, 0, 0, 0];
33    controller: CustomDialogController;
34    @Consume cancelMessage: Resource;
35    @Consume broadCast: Broadcast;
36    @Consume deleteProgress: number;
37    @Consume cancelParam: CancelParam;
38
39    build() {
40        Column() {
41            Text(this.cancelMessage)
42                .fontSize($r('sys.float.ohos_id_text_size_body1'))
43                .fontFamily($r('app.string.id_text_font_family_regular'))
44                .flexGrow(1)
45                .fontColor($r('sys.color.ohos_id_color_text_primary'))
46                .padding({
47                    bottom: 8
48                })
49
50            Stack({ alignContent: Alignment.Top }) {
51                Row() {
52                    Button() {
53                        Text($r('app.string.continue'))
54                            .fontSize($r('sys.float.ohos_id_text_size_button1'))
55                            .fontColor($r('app.color.color_control_highlight'))
56                            .fontWeight(FontWeight.Medium)
57                            .width('50%')
58                            .textAlign(TextAlign.Center)
59                    }
60                    .margin({
61                        left: $r('app.float.details_dialog_button_margin_left'),
62                        right: $r('app.float.details_dialog_button_margin_right')
63                    })
64                    .backgroundColor($r('app.color.transparent'))
65                    .height($r('app.float.details_dialog_button_height'))
66                    .onClick(() => {
67                        Log.info(this.TAG, 'click continue')
68                        this.cancelParam.continueFunc();
69                        this.controller.close()
70                    })
71
72                    Row() {
73                        Divider()
74                            .vertical(true)
75                            .height($r('app.float.dialog_divider_height'))
76                            .color($r('app.color.divider_vertical_color'))
77                    }
78                    .height($r('app.float.details_dialog_button_height'))
79                    .alignItems(VerticalAlign.Center)
80
81                    Button() {
82                        Text($r('app.string.stop'))
83                            .fontSize($r('sys.float.ohos_id_text_size_button1'))
84                            .fontColor(Color.Red)
85                            .fontWeight(FontWeight.Medium)
86                            .width('50%')
87                            .textAlign(TextAlign.Center)
88                    }
89                    .margin({
90                        left: $r('app.float.details_dialog_button_margin_left'),
91                        right: $r('app.float.details_dialog_button_margin_right')
92                    })
93                    .backgroundColor($r('app.color.transparent'))
94                    .height($r('app.float.details_dialog_button_height'))
95                    .onClick(() => {
96                        Log.info(this.TAG, 'click cancel')
97                        this.cancelParam.cancelFunc();
98                        this.controller.close()
99                    })
100                }
101            }
102            .width('100%')
103            .height($r('app.float.details_dialog_button_area_height'))
104        }
105        .padding({
106            left: $r('app.float.max_padding_start'),
107            right: $r('app.float.max_padding_end'),
108            top: $r('app.float.max_padding_start'),
109        })
110        .alignItems(HorizontalAlign.Start)
111        .border({ radius: $r('sys.float.ohos_id_corner_radius_default_l') })
112        .backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
113        .borderRadius($r('app.float.dialog_border_radius'))
114        .width(screenManager.getColumnsWidth(4))
115        .margin({
116            right: $r('app.float.dialog_window_margin'),
117            left: $r('app.float.dialog_window_margin'),
118            bottom: this.isHorizontal || this.isSidebar ? 0 : Constants.DIALOG_BOTTOM_OFFSET + px2vp(this.leftBlank[3])
119        })
120    }
121}
122