Skip to content

Commit

Permalink
Bump to v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stleamist committed Oct 29, 2023
2 parents 8845337 + 7bd079a commit 275f2cb
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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!
Expand Down
9 changes: 7 additions & 2 deletions Demo/iOS/Views/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,19 @@ struct SafariViewPresentationModifier: ViewModifier {
var onDismiss: (() -> Void)? = nil
var representationBuilder: () -> SafariView

private var item: Binding<Bool?> {
private var item: Binding<Identified<Bool>?> {
.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() }
)
)
}
Expand Down
9 changes: 0 additions & 9 deletions Sources/BetterSafariView/Shared/Identifiables.swift

This file was deleted.

8 changes: 8 additions & 0 deletions Sources/BetterSafariView/Shared/Identified.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
struct Identified<Wrapped: Hashable>: Identifiable {

var id: Wrapped

init(_ id: Wrapped) {
self.id = id
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,18 @@ struct WebAuthenticationPresentationModifier: ViewModifier {
@Binding var isPresented: Bool
var representationBuilder: () -> WebAuthenticationSession

private var item: Binding<Bool?> {
private var item: Binding<Identified<Bool>?> {
.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() }
)
)
}
Expand Down

0 comments on commit 275f2cb

Please sign in to comment.