Created
August 15, 2020 16:18
-
-
Save cipolleschi/f57d2b6f6c675cb80583f7f1625ef3f9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Entry point of the app | |
| func scene( | |
| _ scene: UIScene, | |
| willConnectTo session: UISceneSession, | |
| options connectionOptions: UIScene.ConnectionOptions | |
| ) { | |
| // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. | |
| // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. | |
| // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). | |
| guard let scene = (scene as? UIWindowScene) else { return } | |
| self.dependencies = buildDependencies() | |
| let vc = buildViewController() | |
| let window = UIWindow(windowScene: scene) | |
| window.rootViewController = vc | |
| window.makeKeyAndVisible() | |
| self.window = window | |
| } | |
| func buildViewController() -> UIViewController { | |
| //chek for UI testing | |
| #if UITESTING | |
| return self.vcForUITesting() | |
| #endif | |
| return LegalViewController(dependencies: self.dependencies) | |
| } | |
| func vcForUITesting() -> UIViewController { | |
| // extract the state | |
| let user: Models.User? = self.extractState() | |
| // route the app to the proper vc | |
| let initialScreen = UserDefaults.standard.string(forKey: Arguments.initialScreen.rawValue) | |
| if initialScreen == "home_screen" { | |
| // inject the user | |
| return HomeViewController(user: user, dependencies: self.dependencies) | |
| } | |
| return LegalViewController(dependencies: Dependencies()) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment