TabView: Favicons in tab bar

This commit is contained in:
James Magahern
2021-02-15 19:21:48 -08:00
parent d62fa42f57
commit 41289bf790
4 changed files with 33 additions and 13 deletions

View File

@@ -60,8 +60,8 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
}()
public var identifier = UUID()
@Published public var favicon: UIImage?
public var favicon: UIImage?
private var faviconHost: String?
private var faviconRequest: AnyCancellable?

View File

@@ -37,6 +37,9 @@ class TabView: UIControl
leftSeparator.backgroundColor = .secondarySystemFill
rightSeparator.backgroundColor = .secondarySystemFill
imageView.contentMode = .scaleAspectFit
addSubview(imageView)
// Try just one for now
leftSeparator.isHidden = true
}
@@ -53,9 +56,16 @@ class TabView: UIControl
width: closeButtonSize.width, height: closeButtonSize.height
)
var xOffset = insetBounds.minX
imageView.frame = CGRect(
x: xOffset, y: insetBounds.minY,
width: insetBounds.height, height: insetBounds.height
)
xOffset += imageView.frame.width
label.frame = CGRect(
x: insetBounds.minX, y: insetBounds.minY,
width: closeButton.frame.minX - closeButtonPadding, height: insetBounds.height
x: xOffset + 12.0, y: insetBounds.minY,
width: closeButton.frame.minX - closeButtonPadding - xOffset, height: insetBounds.height
)
let separatorWidth = CGFloat(1.0)
@@ -127,6 +137,8 @@ class TabBarView: UIView
private let bottomSeparatorView = UIView(frame: .zero)
private let placeholderTabImage = UIImage(systemName: "network")
override func sizeThatFits(_ size: CGSize) -> CGSize {
CGSize(width: size.width, height: Self.preferredHeight)
}
@@ -201,8 +213,8 @@ class TabBarView: UIView
if let tabView = visibleTab(atIndex: index) {
tabView.label.text = title
tabView.imageView.image = image
tabView.identifier = identifier
tabView.imageView.image = image ?? placeholderTabImage
}
}