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