Skip to content

Commit ac30176

Browse files
committed
Implemented navigation in featured tab
1 parent b14b2c5 commit ac30176

File tree

5 files changed

+59
-10
lines changed

5 files changed

+59
-10
lines changed

WWDC.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
DD6E06F61EDBC379000EAEA4 /* WWDCBottomBorderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6E06F51EDBC379000EAEA4 /* WWDCBottomBorderView.swift */; };
100100
DD6E06F81EDBC62D000EAEA4 /* TranscriptTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6E06F71EDBC62D000EAEA4 /* TranscriptTableViewController.swift */; };
101101
DD6E06FC1EDBCA7E000EAEA4 /* TranscriptTableCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6E06FB1EDBCA7E000EAEA4 /* TranscriptTableCellView.swift */; };
102+
DD71CC2A20BD009500BB5F47 /* AppCoordinator+Featured.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD71CC2920BD009500BB5F47 /* AppCoordinator+Featured.swift */; };
102103
DD7F385D1EABD449002D8C00 /* SyncEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD7F385C1EABD449002D8C00 /* SyncEngine.swift */; };
103104
DD7F385F1EABD631002D8C00 /* WWDCTabViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD7F385E1EABD631002D8C00 /* WWDCTabViewController.swift */; };
104105
DD7F38621EABD6CF002D8C00 /* SessionsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD7F38611EABD6CF002D8C00 /* SessionsTableViewController.swift */; };
@@ -470,6 +471,7 @@
470471
DD6E06F51EDBC379000EAEA4 /* WWDCBottomBorderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WWDCBottomBorderView.swift; sourceTree = "<group>"; };
471472
DD6E06F71EDBC62D000EAEA4 /* TranscriptTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TranscriptTableViewController.swift; sourceTree = "<group>"; };
472473
DD6E06FB1EDBCA7E000EAEA4 /* TranscriptTableCellView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TranscriptTableCellView.swift; sourceTree = "<group>"; };
474+
DD71CC2920BD009500BB5F47 /* AppCoordinator+Featured.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppCoordinator+Featured.swift"; sourceTree = "<group>"; };
473475
DD7F385C1EABD449002D8C00 /* SyncEngine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SyncEngine.swift; sourceTree = "<group>"; };
474476
DD7F385E1EABD631002D8C00 /* WWDCTabViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WWDCTabViewController.swift; sourceTree = "<group>"; };
475477
DD7F38611EABD6CF002D8C00 /* SessionsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SessionsTableViewController.swift; sourceTree = "<group>"; };
@@ -819,6 +821,7 @@
819821
DDF32EB61EBE65930028E39D /* AppCoordinator+UserActivity.swift */,
820822
DDF32EBA1EBE65DD0028E39D /* AppCoordinator+SessionActions.swift */,
821823
DD4873D220AE5FF3005033CE /* AppCoordinator+RelatedSessions.swift */,
824+
DD71CC2920BD009500BB5F47 /* AppCoordinator+Featured.swift */,
822825
DDFA10BE1EBEAAAD001DCF66 /* DownloadManager.swift */,
823826
DD0159FB1ED23F7700F980F1 /* RemoteEnvironment.swift */,
824827
DDB3529D1EC8D8CD00254815 /* main.m */,
@@ -1965,6 +1968,7 @@
19651968
DD7F38651EABD6DF002D8C00 /* SessionDetailsViewController.swift in Sources */,
19661969
DD34A79B1EC3CD5900E0B575 /* Constants.swift in Sources */,
19671970
DD90CDCD1ED7A5ED00CADE86 /* SearchCoordinator.swift in Sources */,
1971+
DD71CC2A20BD009500BB5F47 /* AppCoordinator+Featured.swift in Sources */,
19681972
DD9301C01EE3212D00BE724B /* ChromeCastPlaybackProvider.swift in Sources */,
19691973
DDB28F6F1EACFCDB0077703F /* VibrantButton.swift in Sources */,
19701974
DD0159FC1ED23F7700F980F1 /* RemoteEnvironment.swift in Sources */,

