100aff185Sopenharmony_ci/*
200aff185Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
300aff185Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
400aff185Sopenharmony_ci * you may not use this file except in compliance with the License.
500aff185Sopenharmony_ci * You may obtain a copy of the License at
600aff185Sopenharmony_ci *
700aff185Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
800aff185Sopenharmony_ci *
900aff185Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1000aff185Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1100aff185Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1200aff185Sopenharmony_ci * See the License for the specific language governing permissions and
1300aff185Sopenharmony_ci * limitations under the License.
1400aff185Sopenharmony_ci */
1500aff185Sopenharmony_ci
1600aff185Sopenharmony_ciimport { BroadCast, BroadCastConstants, DateUtil, Log, TimelineData } from '@ohos/common';
1700aff185Sopenharmony_ci
1800aff185Sopenharmony_ciconst TAG: string = 'timeline_TimelineTitleComponent';
1900aff185Sopenharmony_ci
2000aff185Sopenharmony_ci// Group Title
2100aff185Sopenharmony_ci@Component
2200aff185Sopenharmony_ciexport struct TimelineTitleComponent {
2300aff185Sopenharmony_ci  @State groupData: TimelineData = new TimelineData();
2400aff185Sopenharmony_ci  @Consume isSelectedMode: boolean;
2500aff185Sopenharmony_ci  @State isSelected: boolean = false;
2600aff185Sopenharmony_ci  @Consume broadCast: BroadCast;
2700aff185Sopenharmony_ci  mPosition = 0;
2800aff185Sopenharmony_ci  addresses = '';
2900aff185Sopenharmony_ci
3000aff185Sopenharmony_ci  aboutToAppear(): void {
3100aff185Sopenharmony_ci    Log.info(TAG, `${this.groupData.startDate} position ${this.position}`);
3200aff185Sopenharmony_ci  }
3300aff185Sopenharmony_ci
3400aff185Sopenharmony_ci  selectStateChange() {
3500aff185Sopenharmony_ci    AppStorage.setOrCreate('focusUpdate', true);
3600aff185Sopenharmony_ci    Log.info(TAG, 'change selected.');
3700aff185Sopenharmony_ci    this.broadCast.emit(BroadCastConstants.GROUP_SELECT, [this.mPosition]);
3800aff185Sopenharmony_ci  }
3900aff185Sopenharmony_ci
4000aff185Sopenharmony_ci  build() {
4100aff185Sopenharmony_ci    Flex({
4200aff185Sopenharmony_ci      direction: FlexDirection.Row,
4300aff185Sopenharmony_ci      alignItems: ItemAlign.End
4400aff185Sopenharmony_ci    }) {
4500aff185Sopenharmony_ci      Flex({
4600aff185Sopenharmony_ci        direction: FlexDirection.Column,
4700aff185Sopenharmony_ci        alignItems: ItemAlign.Start,
4800aff185Sopenharmony_ci        justifyContent: FlexAlign.End
4900aff185Sopenharmony_ci      }) {
5000aff185Sopenharmony_ci        Text(DateUtil.getGroupDataLocalizedDate(this.groupData.startDate))
5100aff185Sopenharmony_ci          .fontSize($r('sys.float.ohos_id_text_size_sub_title2'))
5200aff185Sopenharmony_ci          .fontFamily($r('app.string.id_text_font_family_medium'))
5300aff185Sopenharmony_ci          .fontColor($r('sys.color.ohos_id_color_titlebar_text'))
5400aff185Sopenharmony_ci          .fontWeight(500)
5500aff185Sopenharmony_ci          .key('TimeLineTitleOfGroup' + this.mPosition)
5600aff185Sopenharmony_ci      }
5700aff185Sopenharmony_ci      .height('100%')
5800aff185Sopenharmony_ci      .layoutWeight(1)
5900aff185Sopenharmony_ci
6000aff185Sopenharmony_ci      if (this.isSelectedMode) {
6100aff185Sopenharmony_ci        Flex({
6200aff185Sopenharmony_ci          direction: FlexDirection.Column,
6300aff185Sopenharmony_ci          justifyContent: FlexAlign.Center,
6400aff185Sopenharmony_ci          alignItems: ItemAlign.Center
6500aff185Sopenharmony_ci        }) {
6600aff185Sopenharmony_ci          Checkbox()
6700aff185Sopenharmony_ci            .select(this.isSelected)
6800aff185Sopenharmony_ci            .selectedColor($r('sys.color.ohos_id_color_activated_end'))
6900aff185Sopenharmony_ci            .key('SelectAllOfGroup' + this.mPosition)
7000aff185Sopenharmony_ci            .height($r('app.float.icon_size'))
7100aff185Sopenharmony_ci            .width($r('app.float.icon_size'))
7200aff185Sopenharmony_ci            .focusable(false)
7300aff185Sopenharmony_ci            .onChange(() => {
7400aff185Sopenharmony_ci              this.selectStateChange()
7500aff185Sopenharmony_ci            })
7600aff185Sopenharmony_ci        }
7700aff185Sopenharmony_ci        .height($r('app.float.icon_title_size_hot'))
7800aff185Sopenharmony_ci        .width($r('app.float.icon_title_size_hot'))
7900aff185Sopenharmony_ci        .padding({
8000aff185Sopenharmony_ci          left: $r('app.float.group_title_padding_bottom'),
8100aff185Sopenharmony_ci        })
8200aff185Sopenharmony_ci      }
8300aff185Sopenharmony_ci    }
8400aff185Sopenharmony_ci    .margin({
8500aff185Sopenharmony_ci      left: $r('app.float.max_padding_start'),
8600aff185Sopenharmony_ci      right: $r('app.float.max_padding_end')
8700aff185Sopenharmony_ci    })
8800aff185Sopenharmony_ci    .padding({ bottom: $r('app.float.group_title_padding_bottom') })
8900aff185Sopenharmony_ci    .height($r('app.float.group_title_height'));
9000aff185Sopenharmony_ci  }
9100aff185Sopenharmony_ci}