-
Notifications
You must be signed in to change notification settings - Fork 382
Search for labels in app (take two) #2314
Changes from all commits
770d472
1f854b7
ad95a7f
37a311b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,12 +9,16 @@ | |
import Foundation | ||
import IGListKit | ||
|
||
final class IssueLabeledSectionController: ListGenericSectionController<IssueLabeledModel> { | ||
|
||
|
||
final class IssueLabeledSectionController: ListGenericSectionController<IssueLabeledModel>, MarkdownStyledTextViewDelegate { | ||
|
||
private let issueModel: IssueDetailsModel | ||
private weak var tapDelegate: IssueLabelTapSectionControllerDelegate? | ||
|
||
init(issueModel: IssueDetailsModel) { | ||
init(issueModel: IssueDetailsModel, tapDelegate: IssueLabelTapSectionControllerDelegate) { | ||
self.issueModel = issueModel | ||
self.tapDelegate = tapDelegate | ||
super.init() | ||
} | ||
|
||
|
@@ -28,8 +32,16 @@ final class IssueLabeledSectionController: ListGenericSectionController<IssueLab | |
let object = self.object | ||
else { fatalError("Missing collection context, cell incorrect type, or object missing") } | ||
cell.configure(object) | ||
cell.delegate = viewController | ||
cell.delegate = self | ||
return cell | ||
} | ||
|
||
|
||
func didTap(cell: MarkdownStyledTextView, attribute: DetectedMarkdownAttribute) { | ||
if case .label(let label) = attribute { | ||
tapDelegate?.didTapIssueLabel(owner: label.owner, repo: label.repo, label: label.label) | ||
} else { | ||
viewController?.handle(attribute: attribute) | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this break showing the profile when tapping on the username in the labeled cell? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it does break tapping on the name- updated to: if case .label(let label) = attribute {
tapDelegate?.didTapIssueLabel(owner: label.owner, repo: label.repo, label: label.label)
} else {
viewController?.handle(attribute: attribute)
} |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,17 +19,24 @@ BaseListViewControllerDataSource, | |
SearchBarSectionControllerDelegate { | ||
|
||
private var models = [ListDiffable]() | ||
private let repo: RepositoryDetails | ||
private let owner: String | ||
private let repo: String | ||
private let client: RepositoryClient | ||
private let type: RepositoryIssuesType | ||
private let searchKey: ListDiffable = "searchKey" as ListDiffable | ||
private let debouncer = Debouncer() | ||
private var previousSearchString = "is:open " | ||
private var label: String? | ||
|
||
init(client: GithubClient, repo: RepositoryDetails, type: RepositoryIssuesType) { | ||
init(client: GithubClient, owner: String, repo: String, type: RepositoryIssuesType, label: String? = nil) { | ||
self.owner = owner | ||
self.repo = repo | ||
self.client = RepositoryClient(githubClient: client, owner: repo.owner, name: repo.name) | ||
self.client = RepositoryClient(githubClient: client, owner: owner, name: repo) | ||
self.type = type | ||
self.label = label | ||
if let label = label { | ||
previousSearchString += "label:\(label) " | ||
} | ||
|
||
super.init( | ||
emptyErrorMessage: NSLocalizedString("Cannot load issues.", comment: "") | ||
|
@@ -51,10 +58,13 @@ SearchBarSectionControllerDelegate { | |
super.viewDidLoad() | ||
|
||
makeBackBarItemEmpty() | ||
|
||
// set the frame in -viewDidLoad is required when working with TabMan | ||
feed.collectionView.frame = view.bounds | ||
feed.collectionView.contentInsetAdjustmentBehavior = .never | ||
|
||
let presentingInTabMan = label == nil | ||
if presentingInTabMan { | ||
// set the frame in -viewDidLoad is required when working with TabMan | ||
feed.collectionView.frame = view.bounds | ||
feed.collectionView.contentInsetAdjustmentBehavior = .never | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When presenting the view controller outside of TabMan, the top part of the view controller was hiding under the nav bar and preventing those settings from being activated resolved it. |
||
} | ||
|
||
// MARK: Overrides | ||
|
@@ -105,7 +115,7 @@ SearchBarSectionControllerDelegate { | |
query: previousSearchString | ||
) | ||
} | ||
return RepositorySummarySectionController(client: client.githubClient, repo: repo) | ||
return RepositorySummarySectionController(client: client.githubClient, owner: owner, repo: repo) | ||
} | ||
|
||
func emptySectionController(listAdapter: ListAdapter) -> ListSectionController { | ||
|
@@ -129,7 +139,7 @@ SearchBarSectionControllerDelegate { | |
case .issues: typeQuery = "is:issue" | ||
case .pullRequests: typeQuery = "is:pr" | ||
} | ||
return "repo:\(repo.owner)/\(repo.name) \(typeQuery) \(previousSearchString)" | ||
return "repo:\(owner)/\(repo) \(typeQuery) \(previousSearchString)" | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// UIViewController+PresentLabels.swift | ||
// Freetime | ||
// | ||
// Created by B_Litwin on 10/19/18. | ||
// Copyright © 2018 Ryan Nystrom. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import GitHubAPI | ||
|
||
extension UIViewController { | ||
func presentLabels(client: GithubClient, owner: String, repo: String, label: String) { | ||
let repositoryIssuesViewController = | ||
RepositoryIssuesViewController( | ||
client: client, | ||
owner: owner, | ||
repo: repo, | ||
type: .issues, | ||
label: label | ||
) | ||
|
||
navigationController?.pushViewController( | ||
repositoryIssuesViewController, | ||
animated: true | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically should be set before init, but getting away w/ it since its
weak