-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adds 2 views to represent Login and Register - Creates 2 coordinators, the AppCoordinator and AuthCoordinator - Creates 2 routers, one for Windows, and the other for NavigationControllers
- Loading branch information
1 parent
32471ea
commit 1b1216a
Showing
19 changed files
with
683 additions
and
144 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Xcode | ||
# | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
## User settings | ||
xcuserdata/ | ||
|
||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) | ||
*.xcscmblueprint | ||
*.xccheckout | ||
|
||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) | ||
build/ | ||
DerivedData/ | ||
*.moved-aside | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
|
||
## Obj-C/Swift specific | ||
*.hmap | ||
|
||
## App packaging | ||
*.ipa | ||
*.dSYM.zip | ||
*.dSYM | ||
|
||
## Playgrounds | ||
timeline.xctimeline | ||
playground.xcworkspace | ||
|
||
# Swift Package Manager | ||
# | ||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. | ||
# Packages/ | ||
# Package.pins | ||
# Package.resolved | ||
# *.xcodeproj | ||
# | ||
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata | ||
# hence it is not needed unless you have added a package configuration file to your project | ||
# .swiftpm | ||
|
||
.build/ | ||
|
||
# CocoaPods | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# | ||
# Pods/ | ||
# | ||
# Add this line if you want to avoid checking in source code from the Xcode workspace | ||
# *.xcworkspace | ||
|
||
# Carthage | ||
# | ||
# Add this line if you want to avoid checking in source code from Carthage dependencies. | ||
# Carthage/Checkouts | ||
|
||
Carthage/Build/ | ||
|
||
# Accio dependency management | ||
Dependencies/ | ||
.accio/ | ||
|
||
# fastlane | ||
# | ||
# It is recommended to not store the screenshots in the git repo. | ||
# Instead, use fastlane to re-generate the screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://docs.fastlane.tools/best-practices/source-control/#source-control | ||
|
||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots/**/*.png | ||
fastlane/test_output | ||
|
||
# Code Injection | ||
# | ||
# After new code Injection tools there's a generated folder /iOSInjectionProject | ||
# https://github.com/johnno1962/injectionforxcode | ||
|
||
iOSInjectionProject/ |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// AppCoordinator.swift | ||
// CoordinatorExample | ||
// | ||
// Created by Gustavo Vergara Garcia on 06/10/20. | ||
// Copyright © 2020 Gustavo Vergara. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class AppCoordinator: Coordinator { | ||
let router: Router | ||
let navigationController: NavigationController | ||
|
||
private let userIsLogged = false | ||
|
||
init( | ||
router: Router, | ||
navigationController: NavigationController = UINavigationController().eraseToNavigationController(), | ||
authFactory: AuthFactoryProtocol = AuthFactory() | ||
) { | ||
self.router = router | ||
self.navigationController = navigationController | ||
} | ||
|
||
func start(animated: Bool) { | ||
router.present(navigationController, animated: animated) | ||
|
||
let navigationRouter = NavigationRouter(navigationController: navigationController) | ||
if !userIsLogged { | ||
let loginController = AuthCoordinator(router: navigationRouter) | ||
loginController.start(animated: animated) | ||
} else { | ||
// ... | ||
} | ||
} | ||
|
||
func dismiss(animated: Bool) { | ||
router.dismiss(animated: animated) | ||
} | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// LoginCoordinator.swift | ||
// CoordinatorExample | ||
// | ||
// Created by Gustavo Vergara Garcia on 06/10/20. | ||
// Copyright © 2020 Gustavo Vergara. All rights reserved. | ||
// | ||
|
||
protocol AuthCoordinatorProtocol: Coordinator { | ||
func presentRegister() | ||
} | ||
|
||
class AuthCoordinator: AuthCoordinatorProtocol { | ||
|
||
let router: Router | ||
let authFactory: AuthFactoryProtocol | ||
|
||
init( | ||
router: Router, | ||
authFactory: AuthFactoryProtocol = AuthFactory() | ||
) { | ||
self.router = router | ||
self.authFactory = authFactory | ||
} | ||
|
||
// MARK: - Coordinator Conformance | ||
func start(animated: Bool) { | ||
let loginVC = authFactory.makeLoginViewController(coordinator: self) | ||
router.present(loginVC, animated: animated) | ||
} | ||
|
||
func dismiss(animated: Bool) { | ||
router.dismiss(animated: animated) | ||
} | ||
|
||
// MARK: - LoginCoordinatorProtocol Conformance | ||
func presentRegister() { | ||
let register = authFactory.makeRegisterViewController(coordinator: self) | ||
router.present(register, animated: true) | ||
} | ||
|
||
} |
Oops, something went wrong.