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

TypeError: result.dialog.dismissAnimatedCompletion is not a function

Open felixkrautschuk opened this issue 7 years ago • 5 comments

Hi,

I try to set up the dialog for iOS, but I always get the following error when I try to close the dialog after an http request has finished: TypeError: result.dialog.dismissAnimatedCompletion is not a function. (In 'result.dialog.dismissAnimatedCompletion(true, null)', 'result.dialog.dismissAnimatedCompletion' is undefined)

This is what I am doing:

exports.showActivityIndicatorDialog = function() {
    if(platform.device.os === platform.platformNames.ios){
        nativeView = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(UIActivityIndicatorViewStyle.UIActivityIndicatorViewStyleGray);
        nativeView.startAnimating();
    } else if(platform.device.os === platform.platformNames.android){
        nativeView = new android.widget.ProgressBar(application.android.currentContext);
        nativeView.setIndeterminate(true);
        nativeView.setPadding(0, 0, 0, 30); //left, top, right, bottom
    }

    dialog.show({
        message: "Some message",
        cancelButtonText: "",
        nativeView: nativeView
    }).then(function(result){
        console.log(result);
    });
};


exports.closeActivityIndicatorDialog = function() {
    try {
        dialog.close();
    } catch(e) {
        console.log(e);
    }
};

So when any http-request in my app has finished, I try to call the closeActivityIndicatorDialog function. My testing environment:

  • Telerik AppBuilder 3.7.0
  • NativeScript 2.5
  • tns-core-modules: 2.5.2
  • nativescript-dialog: 0.1.0
  • iPhone 4S with iOS 8.4

Everything works fine on Android. Does anybody know what is going wrong here on iOS?

Best regards, Felix

felixkrautschuk avatar Mar 31 '17 11:03 felixkrautschuk

It is broken code, I just traced it down myself.

@enchev - The actual function should be dismissViewControllerAnimatedCompletion not dismissAnimatedCompletion

NathanaelA avatar Apr 09 '17 21:04 NathanaelA

@enchev - Another issue with the manual close routine is the promise should be resolved in the dismissViewControllerAnimatedCompletion completion callback, not outside of it. Otherwise if you attempt to navigate in the promise after you call the close, you are dead...

This is my version of the close routine; it

exports.close = function () {
  if(result){
	  if(result.dialog instanceof SDCAlertController){
		  result.dialog.dismissViewControllerAnimatedCompletion(true, function() {
			  if(result.resolve instanceof Function){
				  result.resolve(true);
			  }
		  });
	  }
  }
}

NathanaelA avatar Apr 10 '17 17:04 NathanaelA

Can you say when the fix will get officially released?

felixkrautschuk avatar May 03 '17 09:05 felixkrautschuk

Please run this PR. https://github.com/enchev/nativescript-dialog/pull/16

shauntif avatar Jun 19 '17 23:06 shauntif

This is now fixed in https://github.com/nstudio/nativescript-dialog and our fork of this can be easily installed using tns plugin install @nstudio/nativescript-dialog

NathanaelA avatar Apr 25 '19 20:04 NathanaelA