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 */ 15 16import { Constants, Log } from '@ohos/common'; 17 18const TAG: string = 'browser_RecycleAlbum'; 19 20interface MsgOnError { 21 componentWidth: number; 22 componentHeight: number; 23} 24 25interface MsgOnComplete { 26 width: number; 27 height: number; 28 componentWidth: number; 29 componentHeight: number; 30} 31 32@Component 33export struct RecycleAlbum { 34 @State icHeight: number = 0; 35 @Consume gridHeight: number; 36 gridAspectRatio = Constants.CARD_ASPECT_RATIO; 37 38 aboutToAppear(): void { 39 let numberHeight = px2vp(fp2px(Constants.TEXT_SIZE_BODY2)); 40 let nameHeight = px2vp(fp2px(Constants.TEXT_SIZE_SUB_TITLE1)); 41 this.icHeight = this.gridHeight - Constants.ALBUM_SET_NEW_ICON_MARGIN; 42 -numberHeight - nameHeight; 43 } 44 45 build() { 46 Flex({ 47 direction: FlexDirection.Column, 48 justifyContent: FlexAlign.Start, 49 alignItems: ItemAlign.Start 50 }) { 51 Stack({ alignContent: Alignment.Center }) { 52 Image($r('app.media.ic_gallery_public_delete_line')) 53 .width($r('app.float.recycle_album_cover_icon_size')) 54 .height($r('app.float.recycle_album_cover_icon_size')) 55 .fillColor($r('app.color.empty_or_recycle_album_icon')) 56 .onError((msg?: MsgOnError) => { 57 if(msg){ 58 Log.debug(TAG, `image load failed and its componentWidth is: ${msg.componentWidth}`); 59 Log.debug(TAG, `image load failed and its componentHeight is: ${msg.componentHeight}`); 60 } 61 }) 62 .onComplete((msg?: MsgOnComplete) => { 63 if(msg){ 64 Log.debug(TAG, `image load successfully and its width is: ${msg.width}`); 65 Log.debug(TAG, `image load successfully and its height is: ${msg.height}`); 66 Log.debug(TAG, `image load successfully and its componentWidth is: ${msg.componentWidth}`); 67 Log.debug(TAG, `image load successfully and its componentHeight is: ${msg.componentHeight}`); 68 } 69 }) 70 } 71 .height(this.icHeight) 72 .width('100%') 73 } 74 .aspectRatio(this.gridAspectRatio) 75 .backgroundColor($r('app.color.empty_or_recycle_album_back')) 76 .border({ radius: $r('sys.float.ohos_id_corner_radius_default_l') }) 77 } 78}