1/*
2 * Copyright (c) 2021-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
16@Styles
17function pressStyles() {
18  .backgroundColor($r('app.color.button_pressStyles'))
19}
20
21@Styles
22function normalStyles() {
23  .borderRadius($r('app.float.common_borderRadius8'))
24  .backgroundColor($r('app.color.transparent_color'))
25}
26
27@Component
28export struct DialogTitle {
29  title: Resource;
30
31  build() {
32    Text(this.title)
33      .fontSize($r('app.float.common_font_size20'))
34      .fontColor($r('app.color.dialog_title_font_color'))
35      .fontWeight(FontWeight.Medium)
36      .width('100%')
37      .padding({
38        top: $r('app.float.common_padding14'),
39        bottom: $r('app.float.common_padding14')
40      })
41  }
42}
43
44@Component
45export struct DialogButton {
46  text: Resource;
47  color: Resource = $r('app.color.dialog_button_blue');
48  bgColor: Resource = $r('app.color.transparent_color');
49  @Prop isDisabled: boolean;
50  click: Function;
51
52  build() {
53    Row() {
54      Row() {
55        Text(this.text)
56          .fontSize($r('app.float.common_font_size16'))
57          .fontColor(this.color)
58          .fontWeight(FontWeight.Medium)
59      }.height('100%')
60      .width('100%')
61      .justifyContent(FlexAlign.Center)
62      .onClick(() => {
63        if (!this.click || this.isDisabled) {
64          return
65        }
66        this.click()
67      })
68    }
69    .height($r('app.float.common_line_height36'))
70    .layoutWeight(1)
71    .backgroundColor(this.bgColor)
72    .stateStyles({
73      pressed: pressStyles,
74      normal: normalStyles
75    })
76    .opacity(this.isDisabled ? $r('app.float.common_opacity5') : $r('app.float.common_opacity10'))
77    .borderRadius($r('app.float.common_borderRadius18'))
78  }
79}
80
81@Component
82export struct DialogButtonDivider {
83  build() {
84    Divider().vertical(true)
85      .margin({ left: $r('app.float.common_margin10'), right: $r('app.float.common_margin10') })
86      .height($r('app.float.divider_height24'))
87      .color($r('app.color.dialog_button_divider_color'))
88  }
89}
90