• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2023 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 { BroadCast, Constants } from '@ohos/common';
17
18@Component
19export struct CropResetButton {
20  @Consume broadCast: BroadCast;
21  @Consume isCropReset: boolean;
22  @State buttonStatus: String = Constants.BUTTON_STATUS_NORMAL;
23  @State isPcStyle: boolean = true;
24  @Consume('verticalScreen') isVerticalScreen: boolean;
25
26  // 编辑重置按钮按照小按钮的参数设置
27  build() {
28    if (this.isPcStyle) {
29      Stack() {
30        Flex({
31          direction: FlexDirection.Column,
32          alignItems: ItemAlign.Center,
33          justifyContent: FlexAlign.Center
34        }) {
35          Text($r('app.string.cropModeReset_text'))
36            .fontSize($r('sys.float.ohos_id_text_size_body2'))
37            .fontColor('#5291FF')
38            .textAlign(TextAlign.Center)
39            .padding({
40              left: $r('app.float.menu_padding_horizontal'),
41              right: $r('app.float.menu_padding_horizontal')
42            })
43        }
44        .height($r('app.float.small_button_height'))
45        .borderRadius($r('app.float.small_button_radius'))
46        .onClick(() => {
47          this.broadCast.emit(Constants.CROP_RESET_CLICKED, []);
48        })
49        .backgroundColor('#1affffff')
50        .opacity(this.isCropReset ? 1 : Constants.BUTTON_INVALID_OPACITY)
51      }.borderRadius($r('app.float.small_button_radius'))
52      .height($r('app.float.small_button_height'))
53    } else {
54      Column() {
55        Text($r('app.string.cropModeReset_text'))
56          .key('PhotoEditCropReset')
57          .fontSize(this.isVerticalScreen ? Constants.VERTICAL_RESET_BUTTON_TEXT_SIZE :
58          Constants.HORIZONTAL_RESET_BUTTON_TEXT_SIZE)
59          .fontColor('#5291FF')
60          .textAlign(TextAlign.Center)
61          .visibility(this.isCropReset ? Visibility.Visible : Visibility.Hidden)
62      }
63      .onClick(() => {
64        this.broadCast.emit(Constants.CROP_RESET_CLICKED, []);
65      })
66      .width(this.isVerticalScreen ? Constants.PERCENT_100 : Constants.HORIZONTAL_RESET_BUTTON_WIDTH)
67      .height(this.isVerticalScreen ? Constants.VERTICAL_RESET_BUTTON_HEIGHT : Constants.HORIZONTAL_RESET_BUTTON_HEIGHT)
68    }
69  }
70}