Files
GitHawk/Classes/View Controllers/SplitViewControllerDelegate.swift
Shaps Benkau 6eb0991768 Introduced FeedSelectionProviding to indicate when a selection has been made
Updated IssuesViewController and NotificationsViewController to conform to FeedSelectionProviding
Updated NotificationsViewController to show the placeholder when toggling the filter
Updated the SplitViewDelegate to depend on the current selection rather than a placeholder view
2017-07-23 14:55:20 +01:00

37 lines
1.1 KiB
Swift

//
// SplitViewControllerDelegate.swift
// Freetime
//
// Created by Ryan Nystrom on 6/25/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import UIKit
final class SplitViewControllerDelegate: UISplitViewControllerDelegate {
private func containsSelection(in primaryViewController: UIViewController) -> Bool {
guard let nav = primaryViewController as? UINavigationController else { return false }
if let provider = nav.topViewController as? FeedSelectionProviding {
return provider.feedContainsSelection
}
if let nav = nav.topViewController as? UINavigationController,
let provider = nav.topViewController as? FeedSelectionProviding {
return provider.feedContainsSelection
}
return false
}
func splitViewController(
_ splitViewController: UISplitViewController,
collapseSecondary secondaryViewController: UIViewController,
onto primaryViewController: UIViewController
) -> Bool {
return !containsSelection(in: primaryViewController)
}
}