• 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 { CheckEmptyUtils } from '../utils/CheckEmptyUtils'
17import { ResourceManager } from '../manager/ResourceManager'
18import { GridLayoutItemInfo } from '../bean/GridLayoutItemInfo'
19
20@CustomDialog
21export struct DeleteDialog {
22  private appInfo: GridLayoutItemInfo = new GridLayoutItemInfo()
23  private dialogContent: string = ''
24  private controller: CustomDialogController
25  private confirm: () => void = () => {
26  }
27  private mResourceManager: ResourceManager = ResourceManager.getInstance(getContext(this))
28  @State icon: string = ''
29
30  public aboutToAppear(): void  {
31    if (CheckEmptyUtils.isEmpty(this.icon)) {
32      this.updateIcon()
33    }
34  }
35
36  public iconLoadCallback: (image: string) => void = (image: string) => {
37    this.icon = image
38  }
39
40  public updateIcon() {
41    this.mResourceManager.getAppIconWithCache(this.appInfo.appIconId, this.appInfo.bundleName,
42    this.iconLoadCallback, '');
43  }
44
45  build() {
46    Column() {
47      Image(this.icon)
48        .width(60)
49        .height(60)
50      Row() {
51        Text($r('app.string.whether_to_uninstall'))
52          .fontSize(17)
53          .fontColor(Color.Black)
54          .fontWeight(FontWeight.Medium)
55        Text(this.dialogContent)
56          .fontSize(17)
57          .fontColor(Color.Black)
58          .fontWeight(FontWeight.Medium)
59      }
60      .margin({ top: 10 })
61
62      Row() {
63        Button($r('app.string.cancel'))
64          .layoutWeight(7)
65          .fontColor(Color.Blue)
66          .backgroundColor(Color.White)
67          .margin(5)
68          .onClick(() => {
69            this.controller.close()
70
71          })
72        Divider()
73          .width(1).height(35)
74          .backgroundColor('#8F8F8F')
75        Button($r('app.string.uninstall'))
76          .layoutWeight(7)
77          .fontColor(Color.Red)
78          .backgroundColor(Color.White)
79          .margin(5)
80          .onClick(() => {
81            this.confirm()
82            this.controller.close()
83          })
84      }
85      .margin({ top: 10 })
86    }
87    .margin({ bottom: 100 })
88    .width('80%')
89    .borderRadius(15)
90    .padding(16)
91    .backgroundColor(Color.White)
92  }
93}