Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit ad95a7f

Browse files
committed
Added presentLabels extension to UIViewController
1 parent 1f854b7 commit ad95a7f

File tree

7 files changed

+50
-15
lines changed

7 files changed

+50
-15
lines changed

Classes/Issues/IssuesViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,8 @@ final class IssuesViewController: MessageViewController,
636636

637637
// MARK: IssueLabelsSectionControllerDelegate
638638

639-
func didTapLabel(owner: String, repo: String, label: String) {
640-
print("Label tapped! \(owner) \(repo) \(label)" )
639+
func didTapIssueLabel(owner: String, repo: String, label: String) {
640+
presentLabels(client: client, owner: owner, repo: repo, label: label)
641641
}
642642

643643
}

Classes/Issues/Labeled/IssueLabeledSectionController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class IssueLabeledSectionController: ListGenericSectionController<IssueLab
3838

3939
func didTap(cell: MarkdownStyledTextView, attribute: DetectedMarkdownAttribute) {
4040
guard case .label(let label) = attribute else { return }
41-
tapDelegate?.didTapLabel(owner: label.owner, repo: label.repo, label: label.label)
41+
tapDelegate?.didTapIssueLabel(owner: label.owner, repo: label.repo, label: label.label)
4242
}
4343

4444
}

Classes/Issues/Labels/IssueLabelsSectionController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import IGListKit
1111

1212

1313
protocol IssueLabelTapSectionControllerDelegate: class {
14-
func didTapLabel(owner: String, repo: String, label: String)
14+
func didTapIssueLabel(owner: String, repo: String, label: String)
1515
}
1616

1717
final class IssueLabelsSectionController: ListBindingSectionController<IssueLabelsModel>,
@@ -104,7 +104,7 @@ ListBindingSectionControllerSelectionDelegate {
104104

105105
func sectionController(_ sectionController: ListBindingSectionController<ListDiffable>, didSelectItemAt index: Int, viewModel: Any) {
106106
guard let viewModel = viewModel as? RepositoryLabel else { return }
107-
tapDelegate?.didTapLabel(owner: issue.owner, repo: issue.repo, label: viewModel.name)
107+
tapDelegate?.didTapIssueLabel(owner: issue.owner, repo: issue.repo, label: viewModel.name)
108108
}
109109

110110
}

