Last active
November 21, 2018 01:18
-
-
Save martinmroz/ff8a2c7f4a0dfa557a8cb9788ed65f38 to your computer and use it in GitHub Desktop.
Medium - Flow Controller Demo - Simple Flow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class RootFlow { | |
// MARK: - Private Properties | |
private let navigationController: UINavigationController | |
private var presented: Bool = false | |
// MARK: - Private Properties - View Controllers | |
private lazy var simpleViewController = SimpleViewController(delegate: self) | |
// MARK: - Initialization | |
public init(navigationController: UINavigationController) { | |
self.navigationController = navigationController | |
} | |
// MARK: - Public Methods | |
public func present(animated: Bool = false) { | |
precondition(self.presented == false) | |
self.navigationController.pushViewController(self.simpleViewController, animated: animated) | |
self.presented = true | |
} | |
} | |
// MARK: - SimpleViewControllerDelegate | |
extension RootFlow: SimpleViewControllerDelegate { | |
public func simpleViewControllerAction(_ viewController: SimpleViewController) { | |
/* Your Action Here: Push, Pop, Present, Dismiss, Make Network Requests */ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment