• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 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 ComponentConfig from './ComponentConfig';
16import Router from '@system.router';
17
18const TAG = "CertManager HeadComponent: ";
19
20/**
21 * head custom component
22 */
23@Component
24export default struct HeadComponent {
25  private icBackIsVisibility: boolean= true;
26  private headName: string | Resource = '';
27  @State isTouch: boolean= false;
28
29  build() {
30    Row() {
31      Stack({ alignContent: Alignment.Center }) {
32        Image($r('app.media.ic_back'))
33          .width($r('app.float.wh_value_24'))
34          .height($r('app.float.wh_value_24'))
35          .fillColor($r("sys.color.ohos_id_color_primary"))
36      }
37      .margin({ right: $r('app.float.wh_value_16') })
38      .backgroundColor(this.isTouch ? $r('app.color.color_E3E3E3_grey') : $r('app.color.color_00000000_transparent'))
39      .visibility(this.icBackIsVisibility ? Visibility.Visible : Visibility.None)
40      .onClick(() => {
41        var length = Router.getLength();
42        console.log(TAG + "router length: " + Number(length));
43        Number(length) == 1 ? globalThis.certManagerAbilityContext.terminateSelf() : Router.back();
44      })
45      .onTouch((event: TouchEvent) => {
46        if (event.type === TouchType.Down) {
47          this.isTouch = true;
48        }
49        if (event.type === TouchType.Up) {
50          this.isTouch = false;
51        }
52      });
53
54      Text(this.headName)
55        .fontSize($r('app.float.head_font_20'))
56        .lineHeight($r('app.float.wh_value_33'))
57        .fontFamily('HarmonyHeiTi-Bold')
58        .fontWeight(FontWeight.Regular)
59        .fontColor($r('app.color.font_color_182431'))
60        .maxLines(ComponentConfig.MAX_LINES_1)
61        .textOverflow({ overflow: TextOverflow.Ellipsis })
62        .textAlign(TextAlign.Start)
63        .margin({ top: $r('app.float.wh_value_13'), bottom: $r('app.float.wh_value_15') });
64    }
65    .width(ComponentConfig.WH_100_100)
66    .padding({ left: $r('app.float.wh_value_24') })
67    .height($r('app.float.wh_value_56'))
68    .alignItems(VerticalAlign.Center)
69    .align(Alignment.Start)
70  }
71}