Classes/Repository/RepositoryIssuesViewController.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ SearchBarSectionControllerDelegate {
2626
private let searchKey: ListDiffable = "searchKey" as ListDiffable
2727
private let debouncer = Debouncer()
2828
private var previousSearchString = "is:open "
29+
private var label: String?
2930

30-
init(client: GithubClient, owner: String, repo: String, type: RepositoryIssuesType) {
31+
init(client: GithubClient, owner: String, repo: String, type: RepositoryIssuesType, label: String? = nil) {
3132
self.owner = owner
3233
self.repo = repo
3334
self.client = RepositoryClient(githubClient: client, owner: owner, name: repo)
3435
self.type = type
36+
self.label = label
37+
if let label = label {
38+
previousSearchString += "label:\(label) "
39+
}
3540

3641
super.init(
3742
emptyErrorMessage: NSLocalizedString("Cannot load issues.", comment: "")
@@ -53,10 +58,13 @@ SearchBarSectionControllerDelegate {
5358
super.viewDidLoad()
5459

5560
makeBackBarItemEmpty()
56-
57-
// set the frame in -viewDidLoad is required when working with TabMan
58-
feed.collectionView.frame = view.bounds
59-
feed.collectionView.contentInsetAdjustmentBehavior = .never
61+
62+
let presentingInTabMan = label == nil
63+
if presentingInTabMan {
64+
// set the frame in -viewDidLoad is required when working with TabMan
65+
feed.collectionView.frame = view.bounds
66+
feed.collectionView.contentInsetAdjustmentBehavior = .never
67+
}
6068
}
6169

6270
// MARK: Overrides
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// UIViewController+PresentLabels.swift
3+
// Freetime
4+
//
5+
// Created by B_Litwin on 10/19/18.
6+
// Copyright © 2018 Ryan Nystrom. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import GitHubAPI
11+
12+
extension UIViewController {
13+
func presentLabels(client: GithubClient, owner: String, repo: String, label: String) {
14+
let repositoryIssuesViewController =
15+
RepositoryIssuesViewController(
16+
client: client,
17+
owner: owner,
18+
repo: repo,
19+
type: .issues,
20+
label: label
21+
)
22+
23+
navigationController?.pushViewController(
24+
repositoryIssuesViewController,
25+
animated: true
26+
)
27+
}
28+
}

Classes/View Controllers/UIViewController+Safari.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ extension UIViewController {
3030
presentSafari(url: url)
3131
}
3232

33-
func presentLabels(owner: String, repo: String, label: String) {
34-
guard let url = URL(string: "https://github.com/\(owner)/\(repo)/labels/\(label)") else { return }
35-
presentSafari(url: url)
36-
}
37-
3833
func presentMilestone(owner: String, repo: String, milestone: Int) {
3934
guard let url = URL(string: "https://github.com/\(owner)/\(repo)/milestone/\(milestone)") else { return }
4035
presentSafari(url: url)

Freetime.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@
449449
98F9F4011F9CCFFE005A0266 /* ImgurClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F9F3FE1F9CCFFE005A0266 /* ImgurClient.swift */; };
450450
98F9F4031F9CD006005A0266 /* Image+Base64.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F9F4021F9CD006005A0266 /* Image+Base64.swift */; };
451451
BD3761B0209E032500401DFB /* BookmarkNavigationItemTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD3761AF209E032500401DFB /* BookmarkNavigationItemTests.swift */; };
452+
BD67495C217A47BC00E8E4FD /* UIViewController+PresentLabels.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD67495B217A47BC00E8E4FD /* UIViewController+PresentLabels.swift */; };
452453
BD89007E20B8844B0026013F /* NetworkingURLPathTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD89007D20B8844B0026013F /* NetworkingURLPathTests.swift */; };
453454
BDB6AA66215FBC35009BB73C /* RepositoryBranchesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDB6AA5F215FBC35009BB73C /* RepositoryBranchesViewModel.swift */; };
454455
BDB6AA67215FBC35009BB73C /* RepositoryBranchUpdatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDB6AA60215FBC35009BB73C /* RepositoryBranchUpdatable.swift */; };
@@ -999,6 +1000,7 @@
9991000
ACAE4A11E9671879046F0CE7 /* Pods-FreetimeWatch.testflight.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FreetimeWatch.testflight.xcconfig"; path = "Pods/Target Support Files/Pods-FreetimeWatch/Pods-FreetimeWatch.testflight.xcconfig"; sourceTree = "<group>"; };
10001001
B3C439BE890EECD7C0C692C5 /* Pods-Freetime.testflight.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Freetime.testflight.xcconfig"; path = "Pods/Target Support Files/Pods-Freetime/Pods-Freetime.testflight.xcconfig"; sourceTree = "<group>"; };
10011002
BD3761AF209E032500401DFB /* BookmarkNavigationItemTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkNavigationItemTests.swift; sourceTree = "<group>"; };
1003+
BD67495B217A47BC00E8E4FD /* UIViewController+PresentLabels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+PresentLabels.swift"; sourceTree = "<group>"; };
10021004
BD89007D20B8844B0026013F /* NetworkingURLPathTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkingURLPathTests.swift; sourceTree = "<group>"; };
10031005
BDB6AA5F215FBC35009BB73C /* RepositoryBranchesViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepositoryBranchesViewModel.swift; sourceTree = "<group>"; };
10041006
BDB6AA60215FBC35009BB73C /* RepositoryBranchUpdatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepositoryBranchUpdatable.swift; sourceTree = "<group>"; };
@@ -1743,6 +1745,7 @@
17431745
290056F2210028B20046EAE5 /* UIViewController+MenuDone.swift */,
17441746
29792B181FFB10A3007A0C57 /* UIViewController+MessageAutocompleteControllerLayoutDelegate.swift */,
17451747
292CD3D11F0DBEC000D3D57B /* UIViewController+Safari.swift */,
1748+
BD67495B217A47BC00E8E4FD /* UIViewController+PresentLabels.swift */,
17461749
290D2A3C1F044CB20082E6CC /* UIViewController+SmartDeselection.swift */,
17471750
299F63E3205E1CAB0015D901 /* UIViewController+StyledTextViewCellDelegate.swift */,
17481751
4920F1A71F72E27200131E9D /* UIViewController+UserActivity.swift */,
@@ -2762,6 +2765,7 @@
27622765
29459A6F1FE61E0500034A04 /* MarkdownCheckboxModel.swift in Sources */,
27632766
299997302031227E00995FFD /* IssueMergeButtonModel.swift in Sources */,
27642767
29CEA5CD1F84DB1B009827DB /* BaseListViewController.swift in Sources */,
2768+
BD67495C217A47BC00E8E4FD /* UIViewController+PresentLabels.swift in Sources */,
27652769
299F63E0205DDF6B0015D901 /* UIViewController+Routing.swift in Sources */,
27662770
98835BD41F1A17EE005BA24F /* Bundle+Version.swift in Sources */,
27672771
29316DB51ECC7DEB007CAE3F /* ButtonCell.swift in Sources */,

0 commit comments

Comments
 (0)