• 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 */
15
16import { Log } from '@ohos/base/src/main/ets/utils/Log';
17import { ActionBarProp } from '../browserOperation/ActionBarProp';
18
19// Large picture title, including primary date title and secondary time and place title
20@Component
21export struct DetailTitle {
22    private TAG: string = 'DetailTitle';
23    @Consume('dateTitle') title: string;
24    @Consume('timeLocationTitle') subTitle: string;
25    isVideoPage: boolean = false;
26
27    private onBuildDone(): void {
28        Log.debug(this.TAG, `onBuildDone, title: ${this.title}, subTitle: ${this.subTitle}`);
29    }
30
31    build() {
32        Row() {
33            Column() {
34                Text(this.title)
35                    .fontSize(ActionBarProp.TITLE_TEXT_SIZE)
36                    .fontColor(this.isVideoPage ? $r('app.color.white') : ActionBarProp.NORMAL_TEXT_COLOR)
37                    .fontWeight(FontWeight.Bold)
38                    .maxLines(1)
39                    .textOverflow({ overflow: TextOverflow.Ellipsis })
40                Text(this.subTitle)
41                    .fontSize($r('sys.float.ohos_id_text_size_over_line'))
42                    .fontFamily(ActionBarProp.REGULAR_FONT)
43                    .fontColor(this.isVideoPage ? $r('app.color.white') : ActionBarProp.NORMAL_SUBTITLE_TEXT_COLOR)
44                    .maxLines(1)
45                    .lineHeight('app.float.detail_sub_title_max_lines')
46                    .margin({ top: $r('sys.float.ohos_id_text_margin_vertical') })
47                    .textOverflow({ overflow: TextOverflow.Ellipsis })
48            }
49            .constraintSize({ minHeight: ('app.float.detail_title_constraint_size_min_height') })
50            .alignItems(HorizontalAlign.Start)
51        }.margin({ left: $r('app.float.actionbar_title_margin'),
52            right: $r('app.float.actionbar_title_margin') })
53        .alignItems(VerticalAlign.Center)
54    }
55}