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 { KeyValuePair } from '../model/KeyValuePair'; 17import { DeleteView } from './DeleteView'; 18 19@Component 20export struct KeyValueItemView { 21 @ObjectLink keyValuePair: KeyValuePair; 22 @State deleteEnabled: boolean = true; 23 private deleteAction: (event?: ClickEvent) => void = () => { 24 }; 25 private index: number = 0; 26 27 build() { 28 Row() { 29 Column() { 30 Text(`Key: ${this.keyValuePair.key}`) 31 .fontColor($r('app.color.text_color_primary')) 32 .fontSize(16) 33 Text(`Value: ${this.keyValuePair.value}`) 34 .fontColor($r('app.color.text_color_second')) 35 .fontSize(14) 36 } 37 .height('100%') 38 .layoutWeight(1) 39 .padding({ left: 16, right: 16, top: 12, bottom: 12 }) 40 .borderRadius(16) 41 .backgroundColor($r('app.color.bg_white')) 42 .alignItems(HorizontalAlign.Start) 43 44 DeleteView({ enable: this.deleteEnabled }) 45 .id(`delete${this.index}`) 46 .margin({ left: 12 }) 47 .enabled(this.deleteEnabled) 48 .onClick(this.deleteAction) 49 } 50 .width('100%') 51 .height(64) 52 .alignItems(VerticalAlign.Center) 53 } 54}