Skip to content
Open
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
7 changes: 5 additions & 2 deletions browser/ios/Plugin/Browser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ import SafariServices
return safariViewController
}

@objc public func prepare(for url: URL, withTint tint: UIColor? = nil, modalPresentation style: UIModalPresentationStyle = .fullScreen) -> Bool {
@objc public func prepare(for url: URL, withBarTint toolbar: UIColor? = nil, withControlsTint controls: UIColor? = nil, modalPresentation style: UIModalPresentationStyle = .fullScreen) -> Bool {
if safariViewController == nil, let scheme = url.scheme?.lowercased(), ["http", "https"].contains(scheme) {
let safariVC = SFSafariViewController(url: url)
safariVC.delegate = self
if let color = tint {
if let color = toolbar {
safariVC.preferredBarTintColor = color
}
if let color = controls {
safariVC.preferredControlTintColor = color
}
safariVC.modalPresentationStyle = style
if style == .popover {
DispatchQueue.main.async {
Expand Down
6 changes: 5 additions & 1 deletion browser/ios/Plugin/BrowserPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ public class CAPBrowserPlugin: CAPPlugin {
if let toolbarColor = call.getString("toolbarColor") {
color = UIColor.capacitor.color(fromHex: toolbarColor)
}
var controlsColor: UIColor?
if let controlsColorStr = call.getString("controlsColor") {
controlsColor = UIColor.capacitor.color(fromHex: controlsColorStr)
}
let style = self.presentationStyle(for: call.getString("presentationStyle"))
// prepare for display
guard implementation.prepare(for: url, withTint: color, modalPresentation: style), let viewController = implementation.viewController else {
guard implementation.prepare(for: url, withBarTint: color, withControlsTint: controlsColor, modalPresentation: style), let viewController = implementation.viewController else {
call.reject("Unable to display URL")
return
}
Expand Down
7 changes: 7 additions & 0 deletions browser/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ export interface OpenOptions {
*/
toolbarColor?: string;

/**
* A hex color to which the color of controls in the toolbar are set.
*
* @since 1.0.0
*/
controlsColor?: string;

/**
* iOS only: The presentation style of the browser. Defaults to fullscreen.
*
Expand Down