• 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 */
15import type { DialogCallback } from '../../model/common/DialogUtil';
16import { Log } from '../../utils/Log';
17import { ColumnSize, ScreenManager } from '../../model/common/ScreenManager';
18import { Constants } from '../../model/common/Constants';
19
20@CustomDialog
21export struct ThirdDeleteDialog {
22  private TAG: string = 'DeleteDialog'
23  @StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal();
24  @StorageLink('leftBlank') leftBlank: [number, number, number, number] = [0, 0, 0, 0];
25  @Consume dialogCallback: DialogCallback;
26  @Consume dialogMessage: Resource;
27  @StorageLink('confirmText') confirmText: Resource = $r('app.string.dialog_delete');
28  controller: CustomDialogController;
29
30  private uris: any;
31  private thirdAppName: string;
32
33  aboutToAppear() {
34    this.uris = AppStorage.Get("uris");
35    this.thirdAppName = AppStorage.Get("appName");
36  }
37
38  build() {
39    Column() {
40      Column() {
41        Stack({ alignContent: Alignment.Bottom}) {
42
43          if(this.uris.length > 1) {
44            Image(this.uris[1])
45              .objectFit(ImageFit.Cover)
46              .border({ radius: $r('sys.float.ohos_id_corner_radius_default_m')})
47              .height($r('app.float.third_delete_dialog_ico_height'))
48              .width('100%')
49              .opacity(0.4)
50              .padding({ left: $r('app.float.third_delete_dialog_second_ico_margin'),
51                right: $r('app.float.third_delete_dialog_second_ico_margin')})
52          }
53
54          Image(this.uris[0])
55            .objectFit(ImageFit.Cover)
56            .border({ radius: $r('sys.float.ohos_id_corner_radius_default_m')})
57            .height(this.uris.length > 1 ? $r('app.float.third_delete_dialog_ico_height_multi'):
58            $r('app.float.third_delete_dialog_ico_height'))
59            .width('100%')
60            .margin({ bottom: this.uris.length > 1 ? $r('app.float.dialog_button_and_text_margin') :
61            $r('app.float.dialog_offset_bottom')})
62        }
63
64        Text($r('app.string.third_delete_dialog_message', this.thirdAppName, this.uris.length))
65          .textAlign(TextAlign.Center)
66          .fontSize($r('sys.float.ohos_id_text_size_body1'))
67          .fontWeight(FontWeight.Regular)
68          .fontColor($r('sys.color.ohos_id_color_text_primary'))
69          .margin({ top: $r('app.float.first_delete_dialog_ico_margin_bottom')})
70      }
71      .alignItems(HorizontalAlign.Center)
72      .width('100%')
73      .margin({
74        top: $r('app.float.dialog_content_margin'),
75        bottom: $r('app.float.dialog_button_and_text_margin'),
76      })
77
78      Stack({ alignContent: Alignment.Top }) {
79        Row() {
80          Column() {
81            Button() {
82              Text($r('app.string.dialog_cancel'))
83                .fontSize($r('sys.float.ohos_id_text_size_button1'))
84                .fontColor($r('app.color.color_control_highlight'))
85                .fontWeight(FontWeight.Medium)
86                .width('100%')
87                .textAlign(TextAlign.Center)
88            }
89            .margin({
90              right: $r('app.float.dialog_double_buttons_margin')
91            })
92            .backgroundColor($r('app.color.transparent'))
93            .height($r('app.float.details_dialog_button_height'))
94            .onClick(() => {
95              Log.debug(this.TAG, `cancelCallback`);
96              this.controller.close();
97              this.dialogCallback && this.dialogCallback.cancelCallback();
98            })
99          }.width('50%')
100
101
102          Divider()
103            .vertical(true)
104            .height(Constants.DEFAULT_DIVIDER_HEIGHT)
105            .color(Constants.DEFAULT_DIVIDER_COLOR)
106
107          Column() {
108            Button() {
109              Text(this.confirmText)
110                .fontSize($r('sys.float.ohos_id_text_size_button1'))
111                .fontColor($r('sys.color.ohos_id_color_warning'))
112                .fontWeight(FontWeight.Medium)
113                .width('100%')
114                .textAlign(TextAlign.Center)
115            }
116            .margin({
117              left: $r('app.float.dialog_double_buttons_margin'),
118            })
119            .backgroundColor($r('app.color.transparent'))
120            .height($r('app.float.details_dialog_button_height'))
121            .onClick(() => {
122              Log.debug(this.TAG, `confirmCallback`);
123              this.controller.close();
124              this.dialogCallback && this.dialogCallback.confirmCallback();
125            })
126          }.width('50%')
127
128        }
129      }
130      .width('100%')
131      .height($r('app.float.details_dialog_button_area_height'))
132    }
133    .borderRadius($r('sys.float.ohos_id_corner_radius_default_m'))
134    .width(ScreenManager.getInstance().getColumnsWidth(ColumnSize.COLUMN_FOUR))
135    .backgroundColor($r('app.color.white'))
136    .margin({
137      right: $r('app.float.dialog_window_margin'),
138      left: $r('app.float.dialog_window_margin'),
139      bottom: this.isHorizontal ? 0 : Constants.DIALOG_BOTTOM_OFFSET + px2vp(this.leftBlank[3])
140    })
141    .padding({ left: $r('app.float.dialog_content_margin'), right: $r('app.float.dialog_content_margin') })
142    .alignItems(HorizontalAlign.Center)
143    .shadow({
144      radius: $r('app.float.dialog_defult_shadow_m_radio'),
145      color: $r('app.color.dialog_defult_shadow_m_color'),
146      offsetX: $r('app.float.dialog_defult_shadow_m_offsetX'),
147      offsetY: $r('app.float.dialog_defult_shadow_m_offsetY')
148    })
149  }
150}
151