Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move configuration to separate file #11

Merged
merged 1 commit into from
Jul 9, 2023
Merged
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
73 changes: 73 additions & 0 deletions Sources/SafariView/Configuration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// SafariView
// Configuration.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 UIKit

public extension SafariView {

/// The configuration for a ``SafariView/SafariView``
///
/// To change the configuration for the current scope, see the ``SwiftUI/View/safariConfiguration(_:)`` view modifier.
struct Configuration {

/// Create a new safari view configuration
/// - Parameters:
/// - entersReaderIfAvailable: Whether or not the view should enter reader mode automatically, if available.
/// - barCollapsingEnabled: Whether or not the view should support bar collapsing.
/// - activityButton: A custom activity button.
/// - eventAttribution: Event attribution data for Private Click Measurement.
public init(
entersReaderIfAvailable: Bool = false,
barCollapsingEnabled: Bool = false,
activityButton: ActivityButton? = nil,
eventAttribution: UIEventAttribution? = nil
) {
self.entersReaderIfAvailable = entersReaderIfAvailable
self.barCollapsingEnabled = barCollapsingEnabled
self.activityButton = activityButton
self.eventAttribution = eventAttribution
}

/// A value that specifies whether Safari should enter Reader mode, if it is available.
///
/// Set the value to `true` if Reader mode should be entered automatically when it is available for the webpage; otherwise, false. The default value is `false`.
public var entersReaderIfAvailable: Bool

/// A value that specifies whether Safari should allow bar collapsing
///
/// Set the value `true` if bar collapsing should be enabled when the user scrolls; otherwise, false. The default value is `false`.
public var barCollapsingEnabled: Bool

/// The activity button to use in the Safari View.
public var activityButton: ActivityButton?

/// An object you use to send tap event attribution data to the browser for Private Click Measurement.
///
/// For more information about preparing event attribution data, see [`UIEventAttribution`](https://developer.apple.com/documentation/uikit/uieventattribution).
public var eventAttribution: UIEventAttribution?

}

}
42 changes: 0 additions & 42 deletions Sources/SafariView/SafariView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,48 +67,6 @@ public struct SafariView: View {
/// You can generate prewarming tokens for invalidation using the ``prewarmConnections(to:)`` static method.
public typealias PrewarmingToken = SFSafariViewController.PrewarmingToken

/// The configuration for a ``SafariView/SafariView``
///
/// To change the configuration for the current scope, see the ``SwiftUI/View/safariConfiguration(_:)`` view modifier.
public struct Configuration {

/// Create a configuration for a ``SafariView/SafariView``
/// - Parameters:
/// - entersReaderIfAvailable: Whether or not Safari should enter reader mode, if it is available.
/// - barCollapsingEnabled: Whether or not Safari should support bar collapsing.
/// - eventAttribution: Event attribution for Private Click Measurement.
/// - activityButton: A custom activity button.
public init(
entersReaderIfAvailable: Bool = false,
barCollapsingEnabled: Bool = false,
eventAttribution: UIEventAttribution? = nil,
activityButton: ActivityButton? = nil
) {
self.entersReaderIfAvailable = entersReaderIfAvailable
self.barCollapsingEnabled = barCollapsingEnabled
self.eventAttribution = eventAttribution
self.activityButton = activityButton
}

/// A value that specifies whether Safari should enter Reader mode, if it is available.
///
/// Set the value to `true` if Reader mode should be entered automatically when it is available for the webpage; otherwise, false. The default value is `false`.
public var entersReaderIfAvailable: Bool

/// A value that specifies whether Safari should allow bar collapsing
///
/// Set the value `true` if bar collapsing should be enabled when the user scrolls; otherwise, false. The default value is `false`.
public var barCollapsingEnabled: Bool

/// An object you use to send tap event attribution data to the browser for Private Click Measurement.
///
/// For more information about preparing event attribution data, see [`UIEventAttribution`](https://developer.apple.com/documentation/uikit/uieventattribution).
public var eventAttribution: UIEventAttribution?

/// The activity button to use in the Safari View.
public var activityButton: ActivityButton?
}

/// Prewarm the connection to a list of provided URLs
///
/// You can use this returned value of this method to invalidate the prewarmed cache by invoking the `invaldate()` method on the token.
Expand Down