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 */ 15import router from '@ohos.router' 16import { MARKS } from '../model/Const' 17import Note from '../model/Note' 18 19@Component 20export default struct NoteItem { 21 @State note: Note | undefined = undefined 22 private index: number = 0 23 24 build() { 25 Row() { 26 Image(this.note.mark >= 0 ? MARKS[this.note.mark] : $r('app.media.note')) 27 .size({ width: 30, height: 30 }) 28 .objectFit(ImageFit.Contain) 29 Column() { 30 Text(this.note.title) 31 .fontColor(Color.Black) 32 .fontSize(30) 33 .maxLines(1) 34 .textOverflow({ overflow: TextOverflow.Ellipsis }) 35 Text(this.note.content) 36 .fontColor(Color.Gray) 37 .margin({ top: 10 }) 38 .fontSize(25) 39 .maxLines(1) 40 .textOverflow({ overflow: TextOverflow.Ellipsis }) 41 } 42 .alignItems(HorizontalAlign.Start) 43 .margin({ left: 20 }) 44 } 45 .padding(16) 46 .width('100%') 47 .borderRadius(16) 48 .backgroundColor(Color.White) 49 .onClick(() => { 50 router.push({ 51 url: 'pages/Edit', 52 params: { 53 index: this.index, 54 note: this.note, 55 isAdd: false 56 } 57 }) 58 }) 59 } 60} 61