@@ -42,15 +42,15 @@ class OSIABWebViewModel: NSObject, ObservableObject {
4242 /// Constructor method.
4343 /// - Parameters:
4444 /// - url: The current URL being displayed
45- /// - webViewConfiguration: Collection of properties with which to initialize the WebView .
45+ /// - webView: The WebView to display and configure .
4646 /// - scrollViewBounces: Indicates if the WebView's bounce property should be enabled. Defaults to `true`.
4747 /// - customUserAgent: Sets a custom user agent for the WebView.
4848 /// - uiModel: Collection of properties to apply to the WebView's interface.
4949 /// - callbackHandler: Object that manages all the callbacks available for the WebView.
5050 init (
5151 url: URL ,
5252 customHeaders: [ String : String ] ? = nil ,
53- _ webViewConfiguration : WKWebViewConfiguration ,
53+ _ webView : WKWebView ,
5454 _ scrollViewBounces: Bool = true ,
5555 _ customUserAgent: String ? = nil ,
5656 _ backForwardNavigationGestures: Bool = true ,
@@ -59,7 +59,7 @@ class OSIABWebViewModel: NSObject, ObservableObject {
5959 ) {
6060 self . url = url
6161 self . customHeaders = customHeaders
62- self . webView = . init ( frame : . zero , configuration : webViewConfiguration )
62+ self . webView = webView
6363 self . closeButtonText = uiModel. closeButtonText
6464 self . callbackHandler = callbackHandler
6565 if uiModel. showToolbar {
@@ -82,6 +82,36 @@ class OSIABWebViewModel: NSObject, ObservableObject {
8282 self . setupBindings ( uiModel. showURL, uiModel. showToolbar, uiModel. showNavigationButtons)
8383 }
8484
85+ /// Constructor method.
86+ /// - Parameters:
87+ /// - url: The current URL being displayed
88+ /// - webViewConfiguration: Collection of properties with which to initialize the WebView.
89+ /// - scrollViewBounces: Indicates if the WebView's bounce property should be enabled. Defaults to `true`.
90+ /// - customUserAgent: Sets a custom user agent for the WebView.
91+ /// - uiModel: Collection of properties to apply to the WebView's interface.
92+ /// - callbackHandler: Object that manages all the callbacks available for the WebView.
93+ convenience init (
94+ url: URL ,
95+ customHeaders: [ String : String ] ? = nil ,
96+ _ webViewConfiguration: WKWebViewConfiguration ,
97+ _ scrollViewBounces: Bool = true ,
98+ _ customUserAgent: String ? = nil ,
99+ _ backForwardNavigationGestures: Bool = true ,
100+ uiModel: OSIABWebViewUIModel ,
101+ callbackHandler: OSIABWebViewCallbackHandler
102+ ) {
103+ self . init (
104+ url: url,
105+ customHeaders: customHeaders,
106+ WKWebView ( frame: . zero, configuration: webViewConfiguration) ,
107+ scrollViewBounces,
108+ customUserAgent,
109+ backForwardNavigationGestures,
110+ uiModel: uiModel,
111+ callbackHandler: callbackHandler
112+ )
113+ }
114+
85115 /// Setups the combine bindings, so that the Published properties can be filled automatically and reactively.
86116 private func setupBindings( _ showURL: Bool , _ showToolbar: Bool , _ showNavigationButtons: Bool ) {
87117 if #available( iOS 14 . 0 , * ) {
0 commit comments