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 router from '@ohos.router' 17 18class DirectoryItem { 19 title: Resource | string = ''; 20 uri: string = ''; 21 id: string = ''; 22} 23 24@Component 25struct DirectoryList { 26 private directory: DirectoryItem[]=[]; 27 private title?: Resource; 28 29 build() { 30 Scroll() { 31 Column() { 32 Text(this.title) 33 .fontSize(24) 34 .fontWeight(FontWeight.Bold) 35 .height(100); 36 37 ForEach(this.directory, (item : DirectoryItem) => { 38 Button(item.title) 39 .id(item.id) 40 .fontSize(20) 41 .width('90%') 42 .height(55) 43 .margin(12) 44 .backgroundColor('#007DFF') 45 .onClick(() => { 46 router.pushUrl({ 47 url: item.uri 48 }) 49 }); 50 },(item:DirectoryItem)=>JSON.stringify(item)); 51 } 52 } 53 .width('100%') 54 .padding({left: 10, right: 10, bottom: 100}); 55 } 56} 57 58export { DirectoryItem, DirectoryList }