1/* 2 * Copyright (c) 2022-2023 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 { AppInfo, appInit, BundleStateUtil } from 'feature-util' 17 18const TAG = 'FreeApps' 19 20@Component 21export struct FreeApps { 22 @State apps: Array<AppInfo> = appInit() 23 @State freeApps: Array<AppInfo> = [] 24 25 aboutToAppear() { 26 this.getFreeApps() 27 } 28 29 async getFreeApps() { 30 let bundleStateUtil = new BundleStateUtil() 31 this.freeApps = await bundleStateUtil.getFreeAppList() 32 } 33 34 build() { 35 Column() { 36 Text($r('app.string.free_apps')) 37 .width('80%') 38 .fontSize(20) 39 .fontWeight(FontWeight.Bold) 40 .direction(Direction.Ltr) 41 .margin({ bottom: 10 }) 42 Column() { 43 Scroll() { 44 Row() { 45 ForEach(this.freeApps, (item) => { 46 Column() { 47 Image(item.icon) 48 .margin({ top: 10 }) 49 .width(70) 50 .height(70) 51 .objectFit(ImageFit.Fill) 52 Text(item.name) 53 .fontSize(10) 54 .margin({ top: 5 }) 55 } 56 .width(70) 57 .height(120) 58 .margin(10) 59 }, item => item.name) 60 } 61 .borderRadius(10) 62 .backgroundColor(Color.White) 63 } 64 .margin(5) 65 .width('90%') 66 .scrollable(ScrollDirection.Horizontal) 67 } 68 .width('95%') 69 .padding(10) 70 }.margin({ top: 20 }) 71 } 72}