WWDC/AppCoordinator+Featured.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// AppCoordinator+Featured.swift
3+
// WWDC
4+
//
5+
// Created by Guilherme Rambo on 29/05/18.
6+
// Copyright © 2018 Guilherme Rambo. All rights reserved.
7+
//
8+
9+
import Cocoa
10+
import ConfCore
11+
12+
extension AppCoordinator: FeaturedContentViewControllerDelegate {
13+
14+
func featuredContentViewController(_ controller: FeaturedContentViewController, didSelectContent content: FeaturedContentViewModel) {
15+
guard let sessionViewModel = content.sessionViewModel else { return }
16+
17+
selectSessionOnAppropriateTab(with: sessionViewModel)
18+
}
19+
20+
}

WWDC/AppCoordinator+RelatedSessions.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,10 @@
77
//
88

99
import Cocoa
10+
import ConfCore
1011

1112
extension AppCoordinator: RelatedSessionsViewControllerDelegate {
1213

13-
func selectSessionOnAppropriateTab(with viewModel: SessionViewModel) {
14-
if ![.video, .session].contains(viewModel.sessionInstance.type) {
15-
// If the related session selected is not a video or regular session, we must be
16-
// on the schedule tab to show it, since the videos tab only shows videos
17-
tabController.activeTab = .schedule
18-
}
19-
20-
currentListController?.selectSession(with: viewModel.identifier)
21-
}
22-
2314
func relatedSessionsViewController(_ controller: RelatedSessionsViewController, didSelectSession viewModel: SessionViewModel) {
2415
selectSessionOnAppropriateTab(with: viewModel)
2516
}

WWDC/AppCoordinator.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,22 @@ final class AppCoordinator {
199199
updateCurrentActivity(with: selectedViewModelRegardlessOfTab)
200200
}
201201

202+
func switchToAppropriateTab(for instance: SessionInstance) {
203+
if ![.video, .session].contains(instance.type) {
204+
// If the session instace is not a video or regular session, we must be
205+
// on the schedule tab to show it, since the videos tab only shows videos
206+
tabController.activeTab = .schedule
207+
} else {
208+
tabController.activeTab = .videos
209+
}
210+
}
211+
212+
func selectSessionOnAppropriateTab(with viewModel: SessionViewModel) {
213+
switchToAppropriateTab(for: viewModel.sessionInstance)
214+
215+
currentListController?.selectSession(with: viewModel.identifier)
216+
}
217+
202218
private func setupDelegation() {
203219
let videoDetail = videosController.detailViewController
204220

@@ -214,6 +230,8 @@ final class AppCoordinator {
214230

215231
videosController.listViewController.delegate = self
216232
scheduleController.listViewController.delegate = self
233+
234+
featuredController.delegate = self
217235
}
218236

219237
private func updateListsAfterSync(migrate: Bool = false) {

WWDC/FeaturedContentViewController.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ import RealmSwift
1111
import RxSwift
1212
import RxCocoa
1313

14+
protocol FeaturedContentViewControllerDelegate: class {
15+
func featuredContentViewController(_ controller: FeaturedContentViewController, didSelectContent content: FeaturedContentViewModel)
16+
}
17+
1418
final class FeaturedContentViewController: NSViewController {
1519

20+
weak var delegate: FeaturedContentViewControllerDelegate?
21+
1622
convenience init() {
1723
self.init(nibName: nil, bundle: nil)
1824
}
@@ -81,6 +87,8 @@ final class FeaturedContentViewController: NSViewController {
8187
sectionControllers.removeAll()
8288

8389
sections.map({ FeaturedSectionViewController(viewModel: $0) }).forEach { sectionController in
90+
sectionController.delegate = self
91+
8492
addChildViewController(sectionController)
8593
sectionControllers.append(sectionController)
8694
sectionController.view.heightAnchor.constraint(equalToConstant: FeaturedSectionViewController.Metrics.height).isActive = true
@@ -89,3 +97,11 @@ final class FeaturedContentViewController: NSViewController {
8997
}
9098

9199
}
100+
101+
extension FeaturedContentViewController: FeaturedSectionViewControllerDelegate {
102+
103+
func featuredSectionViewController(_ controller: FeaturedSectionViewController, didSelectContent viewModel: FeaturedContentViewModel) {
104+
delegate?.featuredContentViewController(self, didSelectContent: viewModel)
105+
}
106+
107+
}

0 commit comments

Comments
 (0)