• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 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 { Information } from '../../model/Information';
17
18@Component
19export struct ArrayListItem {
20  @ObjectLink information: Information;
21  private index: number = 0;
22  private handleOnClick: (index: number) => void = () => {};
23
24  build() {
25    Row() {
26      Image($r('app.media.contact'))
27        .width('20%')
28        .objectFit(ImageFit.Contain)
29      Column() {
30        Row() {
31          Text($r("app.string.contact_name"))
32            .fontSize(24)
33            .fontColor(Color.Black)
34          Text(this.information.name)
35            .fontColor(Color.Black)
36            .fontSize(24)
37        }
38        .width('100%')
39        .margin({ top: 5 })
40
41        Row() {
42          Text($r("app.string.contact_age"))
43            .fontColor(Color.Black)
44            .fontSize(24)
45          Text(this.information.age.toString())
46            .fontColor(Color.Black)
47            .fontSize(24)
48        }
49        .width('100%')
50        .margin({ top: 5 })
51
52        Row() {
53          Text($r("app.string.contact_phone"))
54            .fontColor(Color.Black)
55            .fontSize(24)
56          Text(this.information.phone)
57            .fontColor(Color.Black)
58            .fontSize(24)
59        }
60        .width('100%')
61        .margin({ top: 5 })
62      }
63      .width('55%')
64      .margin({ left: 10 })
65      .justifyContent(FlexAlign.Start)
66
67      Blank()
68      Button() {
69        Text($r('app.string.button_delete'))
70          .key('delContact')
71          .fontColor(Color.Red)
72          .fontSize(19)
73          .width(100)
74          .textAlign(TextAlign.Center)
75      }
76      .type(ButtonType.Capsule)
77      .backgroundColor($r("app.color.button_bg"))
78      .height(40)
79      .onClick(() => {
80        this.handleOnClick(this.index);
81      })
82    }
83    .width('100%')
84    .padding(10)
85    .align(Alignment.Center)
86    .borderRadius(20)
87    .backgroundColor(Color.White)
88  }
89}