• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2021-2022 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 */
15import ConfigData from '../../common/constants';
16import Router from '@system.router';
17
18@Component
19export default
20struct HeadComponent {
21  private isActive: boolean= true;
22  private icBackIsVisibility: boolean= true;
23  @Link headName: Resource;
24  @State isTouch: boolean= false;
25
26  build() {
27    Row() {
28      if (this.icBackIsVisibility) {
29        Image($r('app.media.ic_back'))
30          .width($r('app.float.appitem_header_icon_width'))
31          .height($r('app.float.appitem_header_icon_height'))
32          .borderRadius($r('app.float.image_border_radius'))
33          .margin({
34            left: $r('app.float.page_header_icon_margin_l'),
35            top: $r('app.float.page_margin_t'),
36            bottom: $r('app.float.page_margin_b')
37          })
38          .backgroundColor(this.isTouch ? $r('app.color.background_color') : $r('app.color.background_transparent'))
39          .onClick(() => {
40            Router.back();
41          })
42          .onTouch((touchEvent: TouchEvent) => {
43            if (touchEvent.type === TouchType.Down){
44              this.isTouch = true;
45            } else if (touchEvent.type === TouchType.Up){
46              this.isTouch = false;
47            }
48          })
49      }
50      Text(this.headName)
51        .fontColor($r('sys.color.ohos_id_color_text_primary'))
52        .fontSize($r('app.float.page_phrases_tittle_font'))
53        .fontWeight(FontWeight.Medium)
54        .width(ConfigData.WH_100_100)
55        .maxLines(ConfigData.MAX_LINES_1)
56        .textOverflow({ overflow: TextOverflow.Ellipsis })
57        .margin({ left: $r('app.float.page_header_margin_l'), right: $r('app.float.page_margin_r') });
58    }
59    .width(ConfigData.WH_100_100)
60    .height($r('app.float.page_title_height'))
61    .alignItems(VerticalAlign.Center)
62    .align(Alignment.Start)
63  }
64}