• 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  screenManager  from '@ohos/base/src/main/ets/manager/ScreenManager';
17import { Constants } from '../../model/common/Constants';
18
19@Observed
20export class OperateParam {
21    moveFunc: Function
22    copyFunc: Function
23}
24
25@CustomDialog
26export struct CopyOrMoveDialog {
27    @StorageLink('isHorizontal') isHorizontal: boolean = screenManager.isHorizontal();
28    @StorageLink('isSidebar') isSidebar: boolean = screenManager.isSidebar();
29    @StorageLink('leftBlank') leftBlank: [number, number, number, number] = [0, 0, 0, 0];
30    controller: CustomDialogController;
31    dataTime: string;
32    @Consume operateParam: OperateParam;
33
34    aboutToAppear() {
35
36    }
37
38    build() {
39        Column() {
40            Row() {
41                Text($r('app.string.copy_or_move'))
42                    .fontSize($r('sys.float.ohos_id_text_size_headline7'))
43                    .fontWeight(FontWeight.Medium)
44                    .fontColor($r('sys.color.ohos_id_color_text_primary'))
45            }.alignItems(VerticalAlign.Center)
46            .height($r('app.float.dialog_title_height'))
47
48
49            Row() {
50                Column() {
51                    Text($r('app.string.copy'))
52                        .fontSize($r('sys.float.ohos_id_text_size_sub_title2'))
53                        .fontFamily($r('app.string.id_text_font_family_regular'))
54                        .fontColor($r('sys.color.ohos_id_color_text_primary'))
55                }
56            }.alignItems(VerticalAlign.Center)
57            .height($r('app.float.dialog_list_card_height'))
58            .width('100%')
59            .onClick(() => {
60                this.controller.close()
61                this.operateParam.copyFunc();
62            })
63
64
65            Row() {
66                Divider()
67                    .vertical(false)
68                    .width('100%')
69                    .color($r('sys.color.ohos_id_color_list_separator'))
70            }
71
72            Row() {
73                Column() {
74                    Text($r('app.string.move'))
75                        .fontSize($r('sys.float.ohos_id_text_size_sub_title2'))
76                        .fontFamily($r('app.string.id_text_font_family_regular'))
77                        .fontColor($r('sys.color.ohos_id_color_text_primary'))
78                }
79
80            }
81            .alignItems(VerticalAlign.Center)
82            .height($r('app.float.dialog_list_card_height'))
83            .width('100%')
84            .margin({
85                bottom: $r('app.float.select_model_dialog_margin') })
86            .onClick(() => {
87                this.controller.close()
88                this.operateParam.moveFunc();
89            })
90
91            Stack({ alignContent: Alignment.Top }) {
92                Button() {
93                    Text($r('app.string.cancel_button'))
94                        .fontSize($r('sys.float.ohos_id_text_size_button1'))
95                        .fontColor($r('app.color.color_control_highlight'))
96                        .width('100%')
97                        .textAlign(TextAlign.Center)
98                        .fontWeight(FontWeight.Medium)
99                }
100                .backgroundColor($r('app.color.transparent'))
101                .height($r('app.float.details_dialog_button_height'))
102                .onClick(() => {
103                    this.controller.close()
104                })
105            }.width('100%')
106            .height($r('app.float.details_dialog_button_area_height'))
107        }
108        .padding({ left: $r('app.float.dialog_content_margin'), right: $r('app.float.dialog_content_margin') })
109        .alignItems(HorizontalAlign.Start)
110        .borderRadius($r('app.float.dialog_border_radius'))
111        .width(screenManager.getColumnsWidth(4))
112        .backgroundColor($r('app.color.white'))
113        .margin({
114            right: $r('app.float.dialog_window_margin'),
115            left: $r('app.float.dialog_window_margin'),
116            bottom: this.isHorizontal || this.isSidebar ? 0 : Constants.DIALOG_BOTTOM_OFFSET + px2vp(this.leftBlank[3])
117        })
118    }
119}
120