Tab Bar: Adds tab bar view/view controller

This commit is contained in:
James Magahern
2020-10-28 17:57:34 -07:00
parent af296d7430
commit 5e9c6e5880
7 changed files with 390 additions and 7 deletions

View File

@@ -21,6 +21,14 @@ class BrowserView: UIView
didSet { addSubview(toolbarView!) }
}
var tabBarView: TabBarView? {
didSet { addSubview(tabBarView!) }
}
var tabBarViewVisible: Bool = true {
didSet { setNeedsLayout() }
}
var autocompleteView: UIView? {
didSet {
addSubview(autocompleteView!)
@@ -129,6 +137,25 @@ class BrowserView: UIView
}
}
if let tabBarView = tabBarView {
bringSubviewToFront(tabBarView)
if tabBarViewVisible {
tabBarView.isHidden = false
let tabViewSize = tabBarView.sizeThatFits(bounds.size)
tabBarView.frame = CGRect(
x: 0.0, y: webViewContentInset.top,
width: bounds.width, height: tabViewSize.height
)
webViewContentInset.top += tabBarView.frame.height
} else {
tabBarView.isHidden = true
}
}
// Fix web view content insets
if let webView = webView {
webView.scrollView.layer.masksToBounds = true
@@ -154,10 +181,15 @@ class BrowserView: UIView
autocompleteView.layer.shadowPath = shadowPath.cgPath
if let toolbarView = toolbarView, let urlBar = toolbarView.urlBar {
var yOffset = toolbarView.frame.maxY + 3.0
if let tabBarView = tabBarView, tabBarViewVisible {
yOffset += tabBarView.frame.height
}
let urlFrame = self.convert(urlBar.frame, from: urlBar.superview)
autocompleteView.frame = CGRect(
x: urlFrame.minX,
y: toolbarView.frame.maxY + 3.0,
y: yOffset,
width: urlFrame.width,
height: bounds.height / 2.5
)