diff --git a/DuckDuckGo/AutocompleteViewController.swift b/DuckDuckGo/AutocompleteViewController.swift index 57847a122f..fca5d61e34 100644 --- a/DuckDuckGo/AutocompleteViewController.swift +++ b/DuckDuckGo/AutocompleteViewController.swift @@ -150,16 +150,7 @@ class AutocompleteViewController: UIViewController { func willDismiss(with query: String) { guard selectedItem != -1, selectedItem < suggestions.count else { return } - - // TODO fire pixels -// let suggestion = suggestions[selectedItem] -// if let url = suggestion.url { -// if query == url.absoluteString { -// firePixel(selectedSuggestion: suggestion) -// } -// } else if query == suggestion.suggestion { -// firePixel(selectedSuggestion: suggestion) -// } + // TODO fire pixel } @IBAction func onPlusButtonPressed(_ button: UIButton) { @@ -268,31 +259,11 @@ extension AutocompleteViewController: UITableViewDataSource { return receivedResponse ? max(Constants.minItems, suggestions.count) : 0 } - // TODO fire pixel - private func firePixel(selectedSuggestion: Suggestion) { -// let resultsIncludeBookmarks: Bool -// if let firstSuggestion = suggestions.first { - // resultsIncludeBookmarks = firstSuggestion.source == .local -// } else { -// resultsIncludeBookmarks = false -// } - -// let params = [PixelParameters.autocompleteBookmarkCapable: bookmarksSearch.hasData ? "true" : "false", -// PixelParameters.autocompleteIncludedLocalResults: resultsIncludeBookmarks ? "true" : "false"] - -// if selectedSuggestion.source == .local { -// Pixel.fire(pixel: .autocompleteSelectedLocal, withAdditionalParameters: params) -// } else { -// Pixel.fire(pixel: .autocompleteSelectedRemote, withAdditionalParameters: params) -// } - - } } extension AutocompleteViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let suggestion = suggestions[indexPath.row] - firePixel(selectedSuggestion: suggestion) delegate?.autocomplete(selectedSuggestion: suggestion) } } diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index 20cb7c2141..5469fff501 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -565,16 +565,7 @@ class MainViewController: UIViewController { findInPageBottomLayoutConstraint.constant = height keyboardHeight = height - if let suggestionsTray = suggestionTrayController { - let suggestionsFrameInView = suggestionsTray.view.convert(suggestionsTray.contentFrame, to: view) - - let overflow = suggestionsFrameInView.size.height + suggestionsFrameInView.origin.y - keyboardFrameInView.origin.y + 10 - if overflow > 0 { - suggestionTrayController?.applyContentInset(UIEdgeInsets(top: 0, left: 0, bottom: overflow, right: 0)) - } else { - suggestionTrayController?.applyContentInset(.zero) - } - } + suggestionTrayController?.applyContentInset(.init(top: 0, left: 0, bottom: keyboardHeight, right: 0)) let y = self.view.frame.height - height let frame = self.findInPageView.frame diff --git a/DuckDuckGo/SuggestionTrayViewController.swift b/DuckDuckGo/SuggestionTrayViewController.swift index bd143d9363..a3eb1319b4 100644 --- a/DuckDuckGo/SuggestionTrayViewController.swift +++ b/DuckDuckGo/SuggestionTrayViewController.swift @@ -222,6 +222,7 @@ class SuggestionTrayViewController: UIViewController { let controller = FavoritesOverlay(viewModel: favoritesModel) controller.delegate = favoritesOverlayDelegate install(controller: controller, completion: onInstall) + controller.collectionView.contentInset = self.contentInsets favoritesOverlay = controller } @@ -243,6 +244,7 @@ class SuggestionTrayViewController: UIViewController { private func installAutocompleteSuggestions() { let controller = AutocompleteViewController.loadFromStoryboard(bookmarksDatabase: bookmarksDatabase, historyCoordinator: historyCoordinator) install(controller: controller) + controller.tableView.contentInset = contentInsets controller.delegate = autocompleteDelegate controller.presentationDelegate = self autocompleteController = controller @@ -275,9 +277,9 @@ class SuggestionTrayViewController: UIViewController { }) } + var contentInsets = UIEdgeInsets.zero func applyContentInset(_ inset: UIEdgeInsets) { - autocompleteController?.tableView.contentInset = inset - favoritesOverlay?.collectionView.contentInset = inset + self.contentInsets = inset } }