diff --git a/build-profile.json5 b/build-profile.json5 index 81867859ce98ce65bb5be4bccc925a9eb9205422..807c91e155fe6ca1b5ca44febf15cb793fad91f9 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -1,7 +1,6 @@ { "app": { "signingConfigs": [ - ], "products": [ { diff --git a/entry/src/main/ets/common/utils/OCRManager.ets b/entry/src/main/ets/common/utils/OCRManager.ets index 549dd12b69d91b4dbd5c0749fb5bb14df74370df..bb5c7532a9ac8f1d460ebbe2e624d03e00797ae7 100644 --- a/entry/src/main/ets/common/utils/OCRManager.ets +++ b/entry/src/main/ets/common/utils/OCRManager.ets @@ -68,6 +68,7 @@ export class OCRManager { // Visual information to be recognized. Currently, only the visual information of the PixelMap type in color data format RGBA_8888 is supported. let visionInfo: textRecognition.VisionInfo = { pixelMap: await OCRManager.getPixelMap(uri) }; let result: textRecognition.TextRecognitionResult = await textRecognition.recognizeText(visionInfo); + visionInfo.pixelMap.release(); return result.value; } @@ -75,7 +76,9 @@ export class OCRManager { // Convert image resources to PixelMap let fileSource = await fs.open(uri, fs.OpenMode.READ_ONLY); let imgSource: image.ImageSource = image.createImageSource(fileSource.fd); + let pixelMap: image.PixelMap = await imgSource.createPixelMap(); fs.close(fileSource); - return imgSource.createPixelMap(); + imgSource.release(); + return pixelMap; } } \ No newline at end of file diff --git a/entry/src/main/ets/model/DataModel.ets b/entry/src/main/ets/model/DataModel.ets index 8f6ef1b83b436c16784e2738e0e2695e3602b639..f68dfa95d4105556bf505b413743f9905fa35e04 100644 --- a/entry/src/main/ets/model/DataModel.ets +++ b/entry/src/main/ets/model/DataModel.ets @@ -13,11 +13,11 @@ * limitations under the License. */ -@Observed +@ObservedV2 export class ConsigneeInfo { label: ResourceStr; placeholder: ResourceStr; - value: string; + @Trace value: string; constructor(label: ResourceStr, placeholder: ResourceStr, value: string) { this.label = label; diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index baadb20abbbb34a7e1b3672992eef44f236cbc25..6e1f153a84def11911fb1e0442d1fafec061615e 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -130,19 +130,19 @@ struct Index { List() { ForEach(this.consigneeInfos, (item: ConsigneeInfo) => { ListItem() { - ConsigneeInfoItem({ - item: item, checkAvailable: () => { - if (this.consigneeInfos[0].value && this.consigneeInfos[1].value && this.consigneeInfos[2].value) { - this.saveAvailable = true; - } else { - this.saveAvailable = false; - } + ConsigneeInfoItem( + item, () => { + if (this.consigneeInfos[0].value && this.consigneeInfos[1].value && this.consigneeInfos[2].value) { + this.saveAvailable = true; + } else { + this.saveAvailable = false; } }) } }, (item: ConsigneeInfo, index: number) => JSON.stringify(item) + index) } .width("100%") + .height(LayoutPolicy.matchParent) .scrollBar(BarState.Off) .divider({ strokeWidth: 0.5, color: $r('app.color.divider_color') }) .padding({ @@ -151,9 +151,12 @@ struct Index { top: 4, bottom: 4 }) + .borderRadius(16) + .backgroundColor($r('app.color.light_background')) } .borderRadius(16) .margin({ top: 12 }) + .constraintSize({ minHeight: 150, maxHeight: '50%' }) .backgroundColor($r('app.color.light_background')) } diff --git a/entry/src/main/ets/views/ConsigneeInfoItem.ets b/entry/src/main/ets/views/ConsigneeInfoItem.ets index fdea87444dac288d45034d187f1fd92d7764d6b3..2b7ab057a9c87d7391742c363404ec9bfa557506 100644 --- a/entry/src/main/ets/views/ConsigneeInfoItem.ets +++ b/entry/src/main/ets/views/ConsigneeInfoItem.ets @@ -16,42 +16,37 @@ import CommonConstants from "../common/constants/CommonConstants"; import { ConsigneeInfo } from "../model/DataModel"; -@Component -export struct ConsigneeInfoItem { - @ObjectLink item: ConsigneeInfo; - checkAvailable?: () => void; +@Builder +export function ConsigneeInfoItem(item: ConsigneeInfo, checkAvailable?: () => void) { + Row() { + Text(item.label) + .fontSize(16) + .fontWeight(400) + .lineHeight(19) + .textAlign(TextAlign.Start) + .fontColor($r('app.color.item_label_color')) + .opacity(0.9) + .layoutWeight(1) - build() { - Row() { - Text(this.item.label) - .fontSize(16) - .fontWeight(400) - .lineHeight(19) - .textAlign(TextAlign.Start) - .fontColor($r('app.color.item_label_color')) - .opacity(0.9) - .layoutWeight(1) - - TextArea({ placeholder: this.item.placeholder, text: this.item.value }) - .type(this.item.label === CommonConstants.PHONE_LABEL ? TextAreaType.PHONE_NUMBER : TextAreaType.NORMAL) - .fontSize(16) - .fontWeight(500) - .lineHeight(21) - .padding(0) - .borderRadius(0) - .textAlign(TextAlign.End) - .fontColor($r('app.color.item_label_color')) - .opacity(0.9) - .backgroundColor($r('app.color.light_background')) - .heightAdaptivePolicy(TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST) - .layoutWeight(2) - .onChange((value: string) => { - this.item.value = value; - this.checkAvailable?.(); - }) - } - .width("100%") - .constraintSize({ minHeight: 48 }) - .justifyContent(FlexAlign.SpaceBetween) + TextArea({ placeholder: item.placeholder, text: item.value }) + .type(item.label === CommonConstants.PHONE_LABEL ? TextAreaType.PHONE_NUMBER : TextAreaType.NORMAL) + .fontSize(16) + .fontWeight(500) + .lineHeight(21) + .padding(0) + .borderRadius(0) + .textAlign(TextAlign.End) + .fontColor($r('app.color.item_label_color')) + .opacity(0.9) + .backgroundColor($r('app.color.light_background')) + .heightAdaptivePolicy(TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST) + .layoutWeight(2) + .onChange((value: string) => { + item.value = value; + checkAvailable?.(); + }) } + .width("100%") + .constraintSize({ minHeight: 48 }) + .justifyContent(FlexAlign.SpaceBetween) } \ No newline at end of file