• 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 { BroadcastConstants } from '@ohos/base/src/main/ets/constants/BroadcastConstants'
17import { Broadcast } from '@ohos/base/src/main/ets/utils/Broadcast'
18import screenManager from '@ohos/base/src/main/ets/manager/ScreenManager'
19import { Constants } from '../../model/common/Constants';
20
21@CustomDialog
22export struct SaveImageDialog {
23    @Consume broadCast: Broadcast
24    @StorageLink('isHorizontal') isHorizontal: boolean = screenManager.isHorizontal();
25    @StorageLink('isSidebar') isSidebar: boolean = screenManager.isSidebar();
26    @StorageLink('leftBlank') leftBlank: [number, number, number, number] = [0, 0, 0, 0];
27    controller: CustomDialogController;
28
29    controllerClose() {
30        this.controller.close()
31    }
32
33    aboutToAppear() {
34        this.broadCast.on(BroadcastConstants.EXIT_SAVE_PROGRESS_CLOSE, this.controllerClose.bind(this));
35    }
36
37    build() {
38        Column() {
39            Row() {
40                Text($r('app.string.edit_save_picture_text')).fontSize($r('sys.float.ohos_id_text_size_body1'))
41                    .flexGrow(1)
42                LoadingProgress().width($r('app.float.image_save_dialog_loading_w'))
43                    .height($r('app.float.image_save_dialog_loading_h'))
44            }
45            .width('100%')
46            .alignItems(VerticalAlign.Center)
47        }
48        .alignItems(HorizontalAlign.Start)
49        .width(screenManager.getColumnsWidth(4))
50        .backgroundColor($r('app.color.white'))
51        .borderRadius($r('app.float.dialog_border_radius'))
52        .margin({
53            right: $r('app.float.dialog_window_margin'),
54            left: $r('app.float.dialog_window_margin'),
55            bottom: this.isHorizontal || this.isSidebar ? 0 : Constants.DIALOG_BOTTOM_OFFSET + px2vp(this.leftBlank[3])
56        })
57        .padding({
58            left: $r('app.float.dialog_content_margin'),
59            right: $r('app.float.dialog_content_margin'),
60            bottom: $r('app.float.dialog_content_margin'),
61            top: $r('app.float.dialog_content_margin')
62        })
63    }
64}