diff --git a/CHANGELOG.md b/CHANGELOG.md index ead4d9f..cab0687 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [v3.0.0](https://github.com/stleamist/BetterSafariView/releases/tag/v3.0.0) (2023-10-30) +### Removed +- Removed public `Identifiable` conformance from `Bool` & `URL`. + ## [v2.4.2](https://github.com/stleamist/BetterSafariView/releases/tag/v2.4.2) (2023-10-30) ### Fixed - Fixed an issue where the `SafariViewPresenter` fails to find a view controller to presented from (#41 & #46). Thanks, @Tunous and @SongJiyeon! diff --git a/Demo/iOS/Views/RootView.swift b/Demo/iOS/Views/RootView.swift index a687ce1..2bf8baa 100644 --- a/Demo/iOS/Views/RootView.swift +++ b/Demo/iOS/Views/RootView.swift @@ -62,10 +62,15 @@ struct RootView: View { } .prefersEphemeralWebBrowserSession(webAuthenticationSessionOptions.prefersEphemeralWebBrowserSession) } - .alert(item: $webAuthenticationSessionCallbackURL) { callbackURL in + .alert( + isPresented: Binding( + get: { webAuthenticationSessionCallbackURL != nil }, + set: { if !$0 { webAuthenticationSessionCallbackURL = nil } } + ) + ) { Alert( title: Text("Session Completed with Callback URL"), - message: Text(callbackURL.absoluteString), + message: (webAuthenticationSessionCallbackURL?.absoluteString).flatMap(Text.init(_:)), dismissButton: nil ) } diff --git a/README.md b/README.md index 2813d90..bda5623 100644 --- a/README.md +++ b/README.md @@ -285,7 +285,7 @@ func prefersEphemeralWebBrowserSession(_ prefersEphemeralWebBrowserSession: Bool Add the following line to the `dependencies` in your [`Package.swift`](https://developer.apple.com/documentation/swift_packages/package) file: ```swift -.package(url: "https://github.com/stleamist/BetterSafariView.git", .upToNextMajor(from: "2.4.2")) +.package(url: "https://github.com/stleamist/BetterSafariView.git", .upToNextMajor(from: "3.0.0")) ``` Next, add `BetterSafariView` as a dependency for your targets: @@ -304,7 +304,7 @@ import PackageDescription let package = Package( name: "MyPackage", dependencies: [ - .package(url: "https://github.com/stleamist/BetterSafariView.git", .upToNextMajor(from: "2.4.2")) + .package(url: "https://github.com/stleamist/BetterSafariView.git", .upToNextMajor(from: "3.0.0")) ], targets: [ .target(name: "MyTarget", dependencies: ["BetterSafariView"]) diff --git a/Sources/BetterSafariView/SafariView/SafariViewPresentationModifier.swift b/Sources/BetterSafariView/SafariView/SafariViewPresentationModifier.swift index 8adca32..2db53da 100644 --- a/Sources/BetterSafariView/SafariView/SafariViewPresentationModifier.swift +++ b/Sources/BetterSafariView/SafariView/SafariViewPresentationModifier.swift @@ -8,24 +8,19 @@ struct SafariViewPresentationModifier: ViewModifier { var onDismiss: (() -> Void)? = nil var representationBuilder: () -> SafariView - private var item: Binding { + private var item: Binding?> { .init( - get: { self.isPresented ? true : nil }, + get: { self.isPresented ? Identified(true) : nil }, set: { self.isPresented = ($0 != nil) } ) } - // Converts `() -> Void` closure to `(Bool) -> Void` - private func itemRepresentationBuilder(bool: Bool) -> SafariView { - return representationBuilder() - } - func body(content: Content) -> some View { content.background( SafariViewPresenter( item: item, onDismiss: onDismiss, - representationBuilder: itemRepresentationBuilder + representationBuilder: { _ in representationBuilder() } ) ) } diff --git a/Sources/BetterSafariView/Shared/Identifiables.swift b/Sources/BetterSafariView/Shared/Identifiables.swift deleted file mode 100644 index 3445401..0000000 --- a/Sources/BetterSafariView/Shared/Identifiables.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Foundation - -extension Bool: Identifiable { - public var id: Bool { self } -} - -extension URL: Identifiable { - public var id: String { self.absoluteString } -} diff --git a/Sources/BetterSafariView/Shared/Identified.swift b/Sources/BetterSafariView/Shared/Identified.swift new file mode 100644 index 0000000..9e8d2a5 --- /dev/null +++ b/Sources/BetterSafariView/Shared/Identified.swift @@ -0,0 +1,8 @@ +struct Identified: Identifiable { + + var id: Wrapped + + init(_ id: Wrapped) { + self.id = id + } +} diff --git a/Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationPresentationModifier.swift b/Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationPresentationModifier.swift index e4f0023..679d5c2 100644 --- a/Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationPresentationModifier.swift +++ b/Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationPresentationModifier.swift @@ -7,23 +7,18 @@ struct WebAuthenticationPresentationModifier: ViewModifier { @Binding var isPresented: Bool var representationBuilder: () -> WebAuthenticationSession - private var item: Binding { + private var item: Binding?> { .init( - get: { self.isPresented ? true : nil }, + get: { self.isPresented ? Identified(true) : nil }, set: { self.isPresented = ($0 != nil) } ) } - // Converts `() -> Void` closure to `(Bool) -> Void` - private func itemRepresentationBuilder(bool: Bool) -> WebAuthenticationSession { - return representationBuilder() - } - func body(content: Content) -> some View { content.background( WebAuthenticationPresenter( item: item, - representationBuilder: itemRepresentationBuilder + representationBuilder: { _ in representationBuilder() } ) ) }