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 router from '@ohos.router' 16import Album from '../pages/Index' 17 18@Component 19export struct MediaView { 20 @Link albums: Array<Album> 21 22 build() { 23 Column() { 24 List() { 25 ForEach(this.albums, (item, index) => { 26 ListItem() { 27 Row() { 28 Text(item.albumName) 29 .fontSize(25) 30 .fontWeight(FontWeight.Bold) 31 .textAlign(TextAlign.Start) 32 Blank() 33 Text(`${item.count}`) 34 .fontSize(25) 35 .fontWeight(FontWeight.Bold) 36 .textAlign(TextAlign.End) 37 } 38 .width('100%') 39 .padding(16) 40 .constraintSize({ minHeight: 70 }) 41 } 42 .onClick(() => { 43 if (item.count > 0) { 44 router.push({ 45 url: 'pages/AlbumPage', 46 params: { albumName: item.albumName, mediaType: item.mediaType } 47 }) 48 } else { 49 AlertDialog.show( 50 { 51 title: $r('app.string.album_empty'), 52 message: null, 53 primaryButton: { 54 value: $r('app.string.yes'), 55 fontColor: Color.Red, 56 action: () => { 57 } 58 } 59 } 60 ) 61 } 62 }) 63 }, item => item.albumName) 64 } 65 .divider({ strokeWidth: 1, color: Color.Gray, startMargin: 16, endMargin: 16 }) 66 .layoutWeight(1) 67 } 68 .height('100%') 69 .width('100%') 70 } 71}