AutocompleteViewController: adjust insets on keyboard appearance
This commit is contained in:
@@ -32,8 +32,6 @@ class AutocompleteViewController: UIViewController, UICollectionViewDelegate
|
|||||||
override var canBecomeFirstResponder: Bool { true }
|
override var canBecomeFirstResponder: Bool { true }
|
||||||
|
|
||||||
public let collectionView: UICollectionView
|
public let collectionView: UICollectionView
|
||||||
|
|
||||||
private let autocompleteView: AutocompleteView
|
|
||||||
private let dataSource: UICollectionViewDiffableDataSource<Section, HistoryItem>
|
private let dataSource: UICollectionViewDiffableDataSource<Section, HistoryItem>
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@@ -53,8 +51,6 @@ class AutocompleteViewController: UIViewController, UICollectionViewDelegate
|
|||||||
collectionView.dequeueConfiguredReusableCell(using: cellRegistry, for: indexPath, item: item)
|
collectionView.dequeueConfiguredReusableCell(using: cellRegistry, for: indexPath, item: item)
|
||||||
})
|
})
|
||||||
|
|
||||||
autocompleteView = AutocompleteView(collectionView: collectionView)
|
|
||||||
|
|
||||||
super.init(nibName: nil, bundle: nil)
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
|
||||||
collectionView.delegate = self
|
collectionView.delegate = self
|
||||||
@@ -64,7 +60,7 @@ class AutocompleteViewController: UIViewController, UICollectionViewDelegate
|
|||||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||||
|
|
||||||
override func loadView() {
|
override func loadView() {
|
||||||
self.view = autocompleteView
|
self.view = collectionView
|
||||||
}
|
}
|
||||||
|
|
||||||
override var keyCommands: [UIKeyCommand]? {
|
override var keyCommands: [UIKeyCommand]? {
|
||||||
@@ -123,24 +119,4 @@ class AutocompleteViewController: UIViewController, UICollectionViewDelegate
|
|||||||
delegate?.autocompleteController(self, didSelectHistoryItem: item)
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class BrowserView: UIView
|
|||||||
didSet { setNeedsLayout() }
|
didSet { setNeedsLayout() }
|
||||||
}
|
}
|
||||||
|
|
||||||
var autocompleteView: UIView? {
|
var autocompleteView: UICollectionView? {
|
||||||
didSet {
|
didSet {
|
||||||
addSubview(autocompleteView!)
|
addSubview(autocompleteView!)
|
||||||
if let toolbarView = toolbarView {
|
if let toolbarView = toolbarView {
|
||||||
@@ -170,6 +170,8 @@ class BrowserView: UIView
|
|||||||
if let autocompleteView = autocompleteView {
|
if let autocompleteView = autocompleteView {
|
||||||
// Compact: autocomplete view takes the space of the webview
|
// Compact: autocomplete view takes the space of the webview
|
||||||
autocompleteView.frame = bounds.inset(by: webViewContentInset)
|
autocompleteView.frame = bounds.inset(by: webViewContentInset)
|
||||||
|
autocompleteView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: keyboardLayoutOffset, right: 0)
|
||||||
|
autocompleteView.scrollIndicatorInsets = autocompleteView.contentInset
|
||||||
|
|
||||||
if traitCollection.horizontalSizeClass == .regular {
|
if traitCollection.horizontalSizeClass == .regular {
|
||||||
// Regular: shows up just underneath the url bar
|
// Regular: shows up just underneath the url bar
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ class BrowserViewController: UIViewController
|
|||||||
findOnPageController.webView = webView
|
findOnPageController.webView = webView
|
||||||
|
|
||||||
// Autocomplete view
|
// Autocomplete view
|
||||||
browserView.autocompleteView = autocompleteViewController.view
|
browserView.autocompleteView = autocompleteViewController.collectionView
|
||||||
|
|
||||||
// Color theme
|
// Color theme
|
||||||
browserView.titlebarView.setColorTheme(tab.colorTheme)
|
browserView.titlebarView.setColorTheme(tab.colorTheme)
|
||||||
|
|||||||
Reference in New Issue
Block a user