Skip to content

Commit 561919b

Browse files
committed
Bump to v2.3.1
2 parents 1d0d8d8 + 0d15ad1 commit 561919b

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [v2.3.1](https://github.com/stleamist/BetterSafariView/releases/tag/v2.3.1) (2020-01-20)
4+
### Fixed
5+
- Fixed an issue where the `SafariView` is not presented on the modal sheets (#9). Thanks @boherna!
6+
37
## [v2.3.0](https://github.com/stleamist/BetterSafariView/releases/tag/v2.3.0) (2021-01-19)
48
### Added
59
- Added `WebAuthenticationSession` support for macOS and watchOS.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func prefersEphemeralWebBrowserSession(_ prefersEphemeralWebBrowserSession: Bool
282282
Add the following line to the `dependencies` in your [`Package.swift`](https://developer.apple.com/documentation/swift_packages/package) file:
283283

284284
```swift
285-
.package(url: "https://github.com/stleamist/BetterSafariView.git", .upToNextMajor(from: "2.3.0"))
285+
.package(url: "https://github.com/stleamist/BetterSafariView.git", .upToNextMajor(from: "2.3.1"))
286286
```
287287

288288
Next, add `BetterSafariView` as a dependency for your targets:
@@ -301,7 +301,7 @@ import PackageDescription
301301
let package = Package(
302302
name: "MyPackage",
303303
dependencies: [
304-
.package(url: "https://github.com/stleamist/BetterSafariView.git", .upToNextMajor(from: "2.3.0"))
304+
.package(url: "https://github.com/stleamist/BetterSafariView.git", .upToNextMajor(from: "2.3.1"))
305305
],
306306
targets: [
307307
.target(name: "MyTarget", dependencies: ["BetterSafariView"])

Sources/BetterSafariView/SafariView/SafariViewPresenter.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ extension SafariViewPresenter {
7575
// MARK: Presentation Handlers
7676

7777
private func presentSafariViewController(with item: Item) {
78+
guard uiViewController.presentedViewController == nil else {
79+
return
80+
}
81+
7882
let representation = parent.representationBuilder(item)
7983
let safariViewController = SFSafariViewController(url: representation.url, configuration: representation.configuration)
8084
safariViewController.delegate = self
@@ -83,8 +87,9 @@ extension SafariViewPresenter {
8387
// There is a problem that page loading and parallel push animation are not working when a modifier is attached to the view in a `List`.
8488
// As a workaround, use a `rootViewController` of the `window` for presenting.
8589
// (Unlike the other view controllers, a view controller hosted by a cell doesn't have a parent, but has the same window.)
86-
let presentingViewController = uiViewController.view.window?.rootViewController ?? uiViewController
87-
presentingViewController.present(safariViewController, animated: true)
90+
var presentingViewController = uiViewController.view.window?.rootViewController
91+
presentingViewController = presentingViewController?.presentedViewController ?? presentingViewController ?? uiViewController
92+
presentingViewController?.present(safariViewController, animated: true)
8893
}
8994

9095
private func updateSafariViewController(with item: Item) {
@@ -96,16 +101,22 @@ extension SafariViewPresenter {
96101
}
97102

98103
private func dismissSafariViewController(completion: (() -> Void)? = nil) {
104+
let dismissCompletion: () -> Void = {
105+
self.handleDismissalWithoutResettingItemBinding()
106+
completion?()
107+
}
108+
109+
guard uiViewController.presentedViewController != nil else {
110+
dismissCompletion()
111+
return
112+
}
99113

100114
// Check if the `uiViewController` is a instance of the `SFSafariViewController`
101115
// to prevent other controllers presented by the container view from being dismissed unintentionally.
102-
guard uiViewController.presentedViewController is SFSafariViewController else {
116+
guard let safariViewController = uiViewController.presentedViewController as? SFSafariViewController else {
103117
return
104118
}
105-
uiViewController.dismiss(animated: true) {
106-
self.handleDismissalWithoutResettingItemBinding()
107-
completion?()
108-
}
119+
safariViewController.dismiss(animated: true, completion: dismissCompletion)
109120
}
110121

111122
// MARK: Dismissal Handlers

0 commit comments

Comments
 (0)