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 .scrollBar(BarState.Off) 51 .edgeEffect(EdgeEffect.None) 52 .width('100%') 53 .flexGrow(1) 54 55 Column() { 56 Text(this.cancelText).textAlign(TextAlign.Center) 57 .width('100%') 58 .fontSize(20) 59 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 60 } 61 .width('100%') 62 .height(30) 63 .alignItems(HorizontalAlign.Center) 64 .onClick(() => { 65 this.controller.close(); 66 this.cancel(); 67 }) 68 } 69 .width('90%') 70 .height(200) 71 .borderRadius(20) 72 .padding(10) 73 } 74}