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

Adding UIColor variants of preferred color methods #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
35 changes: 32 additions & 3 deletions Sources/BetterSafariView/SafariView/SafariView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,29 @@ public struct SafariView {
///
@available(iOS 14.0, *)
public func preferredBarAccentColor(_ color: Color?) -> Self {
guard let color else { return self }

return self.preferredControlAccentColor(UIColor(color))
}

/// Sets the accent color for the background of the navigation bar and the toolbar.
///
/// This color preference is ignored if the view controller is in Private Browsing mode or displaying an antiphishing warning.
/// After the view controller is presented, changes made are not reflected.
///
/// - Parameters:
/// - color: The color to use as a bar accent color. If `nil`, the accent color continues to be inherited.
///
public func preferredBarAccentColor(_ color: UIColor?) -> Self {
var modified = self
if let color = color {
modified.preferredBarTintColor = UIColor(color)
modified.preferredBarTintColor = color
} else {
modified.preferredBarTintColor = nil
}
return modified
}

/// Sets the accent color for the control buttons on the navigation bar and the toolbar.
///
/// This color preference is ignored if the view controller is in Private Browsing mode or displaying an antiphishing warning.
Expand All @@ -91,9 +105,24 @@ public struct SafariView {
///
@available(iOS 14.0, *)
public func preferredControlAccentColor(_ color: Color?) -> Self {
guard let color else { return self }

return self.preferredControlAccentColor(UIColor(color))
}

/// Sets the accent color for the control buttons on the navigation bar and the toolbar.
///
/// This color preference is ignored if the view controller is in Private Browsing mode or displaying an antiphishing warning.
/// After the view controller is presented, changes made are not reflected.
///
/// - Parameters:
/// - color: The color to use as a control accent color. If `nil`, the accent color continues to be inherited.
///
@available(iOS 14.0, *)
public func preferredControlAccentColor(_ color: UIColor?) -> Self {
var modified = self
if let color = color {
modified.preferredControlTintColor = UIColor(color)
modified.preferredControlTintColor = color
} else {
modified.preferredControlTintColor = nil
}
Expand Down