Skip to content

Commit

Permalink
use overflow for the keyboard height and don't show suggestions if th…
Browse files Browse the repository at this point in the history
…ere's an error
  • Loading branch information
brindy committed Mar 12, 2024
1 parent fd64707 commit bc4e2a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion DuckDuckGo/AutocompleteViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 10 additions & 1 deletion DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bc4e2a9

Please sign in to comment.