• 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 { ActionBarColorMode, ActionBarSelectionMode } from '../browserOperation/ActionBarMode';
17import { Log } from '@ohos/base/src/main/ets/utils/Log';
18import { ActionBarProp } from '../browserOperation/ActionBarProp';
19
20// Select the mode title, the content changes with the number of selections
21@Component
22export struct SelectionTitle {
23    private TAG: string = 'SelectionTitle';
24    @Link actionBarProp: ActionBarProp;
25    @Consume('selectedCount') count: number;
26
27    private onBuildDone(): void {
28        Log.info(this.TAG, `onBuildDone, count: ${this.count}`);
29    }
30
31    build() {
32        Row() {
33            Text((this.actionBarProp.getSelectionMode() == ActionBarSelectionMode.MULTI ?
34                (this.count == 0 ? ActionBarProp.MULTI_UNSELECT_TITLE :
35                    (this.actionBarProp.getMaxSelectCount() > 0 ?
36                    ActionBarProp.getCountDetailExternalSelectedTitle(this.count,
37                    this.actionBarProp.getMaxSelectCount()) :
38                    ActionBarProp.getCountDetailSelectedTitle(this.count))) :
39                ActionBarProp.SINGLE_UNSELECT_TITLE))
40                .fontSize(ActionBarProp.TITLE_TEXT_SIZE)
41                .fontWeight(FontWeight.Bold)
42                .fontColor(this.actionBarProp.getColorMode() == ActionBarColorMode.TRANSPARENT ?
43                    ActionBarProp.TRANSPARENT_TEXT_COLOR : ActionBarProp.NORMAL_TEXT_COLOR)
44                .maxLines(1)
45                .textOverflow({ overflow: TextOverflow.Ellipsis })
46        }
47        .margin({ left: $r('app.float.actionbar_title_margin'),
48            right: $r('app.float.actionbar_title_margin') })
49        .alignItems(VerticalAlign.Center)
50    }
51}