diff --git a/OSInAppBrowserLib.podspec b/OSInAppBrowserLib.podspec index aec9998..7a08793 100644 --- a/OSInAppBrowserLib.podspec +++ b/OSInAppBrowserLib.podspec @@ -27,6 +27,6 @@ Pod::Spec.new do |spec| spec.source = { :http => "https://github.com/OutSystems/OSInAppBrowserLib-iOS/releases/download/#{spec.version}/OSInAppBrowserLib.zip", :type => "zip" } spec.vendored_frameworks = "OSInAppBrowserLib.xcframework" - spec.ios.deployment_target = '13.0' + spec.ios.deployment_target = '15.0' spec.swift_versions = ['5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6', '5.7', '5.8', '5.9'] end diff --git a/OSInAppBrowserLib.xcodeproj/project.pbxproj b/OSInAppBrowserLib.xcodeproj/project.pbxproj index e051dd3..e5c83cf 100644 --- a/OSInAppBrowserLib.xcodeproj/project.pbxproj +++ b/OSInAppBrowserLib.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 1BB4F8BC2C36F54800F50A33 /* OSIABErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BB4F8BB2C36F54800F50A33 /* OSIABErrorView.swift */; }; - 7506BDD22C622B8D00409255 /* OSIABWebView13WrapperView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7506BDD12C622B8D00409255 /* OSIABWebView13WrapperView.swift */; }; 750949C02C11D992006843E1 /* OSIABToolbarPosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750949BE2C11D992006843E1 /* OSIABToolbarPosition.swift */; }; 750949C12C11D992006843E1 /* OSIABWebViewOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750949BF2C11D992006843E1 /* OSIABWebViewOptions.swift */; }; 750949C32C11D9D0006843E1 /* OSIABWebViewRouterAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750949C22C11D9D0006843E1 /* OSIABWebViewRouterAdapter.swift */; }; @@ -54,7 +53,6 @@ /* Begin PBXFileReference section */ 1BB4F8BB2C36F54800F50A33 /* OSIABErrorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSIABErrorView.swift; sourceTree = ""; }; - 7506BDD12C622B8D00409255 /* OSIABWebView13WrapperView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSIABWebView13WrapperView.swift; sourceTree = ""; }; 750949BE2C11D992006843E1 /* OSIABToolbarPosition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSIABToolbarPosition.swift; sourceTree = ""; }; 750949BF2C11D992006843E1 /* OSIABWebViewOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSIABWebViewOptions.swift; sourceTree = ""; }; 750949C22C11D9D0006843E1 /* OSIABWebViewRouterAdapter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSIABWebViewRouterAdapter.swift; sourceTree = ""; }; @@ -126,7 +124,6 @@ 759027B22C1AFBCB00E02498 /* OSIABNavigationView.swift */, 750949C52C11D9E2006843E1 /* OSIABWebView.swift */, 750949C92C11D9E2006843E1 /* OSIABWebViewRepresentable.swift */, - 7506BDD12C622B8D00409255 /* OSIABWebView13WrapperView.swift */, 750949C72C11D9E2006843E1 /* OSIABWebViewWrapperView.swift */, ); path = Views; @@ -371,7 +368,6 @@ 750949C02C11D992006843E1 /* OSIABToolbarPosition.swift in Sources */, 750949CA2C11D9E2006843E1 /* OSIABCacheManager.swift in Sources */, 759027B72C1B13CA00E02498 /* OSIABWebViewUIModel.swift in Sources */, - 7506BDD22C622B8D00409255 /* OSIABWebView13WrapperView.swift in Sources */, 754451F62C04AB69003D7361 /* OSIABViewStyle.swift in Sources */, 756346642C00F21000685AA3 /* OSIABApplicationRouterAdapter.swift in Sources */, 750949CF2C11D9E2006843E1 /* OSIABWebViewRepresentable.swift in Sources */, @@ -559,7 +555,7 @@ GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -593,7 +589,7 @@ GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Package.swift b/Package.swift index e1578b7..693500b 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ import PackageDescription let package = Package( name: "OSInAppBrowserLib", platforms: [ - .iOS(.v14) + .iOS(.v15) ], products: [ .library( diff --git a/Sources/OSInAppBrowserLib/RouterAdapters/OSIABWebViewRouterAdapter.swift b/Sources/OSInAppBrowserLib/RouterAdapters/OSIABWebViewRouterAdapter.swift index fd3c521..4176654 100644 --- a/Sources/OSInAppBrowserLib/RouterAdapters/OSIABWebViewRouterAdapter.swift +++ b/Sources/OSInAppBrowserLib/RouterAdapters/OSIABWebViewRouterAdapter.swift @@ -51,13 +51,7 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter { ) let dismissCallback: () -> Void = { self.callbackHandler.onBrowserClosed(true) } - let hostingController: UIViewController - - if #available(iOS 14.0, *) { - hostingController = OSIABWebViewController(rootView: .init(viewModel), dismiss: dismissCallback) - } else { - hostingController = OSIABWebView13Controller(rootView: .init(viewModel), dismiss: dismissCallback) - } + let hostingController: UIViewController = OSIABWebViewController(rootView: .init(viewModel), dismiss: dismissCallback) hostingController.modalPresentationStyle = options.modalPresentationStyle hostingController.modalTransitionStyle = options.modalTransitionStyle hostingController.presentationController?.delegate = self @@ -101,7 +95,6 @@ extension OSIABWebViewRouterAdapter: UIAdaptivePresentationControllerDelegate { } /// A subclass for `UIHostingController` where it's possible to delegate the `dismiss` call to its callers. -@available(iOS 14.0, *) private class OSIABWebViewController: UIHostingController { /// Callback to trigger when the view controller is closed. let dismiss: (() -> Void)? @@ -131,31 +124,3 @@ private class OSIABWebViewController: UIHostingController { - /// Callback to trigger when the view controller is closed. - let dismiss: (() -> Void)? - - /// Constructor method. - /// - Parameters: - /// - rootView: The root view of the SwiftUI view hierarchy that you want to manage using the hosting view controller. - /// - dismiss: The callback to trigger when the view controller is dismissed. - init(rootView: OSIABWebView13WrapperView, dismiss: (() -> Void)?) { - self.dismiss = dismiss - super.init(rootView: rootView) - } - - @MainActor required dynamic init?(coder aDecoder: NSCoder) { - self.dismiss = nil - super.init(coder: aDecoder) - } - - override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) { - super.dismiss(animated: flag, completion: { - self.dismiss?() - completion?() - }) - } -} diff --git a/Sources/OSInAppBrowserLib/WebView/OSIABWebViewModel.swift b/Sources/OSInAppBrowserLib/WebView/OSIABWebViewModel.swift index d581500..4655118 100644 --- a/Sources/OSInAppBrowserLib/WebView/OSIABWebViewModel.swift +++ b/Sources/OSInAppBrowserLib/WebView/OSIABWebViewModel.swift @@ -36,9 +36,7 @@ class OSIABWebViewModel: NSObject, ObservableObject { /// The current address label being displayed on the screen. Empty string indicates that the address will not be displayed. @Published private(set) var addressLabel: String = "" - - private var cancellables = Set() - + /// Constructor method. /// - Parameters: /// - url: The current URL being displayed @@ -114,47 +112,22 @@ class OSIABWebViewModel: NSObject, ObservableObject { /// Setups the combine bindings, so that the Published properties can be filled automatically and reactively. private func setupBindings(_ showURL: Bool, _ showToolbar: Bool, _ showNavigationButtons: Bool) { - if #available(iOS 14.0, *) { - webView.publisher(for: \.isLoading) - .assign(to: &$isLoading) - webView.publisher(for: \.url) - .compactMap { $0 } - .assign(to: &$url) - if showToolbar { - if showNavigationButtons { - webView.publisher(for: \.canGoBack) - .assign(to: &$backButtonEnabled) - - webView.publisher(for: \.canGoForward) - .assign(to: &$forwardButtonEnabled) - } - if showURL { - $url.map(\.absoluteString) - .assign(to: &$addressLabel) - } + webView.publisher(for: \.isLoading) + .assign(to: &$isLoading) + webView.publisher(for: \.url) + .compactMap { $0 } + .assign(to: &$url) + if showToolbar { + if showNavigationButtons { + webView.publisher(for: \.canGoBack) + .assign(to: &$backButtonEnabled) + + webView.publisher(for: \.canGoForward) + .assign(to: &$forwardButtonEnabled) } - } else { - webView.publisher(for: \.isLoading) - .assign(to: \.isLoading, on: self) - .store(in: &cancellables) - webView.publisher(for: \.url) - .compactMap { $0 } - .assign(to: \.url, on: self) - .store(in: &cancellables) - if showToolbar { - if showNavigationButtons { - webView.publisher(for: \.canGoBack) - .assign(to: \.backButtonEnabled, on: self) - .store(in: &cancellables) - webView.publisher(for: \.canGoForward) - .assign(to: \.forwardButtonEnabled, on: self) - .store(in: &cancellables) - } - if showURL { - $url.map(\.absoluteString) - .assign(to: \.addressLabel, on: self) - .store(in: &cancellables) - } + if showURL { + $url.map(\.absoluteString) + .assign(to: &$addressLabel) } } } diff --git a/Sources/OSInAppBrowserLib/WebView/Views/OSIABWebView13WrapperView.swift b/Sources/OSInAppBrowserLib/WebView/Views/OSIABWebView13WrapperView.swift deleted file mode 100644 index fba1aa9..0000000 --- a/Sources/OSInAppBrowserLib/WebView/Views/OSIABWebView13WrapperView.swift +++ /dev/null @@ -1,104 +0,0 @@ -import SwiftUI -import UIKit - -/// View that manages which view to present, depending if the page load was successful or not or is being loaded. -@available(iOS, deprecated: 14.0, message: "Use OSIABWebViewWrapperView for iOS 14.0+") -struct OSIABWebView13WrapperView: View { - /// View Model containing all the customisable elements. - @ObservedObject private var model: OSIABWebViewModel - - /// Constructor method. - /// - Parameter model: View Model containing all the customisable elements. - init(_ model: OSIABWebViewModel) { - self._model = ObservedObject(wrappedValue: model) - } - - var body: some View { - ZStack { - OSIABWebView(model) - .edgesIgnoringSafeArea(model.toolbarPosition == .bottom ? [] : .bottom) - if model.isLoading { - OSIABActivityIndicator(isAnimating: .constant(true), style: .large) - } - } - } -} - -private struct OSIABActivityIndicator: UIViewRepresentable { - @Binding private var isAnimating: Bool - private let style: UIActivityIndicatorView.Style - - init(isAnimating: Binding, style: UIActivityIndicatorView.Style) { - self._isAnimating = isAnimating - self.style = style - } - - func makeUIView(context: UIViewRepresentableContext) -> UIActivityIndicatorView { - return UIActivityIndicatorView(style: style) - } - - func updateUIView(_ uiView: UIActivityIndicatorView, context: UIViewRepresentableContext) { - if self.isAnimating { - uiView.startAnimating() - } else { - uiView.stopAnimating() - } - } -} - -// MARK: - OSIABViewModel's constructor accelerator. -private extension OSIABWebViewModel { - convenience init(toolbarPosition: OSIABToolbarPosition = .defaultValue) { - let configurationModel = OSIABWebViewConfigurationModel() - self.init( - url: .init(string: "https://outsystems.com")!, - webViewConfiguration: configurationModel.toWebViewConfiguration(), - uiModel: .init(toolbarPosition: toolbarPosition), - callbackHandler: .init( - onDelegateURL: { _ in }, - onDelegateAlertController: { _ in }, - onBrowserPageLoad: {}, - onBrowserClosed: { _ in }, - onBrowserPageNavigationCompleted: { _ in } - ) - ) - } - - convenience init(url: String) { - let configurationModel = OSIABWebViewConfigurationModel() - self.init( - url: .init(string: url)!, - webViewConfiguration: configurationModel.toWebViewConfiguration(), - uiModel: .init(), - callbackHandler: .init( - onDelegateURL: { _ in }, - onDelegateAlertController: { _ in }, - onBrowserPageLoad: {}, - onBrowserClosed: { _ in }, - onBrowserPageNavigationCompleted: { _ in } - ) - ) - } -} - -struct OSIABWebView13WrapperView_Previews: PreviewProvider { - static var previews: some View { - - // Default - Light Mode - OSIABWebView13WrapperView(.init()) - - // Default - Dark Mode - OSIABWebView13WrapperView(.init()) - .preferredColorScheme(.dark) - - // Bottom Toolbar Defined - OSIABWebView13WrapperView(.init(toolbarPosition: .bottom)) - - // Error View - Light mode - OSIABWebView13WrapperView(.init(url: "https://outsystems/")) - - // Error View - Dark mode - OSIABWebView13WrapperView(.init(url: "https://outsystems/")) - .preferredColorScheme(.dark) - } -} diff --git a/Sources/OSInAppBrowserLib/WebView/Views/OSIABWebViewWrapperView.swift b/Sources/OSInAppBrowserLib/WebView/Views/OSIABWebViewWrapperView.swift index 40adc94..d49d0ba 100644 --- a/Sources/OSInAppBrowserLib/WebView/Views/OSIABWebViewWrapperView.swift +++ b/Sources/OSInAppBrowserLib/WebView/Views/OSIABWebViewWrapperView.swift @@ -1,7 +1,6 @@ import SwiftUI /// View that manages which view to present, depending if the page load was successful or not or is being loaded. -@available(iOS 14.0, *) struct OSIABWebViewWrapperView: View { /// View Model containing all the customisable elements. @StateObject private var model: OSIABWebViewModel @@ -58,7 +57,6 @@ private extension OSIABWebViewModel { } } -@available(iOS 14.0, *) struct OSIABWebViewWrapperView_Previews: PreviewProvider { static var previews: some View { // Default - Light Mode