• 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
16@CustomDialog
17export struct WarningDialog {
18  @Link code: number
19  controller: CustomDialogController
20  cancel: () => void
21  confirm: () => void
22
23  build() {
24    Column() {
25      Text('Warning Title').fontSize(20).margin(10)
26      if (this.code == 1) {
27        Text($r("app.string.save_file_has_same_file")).fontSize(16).margin(10)
28      } else if (this.code == 2) {
29        Text($r("app.string.save_file_no_media_permission")).fontSize(16).margin(10)
30      } else {
31        Text($r("app.string.save_file_unknown_reason")).fontSize(16).margin(10)
32      }
33      Flex({ justifyContent: FlexAlign.SpaceAround }) {
34        Button('cancel')
35          .onClick(() => {
36            this.controller.close()
37            this.cancel()
38          })
39          .backgroundColor("0xffffff")
40          .fontColor(Color.Black)
41        Button('confirm')
42          .onClick(() => {
43            this.controller.close()
44            this.confirm()
45          })
46          .backgroundColor("0xffffff")
47          .fontColor(Color.Red)
48      }.margin({ bottom: 10 })
49    }
50  }
51}