Tab Bar: Adds tab bar view/view controller
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user