Autocomplete: tweaks to view hierarchy
This commit is contained in:
@@ -30,6 +30,8 @@ class AutocompleteViewController: UIViewController, UICollectionViewDelegate
|
||||
}
|
||||
|
||||
public let collectionView: UICollectionView
|
||||
|
||||
private let autocompleteView: AutocompleteView
|
||||
private let dataSource: UICollectionViewDiffableDataSource<Section, HistoryItem>
|
||||
|
||||
init() {
|
||||
@@ -49,6 +51,8 @@ class AutocompleteViewController: UIViewController, UICollectionViewDelegate
|
||||
collectionView.dequeueConfiguredReusableCell(using: cellRegistry, for: indexPath, item: item)
|
||||
})
|
||||
|
||||
autocompleteView = AutocompleteView(collectionView: collectionView)
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
collectionView.delegate = self
|
||||
@@ -58,7 +62,7 @@ class AutocompleteViewController: UIViewController, UICollectionViewDelegate
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
|
||||
override func loadView() {
|
||||
self.view = collectionView
|
||||
self.view = autocompleteView
|
||||
}
|
||||
|
||||
// MARK: UICollectionViewDelegate
|
||||
@@ -70,4 +74,24 @@ class AutocompleteViewController: UIViewController, UICollectionViewDelegate
|
||||
delegate?.autocompleteController(self, didSelectHistoryItem: item)
|
||||
}
|
||||
}
|
||||
|
||||
private class AutocompleteView: UIView {
|
||||
let collectionView: UICollectionView
|
||||
|
||||
init(collectionView: UICollectionView) {
|
||||
self.collectionView = collectionView
|
||||
super.init(frame: .zero)
|
||||
|
||||
addSubview(collectionView)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
collectionView.frame = bounds
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class BrowserView: UIView
|
||||
didSet { addSubview(toolbarView!) }
|
||||
}
|
||||
|
||||
var autocompleteView: UICollectionView? {
|
||||
var autocompleteView: UIView? {
|
||||
didSet {
|
||||
addSubview(autocompleteView!)
|
||||
if let toolbarView = toolbarView {
|
||||
@@ -118,13 +118,15 @@ class BrowserView: UIView
|
||||
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.shadowRadius = 8.0
|
||||
autocompleteView.layer.shadowOpacity = 0.6
|
||||
autocompleteView.layer.cornerRadius = 8.0
|
||||
autocompleteView.layer.masksToBounds = true
|
||||
|
||||
if let toolbarView = toolbarView, let urlBar = toolbarView.urlBar {
|
||||
let urlFrame = self.convert(urlBar.frame, from: urlBar.superview)
|
||||
|
||||
@@ -208,7 +208,7 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
browserView.webView = webView
|
||||
|
||||
// Autocomplete view
|
||||
browserView.autocompleteView = autocompleteViewController.collectionView
|
||||
browserView.autocompleteView = autocompleteViewController.view
|
||||
|
||||
// Load progress
|
||||
updateLoadProgress(forWebView: webView)
|
||||
|
||||
Reference in New Issue
Block a user