Skip to content

Commit

Permalink
Add support for forwarding container view controller methods
Browse files Browse the repository at this point in the history
  • Loading branch information
davidask committed Aug 24, 2018
1 parent 134afbb commit a74923b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 0 additions & 2 deletions Framework/StateViewController.h
Expand Up @@ -5,5 +5,3 @@ FOUNDATION_EXPORT double StateViewControllerVersionNumber;

//! Project version string for StateViewController.
FOUNDATION_EXPORT const unsigned char StateViewControllerVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <StateViewController/PublicHeader.h>
29 changes: 29 additions & 0 deletions Sources/StateViewController.swift
Expand Up @@ -249,6 +249,26 @@ open class StateViewController<State: Equatable>: UIViewController {
endStateTransitionIfNeeded(animated: animated)
}

// MARK: - Container view controller forwarding

open override var childViewControllerForStatusBarStyle: UIViewController? {
return childViewControllers.last
}

open override var childViewControllerForStatusBarHidden: UIViewController? {
return childViewControllers.last
}

@available(iOS 11, *)
open override func childViewControllerForScreenEdgesDeferringSystemGestures() -> UIViewController? {
return childViewControllers.last
}

@available(iOS 11, *)
open override func childViewControllerForHomeIndicatorAutoHidden() -> UIViewController? {
return childViewControllers.last
}

// MARK: - State transitioning

/// Indicates whether the view controller currently is transitioning between states.
Expand Down Expand Up @@ -530,6 +550,15 @@ fileprivate extension StateViewController {
addContentViewController(viewController, animated: animated)
}

if adding.isEmpty == false || removing.isEmpty == false {
setNeedsStatusBarAppearanceUpdate()

if #available(iOS 11, *) {
setNeedsUpdateOfHomeIndicatorAutoHidden()
setNeedsUpdateOfScreenEdgesDeferringSystemGestures()
}
}

// Update the hierarchy of the view controllers that will represent the state being transitioned to.
updateHierarchy(of: next)
return true
Expand Down

0 comments on commit a74923b

Please sign in to comment.