1/* 2 * Copyright (c) 2023-2024 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 */ 15import router from '@ohos.router'; 16import { logger } from '../util/Logger'; 17import { readImage } from '../util/MediaUtil'; 18 19@Component 20export struct UpdatePage { 21 @State mediaUri: string = (router.getParams() as Record<string, Object>)['mediaUri'] as string; 22 @State isLand: boolean = false; 23 @State pixelMap: PixelMap | null = null; 24 25 async aboutToAppear(): Promise<void> { 26 logger.info('UpdatePage mediaUri' + this.mediaUri); 27 this.pixelMap = await readImage(this.mediaUri); 28 } 29 30 build() { 31 Column() { 32 Row() { 33 Image($r("app.media.back1")) 34 .width($r('app.float.size_35')) 35 .height($r('app.float.size_35')) 36 .objectFit(ImageFit.Contain) 37 .onClick(() => { 38 router.back(); 39 }) 40 } 41 .padding({ left: $r('app.float.size_14') }) 42 .margin({ top: $r('app.float.size_20') }) 43 .justifyContent(FlexAlign.Start) 44 .width('100%') 45 46 Row() { 47 Image(this.pixelMap) 48 .objectFit(ImageFit.Contain) 49 .backgroundColor($r('app.color.update_page_image')) 50 .width('90%') 51 .height('90%') 52 } 53 .layoutWeight(1) 54 .alignItems(VerticalAlign.Center) 55 56 Row() { 57 Column() { 58 Image($r('app.media.ic_edit')) 59 .width($r('app.float.size_35')) 60 .height($r('app.float.size_35')) 61 Text($r('app.string.update_page_edit')) 62 .fontSize($r('app.float.size_18')) 63 .fontColor(Color.White) 64 .margin({ top: $r('app.float.size_5') }) 65 } 66 .height($r('app.float.size_60')) 67 .width($r('app.float.size_100')) 68 .id('Edit') 69 .onClick(() => { 70 router.pushUrl({ 71 url: 'pages/EditImages', 72 params: { mediaUris: this.mediaUri } 73 }); 74 }) 75 76 Column() { 77 Image($r('app.media.ic_delete')) 78 .width($r('app.float.size_35')) 79 .height($r('app.float.size_35')) 80 Text($r('app.string.update_page_delete')) 81 .fontColor(Color.White) 82 .fontSize($r('app.float.size_18')) 83 .margin({ top: $r('app.float.size_5') }) 84 } 85 .height($r('app.float.size_60')) 86 .width($r('app.float.size_100')) 87 .onClick(() => { 88 // 删除图片 89 let imageList: Array<string> = AppStorage.get('imageList') as Array<string>; 90 let index: number = AppStorage.get('selectIndex') as number; 91 imageList.splice(index, 1); 92 AppStorage.setOrCreate<Array<string>>('imageList', imageList); 93 // 返回 94 router.back(); 95 }) 96 } 97 .align(Alignment.Center) 98 .height('10%') 99 .width('100%') 100 .justifyContent(FlexAlign.SpaceAround) 101 } 102 .backgroundColor(Color.Black) 103 .height('100%') 104 .width('100%') 105 } 106}