I am a newcomer to Nativescript and I have a WebView that loads an external website. I want to display an icon or bar while the WebView URL is loading.
This is my XML VIEW:
<Page class="page"
navigatingTo="pageLoaded"
xmlns="http://schemas.nativescript.org/tns.xsd"
actionBarHidden="true"
>
<GridLayout >
<Image src="~/img/loading1.gif" width="75%" class="logo" visibility="{{ showDetails? 'visible' : 'collapsed' }}" />
<WebView id="webView" loaded="onWebViewLoaded" loadFinished="loadFinished" src="preload.html" visibility="{{ showDetails? 'collapsed' : 'visible'}}" />
</GridLayout>
My Controller
var webViewModule = require("ui/web-view");
var observable = require("data/observable");
var pageData = new observable.Observable();
function pageLoaded(args) {
var page = args.object;
pageData.set("showDetails",true );
args.object.bindingContext = pageData;
var web = page.getViewById("webView");
web.src = "http://icon-dz.com/sap/pw";
}
function loadFinished(args) {
pageData.set("showDetails", false );
args.object.bindingContext = pageData;
}
function onWebViewLoaded(args) {
pageData.set("showDetails", false);
args.object.bindingContext = pageData;
}
exports.onWebViewLoaded = onWebViewLoaded ;
exports.loadFinished = loadFinished ;
exports.pageLoaded = pageLoaded;
Could you provide some insight into how this functionality should work exactly?