1c41cb6d2Sopenharmony_ci/**
2c41cb6d2Sopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3c41cb6d2Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4c41cb6d2Sopenharmony_ci * you may not use this file except in compliance with the License.
5c41cb6d2Sopenharmony_ci * You may obtain a copy of the License at
6c41cb6d2Sopenharmony_ci *
7c41cb6d2Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8c41cb6d2Sopenharmony_ci *
9c41cb6d2Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10c41cb6d2Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11c41cb6d2Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12c41cb6d2Sopenharmony_ci * See the License for the specific language governing permissions and
13c41cb6d2Sopenharmony_ci * limitations under the License.
14c41cb6d2Sopenharmony_ci */
15c41cb6d2Sopenharmony_ciimport ComponentConfig from './ComponentConfig';
16c41cb6d2Sopenharmony_ci
17c41cb6d2Sopenharmony_ci/**
18c41cb6d2Sopenharmony_ci * Subheader layout.
19c41cb6d2Sopenharmony_ci * It's suggested to use it when subheader is needed.
20c41cb6d2Sopenharmony_ci */
21c41cb6d2Sopenharmony_ci@Component
22c41cb6d2Sopenharmony_ciexport struct SubHeader {
23c41cb6d2Sopenharmony_ci  private titleContent: ResourceStr = $r('app.string.endTextEmpty');
24c41cb6d2Sopenharmony_ci
25c41cb6d2Sopenharmony_ci  build() {
26c41cb6d2Sopenharmony_ci    Row() {
27c41cb6d2Sopenharmony_ci      Text(this.titleContent)
28c41cb6d2Sopenharmony_ci        .fontSize($r('app.float.font_14'))
29c41cb6d2Sopenharmony_ci        .fontColor($r('sys.color.ohos_id_color_text_secondary'))
30c41cb6d2Sopenharmony_ci        .fontFamily('HarmonyHeiTi')
31c41cb6d2Sopenharmony_ci        .fontWeight(FontWeight.Medium)
32c41cb6d2Sopenharmony_ci        .width(ComponentConfig.WH_100_100)
33c41cb6d2Sopenharmony_ci    }
34c41cb6d2Sopenharmony_ci    .height($r("app.float.wh_value_48"))
35c41cb6d2Sopenharmony_ci    .alignItems(VerticalAlign.Bottom)
36c41cb6d2Sopenharmony_ci    .padding({
37c41cb6d2Sopenharmony_ci      bottom: $r('app.float.distance_9_5'),
38c41cb6d2Sopenharmony_ci      top: $r('app.float.distance_11_5'),
39c41cb6d2Sopenharmony_ci      left: $r('sys.float.ohos_id_card_margin_start'),
40c41cb6d2Sopenharmony_ci      right: $r("sys.float.ohos_id_card_margin_end")
41c41cb6d2Sopenharmony_ci    })
42c41cb6d2Sopenharmony_ci  }
43c41cb6d2Sopenharmony_ci}
44c41cb6d2Sopenharmony_ci
45c41cb6d2Sopenharmony_ci/**
46c41cb6d2Sopenharmony_ci * Single title text with round corner.
47c41cb6d2Sopenharmony_ci */
48c41cb6d2Sopenharmony_ci@Component
49c41cb6d2Sopenharmony_ciexport struct TitleText {
50c41cb6d2Sopenharmony_ci  @State isTouched: boolean = false;
51c41cb6d2Sopenharmony_ci  private title: string | Resource = '';
52c41cb6d2Sopenharmony_ci  private color: ResourceColor = $r('app.color.font_color_182431');
53c41cb6d2Sopenharmony_ci  private visible: Visibility = Visibility.Visible;
54c41cb6d2Sopenharmony_ci
55c41cb6d2Sopenharmony_ci  build() {
56c41cb6d2Sopenharmony_ci    Row() {
57c41cb6d2Sopenharmony_ci      Row() {
58c41cb6d2Sopenharmony_ci        Text(this.title)
59c41cb6d2Sopenharmony_ci          .fontSize($r("app.float.font_16"))
60c41cb6d2Sopenharmony_ci          .fontColor(this.color)
61c41cb6d2Sopenharmony_ci          .fontWeight(500)
62c41cb6d2Sopenharmony_ci          .textAlign(TextAlign.Start)
63c41cb6d2Sopenharmony_ci          .padding($r('app.float.wh_value_4'))
64c41cb6d2Sopenharmony_ci      }
65c41cb6d2Sopenharmony_ci      .height($r("app.float.wh_value_56"))
66c41cb6d2Sopenharmony_ci      .width(ComponentConfig.WH_100_100)
67c41cb6d2Sopenharmony_ci      .padding({
68c41cb6d2Sopenharmony_ci        left: $r('sys.float.ohos_id_card_margin_start'),
69c41cb6d2Sopenharmony_ci        right: $r('sys.float.ohos_id_card_margin_end') })
70c41cb6d2Sopenharmony_ci      .borderRadius($r("app.float.radius_24"))
71c41cb6d2Sopenharmony_ci      .linearGradient(this.isTouched ? {
72c41cb6d2Sopenharmony_ci        angle: 90,
73c41cb6d2Sopenharmony_ci        direction: GradientDirection.Right,
74c41cb6d2Sopenharmony_ci        colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]]
75c41cb6d2Sopenharmony_ci      } : {
76c41cb6d2Sopenharmony_ci        angle: 90,
77c41cb6d2Sopenharmony_ci        direction: GradientDirection.Right,
78c41cb6d2Sopenharmony_ci        colors: [[$r("sys.color.ohos_id_color_foreground_contrary"), 1], [$r("sys.color.ohos_id_color_foreground_contrary"), 1]]
79c41cb6d2Sopenharmony_ci      })
80c41cb6d2Sopenharmony_ci      .onClick(event => this.clickEvent(event))
81c41cb6d2Sopenharmony_ci      .onTouch((event?: TouchEvent | undefined) => {
82c41cb6d2Sopenharmony_ci        if (event?.type === TouchType.Down) {
83c41cb6d2Sopenharmony_ci          this.isTouched = true;
84c41cb6d2Sopenharmony_ci        }
85c41cb6d2Sopenharmony_ci        if (event?.type === TouchType.Up) {
86c41cb6d2Sopenharmony_ci          this.isTouched = false;
87c41cb6d2Sopenharmony_ci        }
88c41cb6d2Sopenharmony_ci      })
89c41cb6d2Sopenharmony_ci    }
90c41cb6d2Sopenharmony_ci    .width(ComponentConfig.WH_100_100)
91c41cb6d2Sopenharmony_ci    .margin({ top: $r("app.float.distance_12") })
92c41cb6d2Sopenharmony_ci    .padding($r("app.float.distance_4"))
93c41cb6d2Sopenharmony_ci    .borderRadius($r("app.float.radius_24"))
94c41cb6d2Sopenharmony_ci    .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
95c41cb6d2Sopenharmony_ci
96c41cb6d2Sopenharmony_ci  }
97c41cb6d2Sopenharmony_ci
98c41cb6d2Sopenharmony_ci  private clickEvent: (event?: ClickEvent) => void = () => {
99c41cb6d2Sopenharmony_ci  };
100c41cb6d2Sopenharmony_ci}
101c41cb6d2Sopenharmony_ci
102c41cb6d2Sopenharmony_ci/**
103c41cb6d2Sopenharmony_ci * Text title with end text layout with harmony round style used in list item.
104c41cb6d2Sopenharmony_ci * Note that this does not contains the white padding when is touched.
105c41cb6d2Sopenharmony_ci * If you want to use it in single touch layout, wrap it with extra container component.
106c41cb6d2Sopenharmony_ci */
107c41cb6d2Sopenharmony_ci@Component
108c41cb6d2Sopenharmony_ciexport struct TextComponentWithEndText {
109c41cb6d2Sopenharmony_ci  @State endText: string = "";
110c41cb6d2Sopenharmony_ci  @State isTouched: boolean = false;
111c41cb6d2Sopenharmony_ci  private title: string | Resource = '';
112c41cb6d2Sopenharmony_ci
113c41cb6d2Sopenharmony_ci  build() {
114c41cb6d2Sopenharmony_ci    Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
115c41cb6d2Sopenharmony_ci      Row() {
116c41cb6d2Sopenharmony_ci        Text(this.title)
117c41cb6d2Sopenharmony_ci          .fontSize($r('app.float.font_16'))
118c41cb6d2Sopenharmony_ci          .fontColor($r('app.color.font_color_182431'))
119c41cb6d2Sopenharmony_ci          .fontWeight(FontWeight.Medium)
120c41cb6d2Sopenharmony_ci          .textAlign(TextAlign.Start);
121c41cb6d2Sopenharmony_ci      }
122c41cb6d2Sopenharmony_ci
123c41cb6d2Sopenharmony_ci      Row() {
124c41cb6d2Sopenharmony_ci        Text(this.endText)
125c41cb6d2Sopenharmony_ci          .fontSize($r('app.float.font_14'))
126c41cb6d2Sopenharmony_ci          .fontColor($r('app.color.font_color_182431'))
127c41cb6d2Sopenharmony_ci          .margin({ right: $r('app.float.distance_4') })
128c41cb6d2Sopenharmony_ci          .textAlign(TextAlign.End);
129c41cb6d2Sopenharmony_ci        Image('/res/image/ic_settings_arrow.svg')
130c41cb6d2Sopenharmony_ci          .width($r('app.float.wh_value_12'))
131c41cb6d2Sopenharmony_ci          .height($r('app.float.wh_value_24'))
132c41cb6d2Sopenharmony_ci          .fillColor($r("sys.color.ohos_id_color_primary"))
133c41cb6d2Sopenharmony_ci          .opacity($r("app.float.opacity_0_2"))
134c41cb6d2Sopenharmony_ci      }
135c41cb6d2Sopenharmony_ci    }
136c41cb6d2Sopenharmony_ci    .padding({
137c41cb6d2Sopenharmony_ci      left: $r('sys.float.ohos_id_card_margin_start'),
138c41cb6d2Sopenharmony_ci      right: $r('sys.float.ohos_id_card_margin_end')
139c41cb6d2Sopenharmony_ci    })
140c41cb6d2Sopenharmony_ci    .height($r('app.float.wh_value_48'))
141c41cb6d2Sopenharmony_ci    .width(ComponentConfig.WH_100_100)
142c41cb6d2Sopenharmony_ci    .borderRadius($r('app.float.radius_24'))
143c41cb6d2Sopenharmony_ci    .onClick(event => this.clickEvent(event))
144c41cb6d2Sopenharmony_ci    .linearGradient(this.isTouched ? {
145c41cb6d2Sopenharmony_ci      angle: 90,
146c41cb6d2Sopenharmony_ci      direction: GradientDirection.Right,
147c41cb6d2Sopenharmony_ci      colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]]
148c41cb6d2Sopenharmony_ci    } : {
149c41cb6d2Sopenharmony_ci      angle: 90,
150c41cb6d2Sopenharmony_ci      direction: GradientDirection.Right,
151c41cb6d2Sopenharmony_ci      colors: [[$r("sys.color.ohos_id_color_foreground_contrary"), 1], [$r("sys.color.ohos_id_color_foreground_contrary"), 1]]
152c41cb6d2Sopenharmony_ci    })
153c41cb6d2Sopenharmony_ci    .onTouch((event?: TouchEvent | undefined) => {
154c41cb6d2Sopenharmony_ci      if (event?.type === TouchType.Down) {
155c41cb6d2Sopenharmony_ci        this.isTouched = true;
156c41cb6d2Sopenharmony_ci      }
157c41cb6d2Sopenharmony_ci      if (event?.type === TouchType.Up) {
158c41cb6d2Sopenharmony_ci        this.isTouched = false;
159c41cb6d2Sopenharmony_ci      }
160c41cb6d2Sopenharmony_ci    });
161c41cb6d2Sopenharmony_ci  }
162c41cb6d2Sopenharmony_ci
163c41cb6d2Sopenharmony_ci  private clickEvent: (event?: ClickEvent) => void = () => {
164c41cb6d2Sopenharmony_ci  };
165c41cb6d2Sopenharmony_ci}