mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-06-03 19:43:10 +08:00
resign search bar when tapping search results, fixes #445
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user