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 16/** 17 * The sharing dialog box is displayed at the bottom. 18 */ 19@CustomDialog 20export default struct ShareDialogEx { 21 controller: CustomDialogController; 22 cancel: () => void; 23 title: string | Resource; 24 itemList: string[] | Resource[]; 25 cancelText: string | Resource; 26 onItemClick: (item, index) => {}; 27 28 build() { 29 Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Start }) { 30 Text(this.title) 31 .width('100%') 32 .height(40) 33 .fontSize(24) 34 35 List() { 36 ForEach(this.itemList, (item, index) => { 37 ListItem() { 38 Column() { 39 Text(item).fontSize(20).margin({ top: 5, bottom: 5 }) 40 } 41 .width('100%') 42 .alignItems(HorizontalAlign.Start) 43 .onClick(() => { 44 this.onItemClick(item, index); 45 this.controller.close(); 46 }) 47 } 48 }, item => item); 49 } 50 .width('100%') 51 .flexGrow(1) 52 53 Column() { 54 Text(this.cancelText).textAlign(TextAlign.Center) 55 .width('100%') 56 .fontSize(20) 57 .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) 58 } 59 .width('100%') 60 .height(30) 61 .alignItems(HorizontalAlign.Center) 62 .onClick(() => { 63 this.controller.close(); 64 this.cancel(); 65 }) 66 } 67 .width('90%') 68 .height(200) 69 .borderRadius(20) 70 .padding(10) 71 } 72}