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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user