| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import promptAction from '@ohos.promptAction';
- @CustomDialog
- export struct CustomDialogView {
- @Link visible: boolean;
- controller: CustomDialogController;
- // 弹窗交互事件参数,点击确认和取消按钮时的回调函数
- onCancel?: () => void;
- onConfirm?: () => void;
- @Prop text: ResourceStr
- build() {
- Column() {
- Text(this.text)
- .fontSize($r('app.integer.custom_dialog_content_font_size'))
- .fontColor(Color.Black)
- .padding({ top: $r('app.integer.ohos_id_card_padding_start') })
- Row() {
- Button($r('app.string.custom_dialog_cancel'))
- .backgroundColor($r('app.color.ohos_id_color_background'))
- .fontColor($r('app.color.ohos_id_color_emphasize'))
- .fontSize($r('app.integer.custom_dialog_content_font_size'))
- .width($r('app.integer.custom_dialog_button_width'))
- .onClick(() => {
- this.visible = false;
- this.onCancel?.();
- })
- Button($r('app.string.custom_dialog_confirm'))
- .backgroundColor($r('app.color.ohos_id_color_background'))
- .fontColor($r('app.color.ohos_id_color_emphasize'))
- .fontSize($r('app.integer.custom_dialog_content_font_size'))
- .width($r('app.integer.custom_dialog_button_width'))
- .onClick(() => {
- if (this.onConfirm) {
- this.onConfirm()
- }
- })
- }
- .justifyContent(FlexAlign.Center)
- }
- .borderRadius($r('app.integer.ohos_id_corner_radius_default_m'))
- .justifyContent(FlexAlign.SpaceAround)
- .backgroundColor($r('app.color.ohos_id_color_background'))
- .height($r('app.integer.custom_dialog_column_height'))
- .width($r('app.integer.custom_dialog_column_width'))
- }
- }
|