Created
January 5, 2018 08:07
-
-
Save vialyx/812bbc5328cb324e9bcf76ffbe42f753 to your computer and use it in GitHub Desktop.
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
protocol LoginInteractorInput { | |
func doLogin(login: String, password: String) -> Bool | |
} | |
protocol LoginRouterInput { | |
func openMainScreen() | |
} | |
class LoginInteractor: LoginInteractorInput { | |
func doLogin(login: String, password: String) -> Bool { | |
// TODO: - Make Network Request | |
return true | |
} | |
} | |
class LoginRouter: LoginRouterInput { | |
func openMainScreen() { | |
// TODO: - Instantiate Main ViewController and show it | |
} | |
} | |
class LoginPresenter { | |
var interactor: LoginInteractorInput! | |
var router: LoginRouterInput! | |
init(interactor: LoginInteractorInput, router: LoginRouterInput) { | |
self.interactor = interactor | |
self.router = router | |
} | |
// MARK: - Logic | |
func login() { | |
let login = "login" | |
let password = "password" | |
guard login.isEmpty, password.isEmpty else { | |
return | |
} | |
if interactor.doLogin(login: login, password: password) { | |
router.openMainScreen() | |
} | |
} | |
} | |
let router = LoginRouter() | |
let interactor = LoginInteractor() | |
let presenter = LoginPresenter(interactor: interactor, router: router) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment