Autocomplete UI
This commit is contained in:
@@ -17,6 +17,10 @@ class BrowserView: UIView
|
||||
didSet { addSubview(toolbarView!) }
|
||||
}
|
||||
|
||||
var autocompleteView: UICollectionView? {
|
||||
didSet { addSubview(autocompleteView!) }
|
||||
}
|
||||
|
||||
var webView: WKWebView? {
|
||||
didSet {
|
||||
oldValue?.removeFromSuperview()
|
||||
@@ -104,5 +108,29 @@ class BrowserView: UIView
|
||||
webView.scrollView.layer.masksToBounds = false // allow content to draw under titlebar/toolbar
|
||||
webView.frame = bounds.inset(by: webViewContentInset)
|
||||
}
|
||||
|
||||
// Autocomplete view
|
||||
if let autocompleteView = autocompleteView {
|
||||
// Compact: autocomplete view takes the space of the webview
|
||||
autocompleteView.frame = bounds.inset(by: webViewContentInset)
|
||||
if traitCollection.horizontalSizeClass == .regular {
|
||||
// Regular: shows up just underneath the url bar
|
||||
autocompleteView.layer.shadowColor = UIColor.black.cgColor
|
||||
autocompleteView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
|
||||
autocompleteView.layer.shadowRadius = 3.0
|
||||
autocompleteView.layer.shadowOpacity = 0.8
|
||||
autocompleteView.layer.cornerRadius = 8.0
|
||||
|
||||
if let toolbarView = toolbarView, let urlBar = toolbarView.urlBar {
|
||||
let urlFrame = self.convert(urlBar.frame, from: urlBar.superview)
|
||||
autocompleteView.frame = CGRect(
|
||||
x: urlFrame.minX,
|
||||
y: toolbarView.frame.maxY + 3.0,
|
||||
width: urlFrame.width,
|
||||
height: bounds.height / 2.5
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user