• 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 { ArrayUtil } from '../../../../../../common/src/main/ets/util/ArrayUtil';
17import { DataItemType } from '../../../../../../feature/contact/src/main/ets/contract/DataType';
18import StringFormatUtil from '../../util/StringFormatUtil'
19import { Birthday } from '../../../../../../feature/contact/src/main/ets/contract/Birthday';
20
21@Component
22export default struct DetailInfoList {
23  private dataType: DataItemType;
24  private List: string;
25  private hasArrow: boolean;
26
27  build() {
28    Column() {
29      if (!ArrayUtil.isEmpty(JSON.parse(this.List))) {
30        Divider()
31          .color($r("sys.color.ohos_id_color_list_separator"))
32        List() {
33          ForEach(JSON.parse(this.List), (item, index) => {
34            ListItem() {
35              DetailInfoListItem({
36                title: this.dataType == DataItemType.EVENT ? StringFormatUtil.stringFormatDateResource(item.data, item?.type == Birthday.TYPE_LUNARBIRTHDAY) : item.data,
37                content: item.labelName,
38                hasArrow: this.hasArrow,
39              });
40            }
41          }, item => JSON.stringify(item))
42        }
43        .divider({ strokeWidth: $r("app.float.id_divide_width"), color: $r("sys.color.ohos_id_color_list_separator") })
44        .scrollBar(BarState.Off)
45        .edgeEffect(EdgeEffect.None)
46      }
47    }
48    .width("100%")
49  }
50}
51
52@Component
53struct DetailInfoListItem {
54  private title: string;
55  private content: string;
56  private hasArrow: boolean;
57
58  build() {
59    Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
60      Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Start }) {
61        Text(this.title)
62          .fontSize($r("sys.float.ohos_id_text_size_body1"))
63          .fontColor($r("sys.color.ohos_id_color_text_primary"))
64          .fontWeight(FontWeight.Medium)
65          .textOverflow({ overflow: TextOverflow.Ellipsis })
66          .maxLines(2)
67        Text(this.content)
68          .fontSize($r("sys.float.ohos_id_text_size_body2"))
69          .fontColor($r("sys.color.ohos_id_color_text_tertiary"))
70          .fontWeight(FontWeight.Regular)
71          .margin({ top: $r("app.float.id_card_margin_sm") })
72      }
73      .flexShrink(1)
74
75      Row() {
76        Image($r('app.media.ic_arrow_right_grey'))
77          .align(Alignment.Center)
78          .width($r("app.float.id_card_image_xs"))
79          .height($r("app.float.id_card_image_small"))
80          .visibility(this.hasArrow ? Visibility.Visible : Visibility.Hidden)
81          .opacity(0.2)
82      }
83      .flexShrink(0)
84    }
85    .width('100%')
86    .height($r("app.float.id_item_height_max"))
87  }
88}