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 { TimelineDataItem } from '../data/TimelineDataItem'; 18import { DateUtil } from '@ohos/base/src/main/ets/utils/DateUtil'; 19import { Broadcast } from '@ohos/base/src/main/ets/utils/Broadcast'; 20import { BroadcastConstants } from '@ohos/base/src/main/ets/constants/BroadcastConstants'; 21import { LazyItem} from '@ohos/base/src/main/ets/vm/ItemDataSource'; 22 23const TAG = "TimelineTitleComponent" 24// Group Title 25@Component 26export struct TimelineTitleComponent { 27 @Consume broadCast: Broadcast; 28 @Consume isSelectedMode: boolean; 29 lazyItem: LazyItem<TimelineDataItem> 30 timelineDataItem: TimelineDataItem; 31 addresses = ''; 32 33 aboutToAppear(): void { 34 Log.info(TAG, `${this.timelineDataItem.dateAdded}`); 35 } 36 37 private selectStateChange() { 38 Log.info(TAG, `change selected ${this.isSelectedMode}`); 39 if (this.isSelectedMode) { 40 let isSelect = !this.timelineDataItem.isSelect() 41 this.timelineDataItem.setSelect(isSelect) 42 if (this.lazyItem) { 43 this.lazyItem.update(this.timelineDataItem) 44 } 45 this.broadCast.emit(BroadcastConstants.GROUP_SELECT, []); 46 } 47 } 48 49 build() { 50 Row() { 51 Column() { 52 Text(DateUtil.getGroupDataLocalizedDate(this.timelineDataItem.dateAdded)) 53 .fontSize($r('sys.float.ohos_id_text_size_sub_title1')) 54 .fontFamily($r('app.string.id_text_font_family_medium')) 55 .fontColor($r('sys.color.ohos_id_color_titlebar_text')) 56 } 57 .height('100%') 58 .justifyContent(FlexAlign.End) 59 .alignItems(HorizontalAlign.Start) 60 .layoutWeight(1) 61 62 if (this.isSelectedMode) { 63 Column() { 64 Image(this.timelineDataItem.isSelect() ? $r('app.media.ic_gallery_public_checkbox_filled') : $r('app.media.ic_checkbox_off')) 65 .height($r('app.float.icon_size')) 66 .width($r('app.float.icon_size')) 67 } 68 .height($r('app.float.icon_title_size_hot')) 69 .width($r('app.float.icon_title_size_hot')) 70 .justifyContent(FlexAlign.Center) 71 .alignItems(HorizontalAlign.Center) 72 .padding({ 73 left: $r('app.float.group_title_padding_bottom'), 74 }) 75 .onClick(() => { 76 this.selectStateChange() 77 }) 78 } 79 } 80 .alignItems(VerticalAlign.Bottom) 81 .margin({ 82 left: $r('app.float.max_padding_start'), 83 right: $r('app.float.max_padding_end'), 84 bottom: $r('app.float.group_title_padding_bottom') 85 }) 86 .height($r('app.float.group_title_height')); 87 } 88}