From bc4e2a94f62ab0d4bab24dc4ecb76d4cdd8a96ea Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Tue, 12 Mar 2024 20:35:32 +0000 Subject: [PATCH] use overflow for the keyboard height and don't show suggestions if there's an error --- DuckDuckGo/AutocompleteViewController.swift | 7 ++++++- DuckDuckGo/MainViewController.swift | 11 ++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo/AutocompleteViewController.swift b/DuckDuckGo/AutocompleteViewController.swift index fca5d61e34..cf31e84111 100644 --- a/DuckDuckGo/AutocompleteViewController.swift +++ b/DuckDuckGo/AutocompleteViewController.swift @@ -180,7 +180,12 @@ class AutocompleteViewController: UIViewController { }) pendingRequest = true - loader?.getSuggestions(query: query) { [weak self] result, _ in + loader?.getSuggestions(query: query) { [weak self] result, error in + guard error == nil else { + print("***", #function, String(describing: error)) + return + } + self?.updateSuggestions(result?.all ?? []) self?.pendingRequest = false } diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index 5469fff501..07a5cf0649 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -565,7 +565,16 @@ class MainViewController: UIViewController { findInPageBottomLayoutConstraint.constant = height keyboardHeight = height - suggestionTrayController?.applyContentInset(.init(top: 0, left: 0, bottom: keyboardHeight, right: 0)) + 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 { + suggestionsTray.applyContentInset(UIEdgeInsets(top: 0, left: 0, bottom: overflow, right: 0)) + } else { + suggestionsTray.applyContentInset(.zero) + } + } let y = self.view.frame.height - height let frame = self.findInPageView.frame