• 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';
18import { Action } from '../browserOperation/Action';
19
20// Single line title, fixed content
21@Component
22export struct SingleTitle {
23    private TAG: string = 'SingleTitle';
24    @Link actionBarProp: ActionBarProp;
25
26    private onBuildDone(): void {
27        Log.info(this.TAG, `onBuildDone, title: ${this.actionBarProp.getTitle()}`);
28    }
29
30    build() {
31        Row() {
32            Text(this.actionBarProp.getTitle())
33                .fontSize(this.actionBarProp.getIsHeadTitle()
34                    ? ActionBarProp.HEAD_TITLE_ONE_LINE_TEXT_SIZE : ActionBarProp.TITLE_TEXT_SIZE)
35                .fontWeight(FontWeight.Bold)
36                .fontColor(ActionBarProp.NORMAL_TEXT_COLOR)
37                .maxLines(2)
38                .textOverflow({ overflow: TextOverflow.Ellipsis })
39        }
40        .width('80%')
41        .alignItems(VerticalAlign.Center)
42        .padding({
43            left: this.actionBarProp.getLeftAction().equals(Action.NONE) ?
44            $r('app.float.default_actionbar_padding_start_without_tab_bar') :
45            $r('app.float.actionbar_title_margin')
46        })
47    }
48}