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