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