Fun: Make each tab have its own color theme
This commit is contained in:
@@ -308,6 +308,9 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
|||||||
// Show tab bar view?
|
// Show tab bar view?
|
||||||
browserView.tabBarViewVisible = tabController.tabs.count > 1
|
browserView.tabBarViewVisible = tabController.tabs.count > 1
|
||||||
|
|
||||||
|
// Color theme
|
||||||
|
browserView.titlebarView.setColorTheme(tab.colorTheme)
|
||||||
|
|
||||||
// Load progress
|
// Load progress
|
||||||
updateLoadProgress(forWebView: webView)
|
updateLoadProgress(forWebView: webView)
|
||||||
loadingObservation = webView.observe(\.estimatedProgress) { [unowned self] (webView, observedChange) in
|
loadingObservation = webView.observe(\.estimatedProgress) { [unowned self] (webView, observedChange) in
|
||||||
|
|||||||
@@ -40,6 +40,25 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
|
|||||||
didSet { bridge.allowAllScripts = javaScriptEnabled }
|
didSet { bridge.allowAllScripts = javaScriptEnabled }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public lazy var colorTheme: [UIColor] = {
|
||||||
|
// Looks really cool as-is, but maybe compute a color based on the
|
||||||
|
// title or URL to make it show up the same for each website?
|
||||||
|
return [
|
||||||
|
UIColor(
|
||||||
|
hue: CGFloat.random(in: 0...1.0),
|
||||||
|
saturation: 0.89,
|
||||||
|
brightness: 0.3,
|
||||||
|
alpha: 1.0
|
||||||
|
),
|
||||||
|
UIColor(
|
||||||
|
hue: CGFloat.random(in: 0...1.0),
|
||||||
|
saturation: 1.0,
|
||||||
|
brightness: 0.7,
|
||||||
|
alpha: 1.0
|
||||||
|
),
|
||||||
|
]
|
||||||
|
}()
|
||||||
|
|
||||||
public var identifier = UUID()
|
public var identifier = UUID()
|
||||||
|
|
||||||
public var favicon: UIImage?
|
public var favicon: UIImage?
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ class TitlebarView: UIView
|
|||||||
titleLabelView.attributedText = NSAttributedString(string: appName, attributes: titleAttributes)
|
titleLabelView.attributedText = NSAttributedString(string: appName, attributes: titleAttributes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setColorTheme(_ colorTheme: [UIColor]) {
|
||||||
|
backgroundView.colors = colorTheme
|
||||||
|
}
|
||||||
|
|
||||||
override func layoutSubviews() {
|
override func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
|
|||||||
Reference in New Issue
Block a user