1/** 2 * Copyright (c) 2023 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 confirm dialog box is displayed at the bottom. 18 */ 19@CustomDialog 20export default struct ConfirmDialogEx { 21 @StorageLink('curBp') curBp: string = 'md' 22 controller: CustomDialogController; 23 cancel: () => void; 24 confirm: () => void; 25 title: string | Resource; 26 cancelText: string | Resource; 27 confirmText: string | Resource; 28 29 build() { 30 Flex({ 31 direction: FlexDirection.Column, 32 justifyContent: FlexAlign.Center, 33 alignItems: ItemAlign.Center 34 }) { 35 Flex({ 36 direction: FlexDirection.Column, 37 justifyContent: FlexAlign.Center, 38 alignItems: ItemAlign.Center 39 }) { 40 Text(this.title) 41 .fontSize(18) 42 .textOverflow({ overflow: TextOverflow.Ellipsis }) 43 .maxLines(2) 44 } 45 .margin({ bottom: 8, top: 10 }) 46 47 Row() { 48 Flex({ 49 direction: FlexDirection.Column, 50 justifyContent: FlexAlign.Center, 51 alignItems: ItemAlign.Center 52 }) { 53 Text(this.cancelText).fontColor($r('sys.color.ohos_id_color_text_primary_activated')).fontSize(18) 54 } 55 .layoutWeight(1) 56 .height(35) 57 .onClick(() => { 58 this.controller.close(); 59 this.cancel(); 60 }) 61 62 Line().width(1).height(25).backgroundColor($r('sys.color.ohos_id_color_list_separator')) 63 64 Flex({ 65 direction: FlexDirection.Column, 66 justifyContent: FlexAlign.Center, 67 alignItems: ItemAlign.Center 68 }) { 69 Text(this.confirmText).fontColor($r('sys.color.ohos_id_color_text_primary_activated')).fontSize(18) 70 } 71 .layoutWeight(1) 72 .height(35) 73 .onClick(() => { 74 this.controller.close(); 75 this.confirm(); 76 }) 77 } 78 .height('30vp') 79 } 80 .width('90%') 81 .height($r('app.float.ConfirmDialogEx_height')) 82 .borderRadius(20) 83 .padding({ 84 bottom: $r('sys.float.ohos_id_dialog_margin_bottom'), 85 right: $r('sys.float.ohos_id_notification_margin_start'), 86 left: $r('sys.float.ohos_id_notification_margin_end') 87 }) 88 .margin({ left: 12, right: 12, bottom: this.curBp === 'sm' ? 16 : 0 }) 89 } 90}