1/* 2 * Copyright (c) 2022-2024 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 userFileManager from '@ohos.filemanagement.userFileManager'; 16import { myMedia } from '../model/myMedia' 17import { getTimeString } from '../model/TimeTools' 18 19@CustomDialog 20export struct isInformationDialog { 21 @Link myMedia: myMedia 22 @State isInformation_uri: string = '' 23 @State isInformation_mediaType: string = '' 24 @State isInformation_displayName: string = '' 25 @State isInformation_title: string = '' 26 @State isInformation_width: string = '' 27 @State isInformation_height: string = '' 28 @State isInformation_orientation: string = '' 29 @State isInformation_duration: string = '' 30 private controller: CustomDialogController = {} as CustomDialogController 31 private isInformation: userFileManager.FileAsset = {} as userFileManager.FileAsset 32 private scroller: Scroller = new Scroller() 33 private context: Context = getContext(this) 34 35 async aboutToAppear() { 36 this.myMedia.getPause() 37 this.isInformation = this.myMedia.getResourceAddress() 38 this.isInformation_uri = await this.convertResourceToString($r('app.string.index_formation_uri')) 39 this.isInformation_mediaType = await this.convertResourceToString($r('app.string.index_formation_mediaType')) 40 this.isInformation_displayName = await this.convertResourceToString($r('app.string.index_formation_displayName')) 41 this.isInformation_title = await this.convertResourceToString($r('app.string.index_formation_title')) 42 this.isInformation_width = await this.convertResourceToString($r('app.string.index_formation_width')) 43 this.isInformation_height = await this.convertResourceToString($r('app.string.index_formation_height')) 44 this.isInformation_orientation = await this.convertResourceToString($r('app.string.index_formation_orientation')) 45 this.isInformation_duration = await this.convertResourceToString($r('app.string.index_formation_duration')) 46 } 47 48 async convertResourceToString(resource: Resource): Promise<string> { 49 return await this.context.resourceManager.getStringValue(resource.id) 50 } 51 52 build() { 53 Scroll(this.scroller) { 54 Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceEvenly }) { 55 Text($r('app.string.index_formation')).fontColor('#FFFFFF') 56 Text(`${this.isInformation_uri + this.isInformation.uri}`).fontColor('#FFFFFF') 57 Text(`${this.isInformation_mediaType + this.isInformation.fileType}`).fontColor('#FFFFFF') 58 Text(`${this.isInformation_displayName + this.isInformation.displayName}`).fontColor('#FFFFFF') 59 Text(`${this.isInformation_title + this.isInformation.get('title')}`).fontColor('#FFFFFF') 60 Text(`${this.isInformation_width + this.isInformation.get('width')}`).fontColor('#FFFFFF') 61 Text(`${this.isInformation_height + this.isInformation.get('height')}`).fontColor('#FFFFFF') 62 Text(`${this.isInformation_orientation + this.isInformation.get('orientation')}`).fontColor('#FFFFFF') 63 Text(`${this.isInformation_duration + getTimeString(this.isInformation.get('duration'))}`).fontColor('#FFFFFF') 64 }.width('100%').height('100%') 65 } 66 .scrollBar(BarState.Off) 67 .scrollBarColor(Color.White) 68 .padding('1%') 69 .backgroundColor('rgba(0,0,0,0.6)') 70 .width('22%') 71 .height('71%') 72 } 73}