• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 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@Entry
17@Component
18struct WidgetCard {
19  /*
20   * The title.
21   */
22  readonly TITLE: Resource = $r('app.string.FormTitle');
23  /*
24   * The subtext.
25   */
26  readonly SUBTEXT: Resource = $r('app.string.FormThemes');
27  /*
28   * The action type.
29   */
30  readonly ACTION_TYPE: string = 'message';
31  /*
32   * The action topic.
33   */
34  readonly TOPIC: Resource = $r('app.string.Topic');
35  /*
36   * The action topic.
37   */
38  readonly TOPIC_AGAIN: Resource = $r('app.string.Topic_Again');
39  /*
40   * The message.
41   */
42  readonly MESSAGE: string = 'message';
43  /*
44   * The width percentage setting.
45   */
46  readonly FULL_WIDTH_PERCENT: string = '100%';
47  /*
48   * The height percentage setting.
49   */
50  readonly FULL_HEIGHT_PERCENT: string = '100%';
51  @State isClick: Boolean = false
52
53  build() {
54    Row() {
55      Column() {
56        Row() {
57          Column() {
58            Text(this.TITLE)
59              .fontColor($r('app.color.fount_color'))
60              .fontSize($r('app.float.16fp'))
61              .height($r('app.float.22vp'))
62              .width($r('app.float.240vp'))
63              .fontWeight(500)
64              .textAlign(TextAlign.Start)
65              .margin({
66                top: $r('app.float.14vp')
67              })
68            Text(this.SUBTEXT)
69              .fontColor($r('app.color.fount_color'))
70              .opacity(0.6)
71              .fontSize($r('app.float.14fp'))
72              .width($r('app.float.240vp'))
73              .height($r('app.float.19vp'))
74              .fontWeight(400)
75              .textAlign(TextAlign.Start)
76              .margin({
77                top: $r('app.float.2vp'),
78                bottom: $r('app.float.15vp')
79              })
80          }
81          .margin({
82            left: $r('app.float.12vp')
83          })
84
85          Column() {
86            if (this.isClick) {
87              Button(this.TOPIC_AGAIN)
88                .backgroundColor($r('app.color.subscribe_events_background'))
89                .fontSize($r('app.float.button_fount_size'))
90                .fontColor($r('app.color.subscribe_events_fount'))
91                .width($r('app.float.72vp'))
92                .height($r('app.float.28vp'))
93                .margin({
94                  right: $r('app.float.12vp')
95                })
96            } else {
97              Button(this.TOPIC)
98                .backgroundColor($r('app.color.subscribe_events_background'))
99                .fontSize($r('app.float.button_fount_size'))
100                .fontColor($r('app.color.subscribe_events_fount'))
101                .width($r('app.float.72vp'))
102                .height($r('app.float.28vp'))
103                .margin({
104                  right: $r('app.float.12vp')
105                })
106            }
107          }
108        }
109      }
110      .backgroundColor($r('app.color.start_window_background'))
111      .width(this.FULL_WIDTH_PERCENT)
112    }
113    .height(this.FULL_HEIGHT_PERCENT)
114    .onClick(() => {
115      this.isClick = true
116      postCardAction(this, {
117        'action': this.ACTION_TYPE,
118        'params': {
119          message: this.MESSAGE
120        }
121      });
122    })
123  }
124}