resign search bar when tapping search results, fixes #445

This commit is contained in:
Ryan Nystrom
2017-09-27 21:48:16 -04:00
parent 582e3e224f
commit 42c679e1ec
2 changed files with 19 additions and 3 deletions

View File

@@ -8,12 +8,18 @@
import IGListKit
protocol SearchResultSectionControllerDelegate: class {
func didSelect(sectionController: SearchResultSectionController)
}
final class SearchResultSectionController: ListGenericSectionController<SearchRepoResult> {
private weak var delegate: SearchResultSectionControllerDelegate? = nil
private let client: GithubClient
init(client: GithubClient) {
init(client: GithubClient, delegate: SearchResultSectionControllerDelegate) {
self.client = client
self.delegate = delegate
super.init()
}
@@ -34,6 +40,9 @@ final class SearchResultSectionController: ListGenericSectionController<SearchRe
override func didSelectItem(at index: Int) {
guard let object = object else { return }
delegate?.didSelect(sectionController: self)
let repo = RepositoryDetails(owner: object.owner, name: object.name, hasIssuesEnabled: object.hasIssuesEnabled)
let repoViewController = RepositoryViewController(client: client, repo: repo)
let navigation = UINavigationController(rootViewController: repoViewController)

View File

@@ -16,7 +16,8 @@ class SearchViewController: UIViewController,
SearchEmptyViewDelegate,
SearchRecentSectionControllerDelegate,
SearchRecentHeaderSectionControllerDelegate,
TabNavRootViewControllerType {
TabNavRootViewControllerType,
SearchResultSectionControllerDelegate {
private let client: GithubClient
private let noResultsKey = "com.freetime.SearchViewController.no-results-key" as ListDiffable
@@ -136,7 +137,7 @@ TabNavRootViewControllerType {
} else if object === recentHeaderKey {
return SearchRecentHeaderSectionController(delegate: self)
} else if object is SearchRepoResult {
return SearchResultSectionController(client: client)
return SearchResultSectionController(client: client, delegate: self)
} else if object is String {
return SearchRecentSectionController(delegate: self)
}
@@ -223,5 +224,11 @@ TabNavRootViewControllerType {
func didDoubleTapTab() {
searchBar.becomeFirstResponder()
}
// MARK: SearchResultSectionControllerDelegate
func didSelect(sectionController: SearchResultSectionController) {
searchBar.resignFirstResponder()
}
}