diff --git a/browser/ios/Plugin/Browser.swift b/browser/ios/Plugin/Browser.swift index 3f1d1ade3..9881c81d7 100644 --- a/browser/ios/Plugin/Browser.swift +++ b/browser/ios/Plugin/Browser.swift @@ -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 { diff --git a/browser/ios/Plugin/BrowserPlugin.swift b/browser/ios/Plugin/BrowserPlugin.swift index f6be40dd7..5594e4092 100644 --- a/browser/ios/Plugin/BrowserPlugin.swift +++ b/browser/ios/Plugin/BrowserPlugin.swift @@ -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 } diff --git a/browser/src/definitions.ts b/browser/src/definitions.ts index 6946e5e7f..2db3e2de5 100644 --- a/browser/src/definitions.ts +++ b/browser/src/definitions.ts @@ -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. *