Skip to content

Commit

Permalink
Split SafariView and WebAuthentication into separate packages
Browse files Browse the repository at this point in the history
  • Loading branch information
vsanthanam committed Aug 19, 2023
1 parent acbcc2b commit 3dc0534
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 80 deletions.
17 changes: 17 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ let package = Package(
name: "SafariUI",
targets: ["SafariUI"]
),
.library(
name: "SafariView",
targets: ["SafariView"]
),
.library(
name: "WebAuthentication",
targets: ["WebAuthentication"]
),

],
dependencies: [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
Expand All @@ -22,6 +31,14 @@ let package = Package(
targets: [
.target(
name: "SafariUI",
dependencies: ["SafariView", "WebAuthentication"]
),
.target(
name: "SafariView",
dependencies: []
),
.target(
name: "WebAuthentication",
dependencies: []
),
.testTarget(
Expand Down
6 changes: 3 additions & 3 deletions Sources/SafariUI/SafariUI.docc/ExcludedActivityTypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ You can initialize instances of this type using an array literal of `UIActivity.
let excluded: SafariView.ExcludedActivityTypes = [.addToReadingList, .airDrop, .print, .sharePlay]
```

To change the the excluded activity types used by ``SafariView`` at the current scope, use the ``SwiftUI/View/excludedSafariActivityTypes(_:)-4omxw`` view modifier, or the ``SwiftUI/EnvironmentValues/safariViewExcludedActivityTypes`` environment value.
To change the the excluded activity types used by ``SafariView`` at the current scope, use the ``SwiftUI/View/excludedSafariActivityTypes(_:)-tvrg`` view modifier, or the ``SwiftUI/EnvironmentValues/safariViewExcludedActivityTypes`` environment value.

## Topics

### Initializers

- ``init(_:)-92zvd``
- ``init(_:)-93kn9``
- ``init(_:)-1ktmq``
- ``init(_:)-67duh``

### Operators

Expand Down
6 changes: 3 additions & 3 deletions Sources/SafariUI/SafariUI.docc/IncludedActivities.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ You can initialize instances of this type using an array literal of `UIActivity`
let excluded: SafariView.IncludedActivities = [someActivity, someOtherActivity]
```

To change the the included activities used by ``SafariView`` at the current scope, use the ``SwiftUI/View/includedSafariActivities(_:)-7buso`` view modifier, or the ``SwiftUI/EnvironmentValues/safariViewIncludedActivities`` environment value.
To change the the included activities used by ``SafariView`` at the current scope, use the ``SwiftUI/View/includedSafariActivities(_:)-2u8l9`` view modifier, or the ``SwiftUI/EnvironmentValues/safariViewIncludedActivities`` environment value.

## Topics

### Initializers

- ``init(_:)-6ig8b``
- ``init(_:)-43y6f``
- ``init(_:)-6d955``
- ``init(_:)-9q5v6``

### Operators

Expand Down
12 changes: 6 additions & 6 deletions Sources/SafariUI/SafariUI.docc/View.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ SwiftUI view modifiers used to configure a ``SafariView`` or a ``WebAuthenticati

### SafarView Custom Activities

- ``SwiftUI/View/includedSafariActivities(_:)-1yaml``
- ``SwiftUI/View/includedSafariActivities(_:)-7buso``
- ``SwiftUI/View/excludedSafariActivityTypes(_:)-5sf78``
- ``SwiftUI/View/excludedSafariActivityTypes(_:)-4omxw``
- ``SwiftUI/View/includedSafariActivities(_:)-362lz``
- ``SwiftUI/View/includedSafariActivities(_:)-2u8l9``
- ``SwiftUI/View/excludedSafariActivityTypes(_:)-1v8zq``
- ``SwiftUI/View/excludedSafariActivityTypes(_:)-tvrg``

### WebAuthentication Configuration

- ``SwiftUI/View/webAuthenticationPrefersEphemeralWebBrowserSession(_:)``

### WebAuthentication Presentation

- ``SwiftUI/View/webAuthentication(_:webAuthentication:)-5m8qc``
- ``SwiftUI/View/webAuthentication(_:webAuthentication:)-9e7q7``
- ``SwiftUI/View/webAuthentication(_:webAuthentication:)-74m38``
- ``SwiftUI/View/webAuthentication(_:webAuthentication:)-5x82p``
- ``SwiftUI/View/webAuthentication(_:id:webAuthentication:)``
29 changes: 29 additions & 0 deletions Sources/SafariUI/SafariUI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SafariUI
// SafariUI.swift
//
// MIT License
//
// Copyright (c) 2021 Varun Santhanam
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
//
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

@_exported import SafariView
@_exported import WebAuthentication

struct SafariUIHolder {}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ extension EnvironmentValues {
set { self[SafariViewDismissButtonStyleEnvironmentKey.self] = newValue }
}

var webAuthenticationPrefersEphemeralWebBrowserSession: Bool {
get { self[WebAuthenticationPrefersEphemeralWebBrowserSessionEnvironmentKey.self] }
set { self[WebAuthenticationPrefersEphemeralWebBrowserSessionEnvironmentKey.self] = newValue }
}

}

private struct SafariViewEntersReaderIfAvailableEnvironmentKey: EnvironmentKey {
Expand Down Expand Up @@ -167,11 +162,3 @@ private struct SafariViewExcludedActivityTypesEnvironmentKey: EnvironmentKey {
static let defaultValue: Value = .default

}

private struct WebAuthenticationPrefersEphemeralWebBrowserSessionEnvironmentKey: EnvironmentKey {

typealias Value = Bool

static let defaultValue: Bool = false

}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,6 @@ public extension View {
return ModifiedContent(content: self, modifier: modifier)
}

func webAuthenticationPrefersEphemeralWebBrowserSession(_ prefersEphemeralWebBrowserSession: Bool = true) -> some View {
let modifer = WebAuthenticationPrefersEphemeralWebBrowserSessionModifier(prefersEphemeralWebBrowserSession: prefersEphemeralWebBrowserSession)
return ModifiedContent(content: self, modifier: modifer)
}

}

private struct SafariViewEntersReaderIfAvailableModifier: ViewModifier {
Expand Down Expand Up @@ -361,24 +356,3 @@ private struct SafariViewExcludedActivityTypesModifier: ViewModifier {
private let activityTypes: SafariView.ExcludedActivityTypes

}

private struct WebAuthenticationPrefersEphemeralWebBrowserSessionModifier: ViewModifier {

// MARK: - Initializers

init(prefersEphemeralWebBrowserSession: Bool) {
self.prefersEphemeralWebBrowserSession = prefersEphemeralWebBrowserSession
}

// MARK: - ViewModifier

@ViewBuilder
func body(content: Content) -> some View {
content
.environment(\.webAuthenticationPrefersEphemeralWebBrowserSession, prefersEphemeralWebBrowserSession)
}

// MARK: - Private

private let prefersEphemeralWebBrowserSession: Bool
}
Original file line number Diff line number Diff line change
Expand Up @@ -274,32 +274,3 @@ public extension View {
)
}
}

public extension View {

func webAuthentication(
_ isPresented: Binding<Bool>,
webAuthentication: @escaping () -> WebAuthentication
) -> some View {
let modifier = WebAuthentication.BoolModifier(isPresented: isPresented, build: webAuthentication)
return ModifiedContent(content: self, modifier: modifier)
}

func webAuthentication<Item>(
_ item: Binding<Item?>,
webAuthentication: @escaping (Item) -> WebAuthentication
) -> some View where Item: Identifiable {
let modifier = WebAuthentication.IdentifiableItemModitifer(item: item, build: webAuthentication)
return ModifiedContent(content: self, modifier: modifier)
}

func webAuthentication<Item, Identifier>(
_ item: Binding<Item?>,
id: KeyPath<Item, Identifier>,
webAuthentication: @escaping (Item) -> WebAuthentication
) -> some View where Identifier: Hashable {
let modifier = WebAuthentication.ItemModifier(item: item, id: id, build: webAuthentication)
return ModifiedContent(content: self, modifier: modifier)
}

}
File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions Sources/WebAuthentication/Environment.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SafariUI
// Environment.swift
//
// MIT License
//
// Copyright (c) 2021 Varun Santhanam
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
//
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import SwiftUI

extension EnvironmentValues {

var webAuthenticationPrefersEphemeralWebBrowserSession: Bool {
get { self[WebAuthenticationPrefersEphemeralWebBrowserSessionEnvironmentKey.self] }
set { self[WebAuthenticationPrefersEphemeralWebBrowserSessionEnvironmentKey.self] = newValue }
}

}

private struct WebAuthenticationPrefersEphemeralWebBrowserSessionEnvironmentKey: EnvironmentKey {

typealias Value = Bool

static let defaultValue: Bool = false

}
56 changes: 56 additions & 0 deletions Sources/WebAuthentication/Modifiers.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// SafariUI
// Modifiers.swift
//
// MIT License
//
// Copyright (c) 2021 Varun Santhanam
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
//
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import SwiftUI

public extension View {

func webAuthenticationPrefersEphemeralWebBrowserSession(_ prefersEphemeralWebBrowserSession: Bool = true) -> some View {
let modifer = WebAuthenticationPrefersEphemeralWebBrowserSessionModifier(prefersEphemeralWebBrowserSession: prefersEphemeralWebBrowserSession)
return ModifiedContent(content: self, modifier: modifer)
}

}

private struct WebAuthenticationPrefersEphemeralWebBrowserSessionModifier: ViewModifier {

// MARK: - Initializers

init(prefersEphemeralWebBrowserSession: Bool) {
self.prefersEphemeralWebBrowserSession = prefersEphemeralWebBrowserSession
}

// MARK: - ViewModifier

@ViewBuilder
func body(content: Content) -> some View {
content
.environment(\.webAuthenticationPrefersEphemeralWebBrowserSession, prefersEphemeralWebBrowserSession)
}

// MARK: - Private

private let prefersEphemeralWebBrowserSession: Bool
}
55 changes: 55 additions & 0 deletions Sources/WebAuthentication/Presentation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SafariUI
// Presentation.swift
//
// MIT License
//
// Copyright (c) 2021 Varun Santhanam
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
//
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import SwiftUI

public extension View {

func webAuthentication(
_ isPresented: Binding<Bool>,
webAuthentication: @escaping () -> WebAuthentication
) -> some View {
let modifier = WebAuthentication.BoolModifier(isPresented: isPresented, build: webAuthentication)
return ModifiedContent(content: self, modifier: modifier)
}

func webAuthentication<Item>(
_ item: Binding<Item?>,
webAuthentication: @escaping (Item) -> WebAuthentication
) -> some View where Item: Identifiable {
let modifier = WebAuthentication.IdentifiableItemModitifer(item: item, build: webAuthentication)
return ModifiedContent(content: self, modifier: modifier)
}

func webAuthentication<Item, Identifier>(
_ item: Binding<Item?>,
id: KeyPath<Item, Identifier>,
webAuthentication: @escaping (Item) -> WebAuthentication
) -> some View where Identifier: Hashable {
let modifier = WebAuthentication.ItemModifier(item: item, id: id, build: webAuthentication)
return ModifiedContent(content: self, modifier: modifier)
}

}
File renamed without changes.

0 comments on commit 3dc0534

Please sign in to comment.