How to add ActivityIndicator while using utils.ios.openFile?


The utils.ios.openFile method returns a boolean value, but it returns much faster than iOS opens the file. This leaves the UI feeling unresponsive, with no easy way to add an ActivityIndicator.

I added one w/ a timer (for like 2000ms), but that just seems hacky (and I’ve actually run into a UI glitch w/ previously unvisited TabView tabs trying this).

There needs to be some way for me to hook into an event for either when the preview window opens or closes, but I’m just not sure how to go about doing that.

(I’m using the Angular version of NativeScript, in case that matters with this issue.)


You would have to re-implement the functionality and create your own listening events on the delegate and then use the delegate events to handle the waiting part. “utils.ios.openFile” has no ability to notify anything. ;-(

You can see how the code is implemented in the utils.ios.js file; and you can copy the code into your own file/plugin and expand the “UIDocumentInteractionControllerDelegateImpl” delegate – See the Apple docs here:
I would think that if you used the documentInteractionControllerWillBeginPreview event you could stop the animation you started when you make the open file call.

Nathanael A.


Thanks Nathanael!

That is definitely the right path, and I got it working using documentInteractionControllerDidEndPreview, which triggers an event when the preview is closed. documentInteractionControllerWillBeginPreview fires off immediately, so I ended up not being able to use it.

I’ll work on getting a plugin (or maybe PR?) posted for this.


To follow up, I have a pending PR that fixes this issue.