199da06d0Sopenharmony_ci/**
299da06d0Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
399da06d0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
499da06d0Sopenharmony_ci * you may not use this file except in compliance with the License.
599da06d0Sopenharmony_ci * You may obtain a copy of the License at
699da06d0Sopenharmony_ci *
799da06d0Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
899da06d0Sopenharmony_ci *
999da06d0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1099da06d0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1199da06d0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1299da06d0Sopenharmony_ci * See the License for the specific language governing permissions and
1399da06d0Sopenharmony_ci * limitations under the License.
1499da06d0Sopenharmony_ci */
1599da06d0Sopenharmony_ci
1699da06d0Sopenharmony_ci/**
1799da06d0Sopenharmony_ci * The confirm dialog box is displayed at the bottom.
1899da06d0Sopenharmony_ci */
1999da06d0Sopenharmony_ci@CustomDialog
2099da06d0Sopenharmony_ciexport default struct ConfirmDialogEx {
2199da06d0Sopenharmony_ci  @StorageLink('curBp') curBp: string = 'md'
2299da06d0Sopenharmony_ci  controller: CustomDialogController;
2399da06d0Sopenharmony_ci  cancel: () => void;
2499da06d0Sopenharmony_ci  confirm: () => void;
2599da06d0Sopenharmony_ci  title: string | Resource;
2699da06d0Sopenharmony_ci  cancelText: string | Resource;
2799da06d0Sopenharmony_ci  confirmText: string | Resource;
2899da06d0Sopenharmony_ci
2999da06d0Sopenharmony_ci  build() {
3099da06d0Sopenharmony_ci    Flex({
3199da06d0Sopenharmony_ci      direction: FlexDirection.Column,
3299da06d0Sopenharmony_ci      justifyContent: FlexAlign.Center,
3399da06d0Sopenharmony_ci      alignItems: ItemAlign.Center
3499da06d0Sopenharmony_ci    }) {
3599da06d0Sopenharmony_ci      Flex({
3699da06d0Sopenharmony_ci        direction: FlexDirection.Column,
3799da06d0Sopenharmony_ci        justifyContent: FlexAlign.Center,
3899da06d0Sopenharmony_ci        alignItems: ItemAlign.Center
3999da06d0Sopenharmony_ci      }) {
4099da06d0Sopenharmony_ci        Text(this.title)
4199da06d0Sopenharmony_ci          .fontSize(18)
4299da06d0Sopenharmony_ci          .textOverflow({ overflow: TextOverflow.Ellipsis })
4399da06d0Sopenharmony_ci          .maxLines(2)
4499da06d0Sopenharmony_ci      }
4599da06d0Sopenharmony_ci      .margin({ bottom: 8, top: 10 })
4699da06d0Sopenharmony_ci
4799da06d0Sopenharmony_ci      Row() {
4899da06d0Sopenharmony_ci        Flex({
4999da06d0Sopenharmony_ci          direction: FlexDirection.Column,
5099da06d0Sopenharmony_ci          justifyContent: FlexAlign.Center,
5199da06d0Sopenharmony_ci          alignItems: ItemAlign.Center
5299da06d0Sopenharmony_ci        }) {
5399da06d0Sopenharmony_ci          Text(this.cancelText).fontColor($r('sys.color.ohos_id_color_text_primary_activated')).fontSize(18)
5499da06d0Sopenharmony_ci        }
5599da06d0Sopenharmony_ci        .layoutWeight(1)
5699da06d0Sopenharmony_ci        .height(35)
5799da06d0Sopenharmony_ci        .onClick(() => {
5899da06d0Sopenharmony_ci          this.controller.close();
5999da06d0Sopenharmony_ci          this.cancel();
6099da06d0Sopenharmony_ci        })
6199da06d0Sopenharmony_ci
6299da06d0Sopenharmony_ci        Line().width(1).height(25).backgroundColor($r('sys.color.ohos_id_color_list_separator'))
6399da06d0Sopenharmony_ci
6499da06d0Sopenharmony_ci        Flex({
6599da06d0Sopenharmony_ci          direction: FlexDirection.Column,
6699da06d0Sopenharmony_ci          justifyContent: FlexAlign.Center,
6799da06d0Sopenharmony_ci          alignItems: ItemAlign.Center
6899da06d0Sopenharmony_ci        }) {
6999da06d0Sopenharmony_ci          Text(this.confirmText).fontColor($r('sys.color.ohos_id_color_text_primary_activated')).fontSize(18)
7099da06d0Sopenharmony_ci        }
7199da06d0Sopenharmony_ci        .layoutWeight(1)
7299da06d0Sopenharmony_ci        .height(35)
7399da06d0Sopenharmony_ci        .onClick(() => {
7499da06d0Sopenharmony_ci          this.controller.close();
7599da06d0Sopenharmony_ci          this.confirm();
7699da06d0Sopenharmony_ci        })
7799da06d0Sopenharmony_ci      }
7899da06d0Sopenharmony_ci      .height('30vp')
7999da06d0Sopenharmony_ci    }
8099da06d0Sopenharmony_ci    .width('90%')
8199da06d0Sopenharmony_ci    .height($r('app.float.ConfirmDialogEx_height'))
8299da06d0Sopenharmony_ci    .borderRadius(20)
8399da06d0Sopenharmony_ci    .padding({
8499da06d0Sopenharmony_ci      bottom: $r('sys.float.ohos_id_dialog_margin_bottom'),
8599da06d0Sopenharmony_ci      right: $r('sys.float.ohos_id_notification_margin_start'),
8699da06d0Sopenharmony_ci      left: $r('sys.float.ohos_id_notification_margin_end')
8799da06d0Sopenharmony_ci    })
8899da06d0Sopenharmony_ci    .margin({ left: 12, right: 12, bottom: this.curBp === 'sm' ? 16 : 0 })
8999da06d0Sopenharmony_ci  }
9099da06d0Sopenharmony_ci}