18779efd5Sopenharmony_ci/** 28779efd5Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 38779efd5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 48779efd5Sopenharmony_ci * you may not use this file except in compliance with the License. 58779efd5Sopenharmony_ci * You may obtain a copy of the License at 68779efd5Sopenharmony_ci * 78779efd5Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 88779efd5Sopenharmony_ci * 98779efd5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 108779efd5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 118779efd5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 128779efd5Sopenharmony_ci * See the License for the specific language governing permissions and 138779efd5Sopenharmony_ci * limitations under the License. 148779efd5Sopenharmony_ci */ 158779efd5Sopenharmony_ci 168779efd5Sopenharmony_ci/** 178779efd5Sopenharmony_ci * The sharing dialog box is displayed at the bottom. 188779efd5Sopenharmony_ci */ 198779efd5Sopenharmony_ci@CustomDialog 208779efd5Sopenharmony_ciexport default struct ShareDialogEx { 218779efd5Sopenharmony_ci controller: CustomDialogController; 228779efd5Sopenharmony_ci cancel: () => void; 238779efd5Sopenharmony_ci title: string | Resource; 248779efd5Sopenharmony_ci itemList: string[] | Resource[]; 258779efd5Sopenharmony_ci cancelText: string | Resource; 268779efd5Sopenharmony_ci onItemClick: (item, index) => {}; 278779efd5Sopenharmony_ci 288779efd5Sopenharmony_ci build() { 298779efd5Sopenharmony_ci Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Start }) { 308779efd5Sopenharmony_ci Text(this.title) 318779efd5Sopenharmony_ci .width('100%') 328779efd5Sopenharmony_ci .height(40) 338779efd5Sopenharmony_ci .fontSize(24) 348779efd5Sopenharmony_ci 358779efd5Sopenharmony_ci List() { 368779efd5Sopenharmony_ci ForEach(this.itemList, (item, index) => { 378779efd5Sopenharmony_ci ListItem() { 388779efd5Sopenharmony_ci Column() { 398779efd5Sopenharmony_ci Text(item).fontSize(20).margin({ top: 5, bottom: 5 }) 408779efd5Sopenharmony_ci } 418779efd5Sopenharmony_ci .width('100%') 428779efd5Sopenharmony_ci .alignItems(HorizontalAlign.Start) 438779efd5Sopenharmony_ci .onClick(() => { 448779efd5Sopenharmony_ci this.onItemClick(item, index); 458779efd5Sopenharmony_ci this.controller.close(); 468779efd5Sopenharmony_ci }) 478779efd5Sopenharmony_ci } 488779efd5Sopenharmony_ci }, item => item); 498779efd5Sopenharmony_ci } 508779efd5Sopenharmony_ci .scrollBar(BarState.Off) 518779efd5Sopenharmony_ci .edgeEffect(EdgeEffect.None) 528779efd5Sopenharmony_ci .width('100%') 538779efd5Sopenharmony_ci .flexGrow(1) 548779efd5Sopenharmony_ci 558779efd5Sopenharmony_ci Column() { 568779efd5Sopenharmony_ci Text(this.cancelText).textAlign(TextAlign.Center) 578779efd5Sopenharmony_ci .width('100%') 588779efd5Sopenharmony_ci .fontSize(20) 598779efd5Sopenharmony_ci .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 608779efd5Sopenharmony_ci } 618779efd5Sopenharmony_ci .width('100%') 628779efd5Sopenharmony_ci .height(30) 638779efd5Sopenharmony_ci .alignItems(HorizontalAlign.Center) 648779efd5Sopenharmony_ci .onClick(() => { 658779efd5Sopenharmony_ci this.controller.close(); 668779efd5Sopenharmony_ci this.cancel(); 678779efd5Sopenharmony_ci }) 688779efd5Sopenharmony_ci } 698779efd5Sopenharmony_ci .width('90%') 708779efd5Sopenharmony_ci .height(200) 718779efd5Sopenharmony_ci .borderRadius(20) 728779efd5Sopenharmony_ci .padding(10) 738779efd5Sopenharmony_ci } 748779efd5Sopenharmony_ci}