nativescript-cfalert-dialog icon indicating copy to clipboard operation
nativescript-cfalert-dialog copied to clipboard

iOS: problem with programmatically close the dialog

Open cristiandaulisio opened this issue 5 years ago • 8 comments

Which platform(s) does your issue occur on?

  • iOS 13
  • iPhone 7

I'm using this plugin for iOS. All work fine, except that when I want programmatically close the dialog.

If I call "dismiss" the dialog close, but the app freeze, while if I click on the dialog button close all work fine. Need to declare something else?

Thanks

cristiandaulisio avatar May 04 '20 09:05 cristiandaulisio

Can you show me the code of how you are dismissing the alert? At what point in the code?

shiv19 avatar May 04 '20 10:05 shiv19

Ty for fast answer

let cfalertDialog = new CFAlertDialog(); let config: {..} cfalertDialog.show(config); cfalertDialog.dismiss();

The dialog go away but something go wrong with the app, while if I click on cancel it is all ok.

cristiandaulisio avatar May 04 '20 10:05 cristiandaulisio

Well I think is better If I paste the full code:

`public CreateConfirm(options: any): Promise<boolean>
    {
        return new Promise((resolve, reject) =>
        {
            
                let cfalertDialog = new CFAlertDialog();
 
                let config: DialogOptions = {
                    // Options go here
                    dialogStyle: CFAlertStyle.ALERT,
                    title: options.title,
                    message: options.message,
                    cancellable: false,
                    onDismiss: function (dialog) {
                        resolve(false)
                    },
                    buttons: [{
                        text: "INVIA", // title
                        buttonStyle: CFAlertActionStyle.POSITIVE,
                        buttonAlignment: CFAlertActionAlignment.JUSTIFIED,
                        onClick: function ()
                        {
                            resolve(true);
                        }
                            
                    },{
                        text: "ANNULLA", // title
                        buttonStyle: CFAlertActionStyle.DEFAULT,
                        buttonAlignment: CFAlertActionAlignment.JUSTIFIED,
                        onClick: function ()
                        { 
                            resolve(false);
                        }
                    }]
                    }
 
                cfalertDialog.show(config); 
                this.dialog = cfalertDialog;
            
        });
    }
    
    public Close(): Promise<boolean>
    {
        return new Promise(async(resolve, reject) =>
{
            if (this.dialog !== null)
            {
            
                this.dialog.dismiss();
                this.dialog = null;
            }
            
            resolve(true);
        });
    }`

cristiandaulisio avatar May 04 '20 10:05 cristiandaulisio

Other infos that can be useful:

result = await this.DialogResume();
console.log("Action on dialog);
public async DialogResume(): Promise<boolean>
{
const result = this._lastDialog.CreateConfirm({
            title: "This is the title"
            message: "This is the message"
        });
        return result;
}

I notice that I receive this exception: Unbalanced calls to begin/end appearance transitions for <UIViewControllerImpl: 0x15dea9ae0>.

cristiandaulisio avatar May 04 '20 11:05 cristiandaulisio

update: if i write this.dialog.dismiss(true); it work!

cristiandaulisio avatar May 05 '20 07:05 cristiandaulisio

@Atomico001 Yes, it mentioned in the readme that the dismiss function takes a boolean as the parameter. And it doesn't have a default value in the code. You have to pass a boolean to it.

shiv19 avatar May 05 '20 08:05 shiv19

Hi @shiv19 i was trying all time with this.dialog.dismiss(false); and it didn't worked. Only with true work.

cristiandaulisio avatar May 05 '20 08:05 cristiandaulisio

That is weird! Thanks for reporting this :)

shiv19 avatar May 05 '20 10:05 shiv19