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 mediaLibrary from '@ohos.multimedia.mediaLibrary' 16import { myMedia } from '../model/myMedia' 17import { filterSize, getTimeString, getDateTime } from '../model/TimeTools' 18 19@CustomDialog 20export struct isInformationDialog { 21 @Link myMedia: myMedia 22 private controller: CustomDialogController 23 private scroller: Scroller = new Scroller() 24 private isInformation: mediaLibrary.FileAsset = null 25 private context: any 26 @State isInformation_id: string = '' 27 @State isInformation_uri: string = '' 28 @State isInformation_mimeType: string = '' 29 @State isInformation_mediaType: string = '' 30 @State isInformation_displayName: string = '' 31 @State isInformation_title: string = '' 32 @State isInformation_relativePath: string = '' 33 @State isInformation_parent: string = '' 34 @State isInformation_size: string = '' 35 @State isInformation_dateAdded: string = '' 36 @State isInformation_dateModified: string = '' 37 @State isInformation_dateTaken: string = '' 38 @State isInformation_artist: string = '' 39 @State isInformation_audioAlbum: string = '' 40 @State isInformation_width: string = '' 41 @State isInformation_height: string = '' 42 @State isInformation_orientation: string = '' 43 @State isInformation_duration: string = '' 44 @State isInformation_albumId: string = '' 45 @State isInformation_albumUri: string = '' 46 @State isInformation_albumName: string = '' 47 async aboutToAppear() { 48 this.myMedia.getPause() 49 this.isInformation = this.myMedia.getResourceAddress() 50 this.isInformation_id = await this.convertResourceToString($r('app.string.index_formation_id')) 51 this.isInformation_uri = await this.convertResourceToString($r('app.string.index_formation_uri')) 52 this.isInformation_mimeType = await this.convertResourceToString($r('app.string.index_formation_mimeType')) 53 this.isInformation_mediaType = await this.convertResourceToString($r('app.string.index_formation_mediaType')) 54 this.isInformation_displayName = await this.convertResourceToString($r('app.string.index_formation_displayName')) 55 this.isInformation_title = await this.convertResourceToString($r('app.string.index_formation_title')) 56 this.isInformation_relativePath = await this.convertResourceToString($r('app.string.index_formation_relativePath')) 57 this.isInformation_parent = await this.convertResourceToString($r('app.string.index_formation_parent')) 58 this.isInformation_size = await this.convertResourceToString($r('app.string.index_formation_size')) 59 this.isInformation_dateAdded = await this.convertResourceToString($r('app.string.index_formation_dateAdded')) 60 this.isInformation_dateModified = await this.convertResourceToString($r('app.string.index_formation_dateModified')) 61 this.isInformation_dateTaken = await this.convertResourceToString($r('app.string.index_formation_dateTaken')) 62 this.isInformation_artist = await this.convertResourceToString($r('app.string.index_formation_artist')) 63 this.isInformation_audioAlbum = await this.convertResourceToString($r('app.string.index_formation_audioAlbum')) 64 this.isInformation_width = await this.convertResourceToString($r('app.string.index_formation_width')) 65 this.isInformation_height = await this.convertResourceToString($r('app.string.index_formation_height')) 66 this.isInformation_orientation = await this.convertResourceToString($r('app.string.index_formation_orientation')) 67 this.isInformation_duration = await this.convertResourceToString($r('app.string.index_formation_duration')) 68 this.isInformation_albumId = await this.convertResourceToString($r('app.string.index_formation_albumId')) 69 this.isInformation_albumUri = await this.convertResourceToString($r('app.string.index_formation_albumUri')) 70 this.isInformation_albumName = await this.convertResourceToString($r('app.string.index_formation_albumName')) 71 72 73 } 74 async convertResourceToString(resource: Resource){ 75 return await this.context.resourceManager.getString(resource) 76 } 77 build() { 78 Scroll(this.scroller) { 79 Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceEvenly }) { 80 Text($r('app.string.index_formation')).fontColor('#FFFFFF') 81 Text(`${this.isInformation_id + this.isInformation.id}`).fontColor('#FFFFFF') 82 Text(`${this.isInformation_uri + this.isInformation.uri}`).fontColor('#FFFFFF') 83 Text(`${this.isInformation_mimeType + this.isInformation.mimeType}`).fontColor('#FFFFFF') 84 Text(`${this.isInformation_mediaType + this.isInformation.mediaType}`).fontColor('#FFFFFF') 85 Text(`${this.isInformation_displayName + this.isInformation.displayName}`).fontColor('#FFFFFF') 86 Text(`${this.isInformation_title + this.isInformation.title}`).fontColor('#FFFFFF') 87 Text(`${this.isInformation_relativePath + this.isInformation.relativePath}`).fontColor('#FFFFFF') 88 Text(`${this.isInformation_parent + this.isInformation.parent}`).fontColor('#FFFFFF') 89 Text(`${this.isInformation_size + filterSize(this.isInformation.size)}`).fontColor('#FFFFFF') 90 Text(`${this.isInformation_dateAdded + getDateTime(this.isInformation.dateAdded)}`).fontColor('#FFFFFF') 91 Text(`${this.isInformation_dateModified + getDateTime(this.isInformation.dateModified)}`).fontColor('#FFFFFF') 92 Text(`${this.isInformation_dateTaken + getDateTime(this.isInformation.dateTaken)}`).fontColor('#FFFFFF') 93 Text(`${this.isInformation_artist + this.isInformation.artist}`).fontColor('#FFFFFF') 94 Text(`${this.isInformation_audioAlbum + this.isInformation.audioAlbum}`).fontColor('#FFFFFF') 95 Text(`${this.isInformation_width + this.isInformation.width}`).fontColor('#FFFFFF') 96 Text(`${this.isInformation_height + this.isInformation.height}`).fontColor('#FFFFFF') 97 Text(`${this.isInformation_orientation + this.isInformation.orientation}`).fontColor('#FFFFFF') 98 Text(`${this.isInformation_duration + getTimeString(this.isInformation.duration)}`).fontColor('#FFFFFF') 99 Text(`${this.isInformation_albumId + this.isInformation.albumId}`).fontColor('#FFFFFF') 100 Text(`${this.isInformation_albumUri + this.isInformation.albumUri}`).fontColor('#FFFFFF') 101 Text(`${this.isInformation_albumName + this.isInformation.albumName}`).fontColor('#FFFFFF') 102 }.width('100%').height('100%') 103 } 104 .scrollBar(BarState.Off) 105 .scrollBarColor(Color.White) 106 .padding('1%') 107 .backgroundColor('rgba(0,0,0,0.6)') 108 .width('22%') 109 .height('71%') 110 } 111}