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
16/**
17 * The Delete dialog box is displayed at the bottom.
18 */
19@CustomDialog
20export default struct DeleteDialogEx {
21  controller: CustomDialogController;
22  cancel: () => void;
23  confirm: () => void;
24  title: string | Resource;
25  cancalText: string | Resource;
26  confrimText: string | Resource;
27
28  build() {
29    Flex({
30      direction: FlexDirection.Column,
31      justifyContent: FlexAlign.Center,
32      alignItems: ItemAlign.Center
33    }) {
34      Flex({
35        direction: FlexDirection.Column,
36        justifyContent: FlexAlign.Center,
37        alignItems: ItemAlign.Center
38      }) {
39        Text(this.title)
40          .fontSize(24)
41          .textOverflow({ overflow: TextOverflow.Ellipsis })
42          .maxLines(2)
43      }
44      .margin({ bottom: 10 })
45
46      Row() {
47        Flex({
48          direction: FlexDirection.Column,
49          justifyContent: FlexAlign.Center,
50          alignItems: ItemAlign.Center
51        }) {
52          Text(this.cancalText).fontColor($r('sys.color.ohos_id_color_text_primary_activated')).fontSize(20)
53        }
54        .layoutWeight(1)
55        .height(35)
56        .onClick(() => {
57          this.controller.close();
58          this.cancel();
59        })
60
61        Line().width(1).height(25).backgroundColor($r('sys.color.ohos_id_color_list_separator'))
62
63        Flex({
64          direction: FlexDirection.Column,
65          justifyContent: FlexAlign.Center,
66          alignItems: ItemAlign.Center
67        }) {
68          Text(this.confrimText).fontColor(Color.Red).fontSize(20)
69        }
70        .layoutWeight(1)
71        .height(35)
72        .onClick(() => {
73          this.controller.close();
74          this.confirm();
75        })
76      }
77      .height('30vp')
78    }
79    .width('90%')
80    .height($r('app.float.DeleteDialogEx_height'))
81    .borderRadius(20)
82    .padding({
83      bottom: $r('sys.float.ohos_id_dialog_margin_bottom'),
84      right: $r('sys.float.ohos_id_notification_margin_start'),
85      left: $r('sys.float.ohos_id_notification_margin_end')
86    })
87  }
88}