Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OSInAppBrowserLib.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 2 additions & 6 deletions OSInAppBrowserLib.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -54,7 +53,6 @@

/* Begin PBXFileReference section */
1BB4F8BB2C36F54800F50A33 /* OSIABErrorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSIABErrorView.swift; sourceTree = "<group>"; };
7506BDD12C622B8D00409255 /* OSIABWebView13WrapperView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSIABWebView13WrapperView.swift; sourceTree = "<group>"; };
750949BE2C11D992006843E1 /* OSIABToolbarPosition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSIABToolbarPosition.swift; sourceTree = "<group>"; };
750949BF2C11D992006843E1 /* OSIABWebViewOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSIABWebViewOptions.swift; sourceTree = "<group>"; };
750949C22C11D9D0006843E1 /* OSIABWebViewRouterAdapter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSIABWebViewRouterAdapter.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -126,7 +124,6 @@
759027B22C1AFBCB00E02498 /* OSIABNavigationView.swift */,
750949C52C11D9E2006843E1 /* OSIABWebView.swift */,
750949C92C11D9E2006843E1 /* OSIABWebViewRepresentable.swift */,
7506BDD12C622B8D00409255 /* OSIABWebView13WrapperView.swift */,
750949C72C11D9E2006843E1 /* OSIABWebViewWrapperView.swift */,
);
path = Views;
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PackageDescription
let package = Package(
name: "OSInAppBrowserLib",
platforms: [
.iOS(.v14)
.iOS(.v15)
],
products: [
.library(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<OSIABWebViewWrapperView> {
/// Callback to trigger when the view controller is closed.
let dismiss: (() -> Void)?
Expand Down Expand Up @@ -131,31 +124,3 @@ private class OSIABWebViewController: UIHostingController<OSIABWebViewWrapperVie
}
}
}

/// A subclass for `UIHostingController` where it's possible to delegate the `dismiss` call to its callers.
@available(iOS, deprecated: 14.0, message: "Use OSIABWebViewController for iOS 14.0+")
private class OSIABWebView13Controller: UIHostingController<OSIABWebView13WrapperView> {
/// 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?()
})
}
}
59 changes: 16 additions & 43 deletions Sources/OSInAppBrowserLib/WebView/OSIABWebViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnyCancellable>()


/// Constructor method.
/// - Parameters:
/// - url: The current URL being displayed
Expand Down Expand Up @@ -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)
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -58,7 +57,6 @@ private extension OSIABWebViewModel {
}
}

@available(iOS 14.0, *)
struct OSIABWebViewWrapperView_Previews: PreviewProvider {
static var previews: some View {
// Default - Light Mode
Expand Down
Loading