• 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 Constants from '../common/constant';
17
18@Extend(Button) function customizeButton() {
19  .backgroundColor(Color.Transparent)
20  .fontColor($r('app.color.button_text_color'))
21  .fontSize(Constants.BUTTON_TEXT_FONT_SIZE)
22  .fontWeight(Constants.BUTTON_TEXT_FONT_WEIGHT)
23  .height(Constants.BUTTON_HEIGHT)
24  .width(Constants.BUTTON_WIDTH)
25}
26@CustomDialog
27struct LowCustomDialog {
28  controller: CustomDialogController
29  cancel: () => void
30
31  build() {
32    Column() {
33      Column(){
34        Row(){
35          Text($r('app.string.TEXT_LOW_TEMPERATURE_THERMALDIALOG_LOW'))
36            .fontSize(Constants.DIALOG_TITLE_FONT_SIZE)
37            .fontColor($r('app.color.title_color'))
38            .fontWeight(Constants.DIALOG_TITLE_FONT_WEIGHT)
39            .lineHeight(Constants.DIALOG_TITLE_LINE_HEIGHT)
40            .opacity(Constants.DIALOG_TITLE_OPACITY)
41        }
42      }.margin({
43        top: Constants.DIALOG_TITLE_MARGIN_TOP,
44        bottom: Constants.DIALOG_TITLE_MARGIN_BOTTOM
45      })
46      Row() {
47        Button($r('app.string.BUTTON_KNOW'))
48          .onClick(() => {
49            this.controller.close()
50            this.cancel();
51          }).customizeButton()
52      }
53    }
54    .backgroundColor($r('app.color.default_background_color'))
55    .borderRadius(Constants.DIALOG_BORDER_RADIUS)
56    .width(Constants.DIALOG_WIDTH)
57    .height(Constants.DIALOG_HEIGHT)
58  }
59}
60
61@Entry
62@Component
63struct LowDialog {
64  dialogController: CustomDialogController = new CustomDialogController({
65    builder: LowCustomDialog({
66      cancel: this.onCancel,
67    }),
68    cancel: this.existApp,
69    autoCancel: false,
70    alignment: DialogAlignment.Center,
71    offset: { dx: 0, dy: -20 },
72    gridCount: 4,
73    customStyle: true
74  })
75
76  onCancel() {
77    globalThis.thermalLowWindow.destroy();
78    globalThis.g_thermalLowWindowFirst = undefined;
79    globalThis.extensionContext.terminateSelf();
80  }
81
82  existApp() {
83    this.onCancel();
84  }
85
86  build() {
87    Column(this.dialogController.open()) {}
88  }
89}
90