nativescript-awesome-webview-with-custom-menu-items
Version:
Awesome WebViews for all NativeScript Apps!
51 lines • 2.57 kB
JavaScript
import { Color } from '@nativescript/core';
var SFSafariViewControllerDelegateImpl = /** @class */ (function (_super) {
__extends(SFSafariViewControllerDelegateImpl, _super);
function SFSafariViewControllerDelegateImpl() {
return _super !== null && _super.apply(this, arguments) || this;
}
SFSafariViewControllerDelegateImpl.initWithOwnerCallback = function (owner, callback, activityItems) {
var delegate = SFSafariViewControllerDelegateImpl.new();
delegate._owner = owner;
delegate._callback = callback;
delegate._activityItems = activityItems;
return delegate;
};
SFSafariViewControllerDelegateImpl.prototype.safariViewControllerDidCompleteInitialLoad = function (controller, didLoadSuccessfully) {
console.log('Delegate, safariViewControllerDidCompleteInitialLoad: ' + didLoadSuccessfully);
};
SFSafariViewControllerDelegateImpl.prototype.safariViewControllerDidFinish = function (controller) {
if (this._callback && typeof this._callback === 'function') {
this._callback(true);
}
};
SFSafariViewControllerDelegateImpl.prototype.safariViewControllerActivityItemsForURLTitle = function (controller, URL, title) {
console.log('Delegate, safariViewControllerActivityItemsForURLTitle');
return this._activityItems;
};
;
SFSafariViewControllerDelegateImpl.ObjCProtocols = [SFSafariViewControllerDelegate];
return SFSafariViewControllerDelegateImpl;
}(NSObject));
export function init() { }
export function openWebView(options) {
if (!options.url) {
throw new Error('No url set in the Awesome WebView Options object.');
}
let sfc = SFSafariViewController.alloc().initWithURL(NSURL.URLWithString(options.url));
if (options.toolbarColor) {
sfc.preferredBarTintColor = new Color(options.toolbarColor).ios;
}
if (options.toolbarControlsColor) {
sfc.preferredControlTintColor = new Color(options.toolbarControlsColor).ios;
}
if (options.dismissButtonStyle) {
sfc.dismissButtonStyle = options.dismissButtonStyle;
}
sfc.delegate = SFSafariViewControllerDelegateImpl.initWithOwnerCallback(new WeakRef({}), options.isClosed, options.activityItems);
let app = UIApplication.sharedApplication;
const animated = true;
const completionHandler = null;
(options.iosViewController || app.keyWindow.rootViewController).presentViewControllerAnimatedCompletion(sfc, animated, completionHandler);
}
//# sourceMappingURL=awesome-webview.ios.js.map