@@ -7,6 +7,8 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter {
77
88 /// Object that contains the value to format the visual presentation.
99 private let options : OSIABWebViewOptions
10+ /// Custom headers to be used by the WebView.
11+ private let customHeaders : [ String : String ] ?
1012 /// Object that manages the browser's cache
1113 private let cacheManager : OSIABCacheManager
1214 /// Object that manages all the callbacks available for the WebView.
@@ -15,14 +17,17 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter {
1517 /// Constructor method.
1618 /// - Parameters:
1719 /// - options: Object that contains the value to format the visual presentation.
20+ /// - customHeaders: Custom headers to be used by the WebView. `nil` is provided in case of no value.
1821 /// - cacheManager: Object that manages the browser's cache
1922 /// - callbackHandler: Object that manages all the callbacks available for the WebView.
2023 public init (
21- _ options: OSIABWebViewOptions ,
24+ options: OSIABWebViewOptions ,
25+ customHeaders: [ String : String ] ? = nil ,
2226 cacheManager: OSIABCacheManager ,
2327 callbackHandler: OSIABWebViewCallbackHandler
2428 ) {
2529 self . options = options
30+ self . customHeaders = customHeaders
2631 self . cacheManager = cacheManager
2732 self . callbackHandler = callbackHandler
2833 }
@@ -36,12 +41,13 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter {
3641
3742 let viewModel = OSIABWebViewModel (
3843 url: url,
39- self . options. toConfigurationModel ( ) . toWebViewConfiguration ( ) ,
40- self . options. allowOverScroll,
41- self . options. customUserAgent,
42- self . options. allowsBackForwardNavigationGestures,
43- uiModel: self . options. toUIModel ( ) ,
44- callbackHandler: self . callbackHandler
44+ customHeaders: customHeaders,
45+ webViewConfiguration: options. toConfigurationModel ( ) . toWebViewConfiguration ( ) ,
46+ scrollViewBounces: options. allowOverScroll,
47+ customUserAgent: options. customUserAgent,
48+ backForwardNavigationGestures: options. allowsBackForwardNavigationGestures,
49+ uiModel: options. toUIModel ( ) ,
50+ callbackHandler: callbackHandler
4551 )
4652
4753 let dismissCallback : ( ) -> Void = { self . callbackHandler. onBrowserClosed ( true ) }
@@ -52,8 +58,8 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter {
5258 } else {
5359 hostingController = OSIABWebView13Controller ( rootView: . init( viewModel) , dismiss: dismissCallback)
5460 }
55- hostingController. modalPresentationStyle = self . options. modalPresentationStyle
56- hostingController. modalTransitionStyle = self . options. modalTransitionStyle
61+ hostingController. modalPresentationStyle = options. modalPresentationStyle
62+ hostingController. modalTransitionStyle = options. modalTransitionStyle
5763 hostingController. presentationController? . delegate = self
5864
5965 completionHandler ( hostingController)
@@ -66,23 +72,23 @@ private extension OSIABWebViewOptions {
6672 /// - Returns: The `OSIABWebViewConfigurationModel` equivalent value.
6773 func toConfigurationModel( ) -> OSIABWebViewConfigurationModel {
6874 . init(
69- self . mediaTypesRequiringUserActionForPlayback,
70- self . enableViewportScale,
71- self . allowInLineMediaPlayback,
72- self . surpressIncrementalRendering
75+ mediaTypesRequiringUserActionForPlayback,
76+ enableViewportScale,
77+ allowInLineMediaPlayback,
78+ surpressIncrementalRendering
7379 )
7480 }
7581
7682 /// Converts the current value to `OSIABWebViewUIModel` equivalent.
7783 /// - Returns: The `OSIABWebViewUIModel` equivalent value.
7884 func toUIModel( ) -> OSIABWebViewUIModel {
7985 . init(
80- showURL: self . showURL,
81- showToolbar: self . showToolbar,
82- toolbarPosition: self . toolbarPosition,
83- showNavigationButtons: self . showNavigationButtons,
84- leftToRight: self . leftToRight,
85- closeButtonText: self . closeButtonText
86+ showURL: showURL,
87+ showToolbar: showToolbar,
88+ toolbarPosition: toolbarPosition,
89+ showNavigationButtons: showNavigationButtons,
90+ leftToRight: leftToRight,
91+ closeButtonText: closeButtonText
8692 )
8793 }
8894}
0 commit comments