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 { BroadCast, BroadCastConstants, DateUtil, Log, TimelineData } from '@ohos/common'; 17 18const TAG: string = 'timeline_TimelineTitleComponent'; 19 20// Group Title 21@Component 22export struct TimelineTitleComponent { 23 @State groupData: TimelineData = new TimelineData(); 24 @Consume isSelectedMode: boolean; 25 @State isSelected: boolean = false; 26 @Consume broadCast: BroadCast; 27 mPosition = 0; 28 addresses = ''; 29 30 aboutToAppear(): void { 31 Log.info(TAG, `${this.groupData.startDate} position ${this.position}`); 32 } 33 34 selectStateChange() { 35 AppStorage.setOrCreate('focusUpdate', true); 36 Log.info(TAG, 'change selected.'); 37 this.broadCast.emit(BroadCastConstants.GROUP_SELECT, [this.mPosition]); 38 } 39 40 build() { 41 Flex({ 42 direction: FlexDirection.Row, 43 alignItems: ItemAlign.End 44 }) { 45 Flex({ 46 direction: FlexDirection.Column, 47 alignItems: ItemAlign.Start, 48 justifyContent: FlexAlign.End 49 }) { 50 Text(DateUtil.getGroupDataLocalizedDate(this.groupData.startDate)) 51 .fontSize($r('sys.float.ohos_id_text_size_sub_title2')) 52 .fontFamily($r('app.string.id_text_font_family_medium')) 53 .fontColor($r('sys.color.ohos_id_color_titlebar_text')) 54 .fontWeight(500) 55 .key('TimeLineTitleOfGroup' + this.mPosition) 56 } 57 .height('100%') 58 .layoutWeight(1) 59 60 if (this.isSelectedMode) { 61 Flex({ 62 direction: FlexDirection.Column, 63 justifyContent: FlexAlign.Center, 64 alignItems: ItemAlign.Center 65 }) { 66 Checkbox() 67 .select(this.isSelected) 68 .selectedColor($r('sys.color.ohos_id_color_activated_end')) 69 .key('SelectAllOfGroup' + this.mPosition) 70 .height($r('app.float.icon_size')) 71 .width($r('app.float.icon_size')) 72 .focusable(false) 73 .onChange(() => { 74 this.selectStateChange() 75 }) 76 } 77 .height($r('app.float.icon_title_size_hot')) 78 .width($r('app.float.icon_title_size_hot')) 79 .padding({ 80 left: $r('app.float.group_title_padding_bottom'), 81 }) 82 } 83 } 84 .margin({ 85 left: $r('app.float.max_padding_start'), 86 right: $r('app.float.max_padding_end') 87 }) 88 .padding({ bottom: $r('app.float.group_title_padding_bottom') }) 89 .height($r('app.float.group_title_height')); 90 } 91}