• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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';
17import { DeleteView } from './DeleteView';
18import { getString } from '@ohos/common';
19
20@Component
21export struct InformationItemView {
22  @ObjectLink information: Information;
23  private deleteAction: (event?: ClickEvent) => void = () => {};
24  private index: number = 0;
25
26  build() {
27    Row() {
28      Row() {
29        Column() {
30          Text(this.information.name)
31            .fontColor($r('app.color.text_color_primary'))
32            .fontSize(16)
33          Text(this.information.phone)
34            .fontColor($r('app.color.text_color_second'))
35            .fontSize(14)
36            .margin({ top: 5 })
37        }
38
39        Blank()
40        Text(`${this.information.age}${getString($r('app.string.old'))}`)
41          .fontColor($r('app.color.text_color_second'))
42          .fontSize(12)
43      }
44      .height(72)
45      .layoutWeight(1)
46      .padding({ left: 16, right: 15 })
47      .margin({ right: 12 })
48      .backgroundColor($r('app.color.bg_white'))
49      .borderRadius(16)
50
51      DeleteView({ enable: this.information.clickAble })
52        .id(`delete${this.index}`)
53        .enabled(this.information.clickAble)
54        .onClick(this.deleteAction)
55    }
56    .padding({ left: 12 })
57    .width('100%')
58    .margin({ top: 12, right: 12 })
59  }
60}