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 {MyDataSource} from '../util/DataSource' 17 18@Component 19export default struct ThemeDesktop { 20 @Link themeDatas: Array<{ 21 image: Resource, 22 name: string 23 }> 24 25 build() { 26 Grid() { 27 LazyForEach(new MyDataSource(this.themeDatas), (item) => { 28 GridItem() { 29 Column() { 30 Image(item.image) 31 .width(70) 32 .height(70) 33 .padding(10) 34 .objectFit(ImageFit.Fill) 35 Text(item.name).fontSize(15) 36 } 37 .width(90) 38 .height(90) 39 } 40 }, item => item.name) 41 } 42 .rowsGap(10) 43 .width('100%') 44 .columnsGap(10) 45 .layoutWeight(1) 46 .padding({ top: 20 }) 47 .backgroundColor('#e5e5e5') 48 .columnsTemplate('1fr 1fr 1fr 1fr') 49 } 50}