-
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.
Merge pull request #1 from JK0369/feature/LoggedOut_RIB
Feature/logged out rib
- Loading branch information
Showing
12 changed files
with
286 additions
and
5 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
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
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,39 @@ | ||
// | ||
// LoggedOutBuilder.swift | ||
// TodoList | ||
// | ||
// Created by 김종권 on 2021/04/28. | ||
// | ||
|
||
import RIBs | ||
|
||
protocol LoggedOutDependency: Dependency { | ||
// TODO: Declare the set of dependencies required by this RIB, but cannot be | ||
// created by this RIB. | ||
} | ||
|
||
final class LoggedOutComponent: Component<LoggedOutDependency> { | ||
|
||
// TODO: Declare 'fileprivate' dependencies that are only used by this RIB. | ||
} | ||
|
||
// MARK: - Builder | ||
|
||
protocol LoggedOutBuildable: Buildable { | ||
func build(withListener listener: LoggedOutListener) -> LoggedOutRouting | ||
} | ||
|
||
final class LoggedOutBuilder: Builder<LoggedOutDependency>, LoggedOutBuildable { | ||
|
||
override init(dependency: LoggedOutDependency) { | ||
super.init(dependency: dependency) | ||
} | ||
|
||
func build(withListener listener: LoggedOutListener) -> LoggedOutRouting { | ||
let component = LoggedOutComponent(dependency: dependency) | ||
let viewController = LoggedOutViewController() | ||
let interactor = LoggedOutInteractor(presenter: viewController) | ||
interactor.listener = listener | ||
return LoggedOutRouter(interactor: interactor, viewController: viewController) | ||
} | ||
} |
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,51 @@ | ||
// | ||
// LoggedOutInteractor.swift | ||
// TodoList | ||
// | ||
// Created by 김종권 on 2021/04/28. | ||
// | ||
|
||
import RIBs | ||
import RxSwift | ||
|
||
protocol LoggedOutRouting: ViewableRouting { | ||
// TODO: Declare methods the interactor can invoke to manage sub-tree via the router. | ||
} | ||
|
||
protocol LoggedOutPresentable: Presentable { | ||
var listener: LoggedOutPresentableListener? { get set } | ||
// TODO: Declare methods the interactor can invoke the presenter to present data. | ||
} | ||
|
||
protocol LoggedOutListener: AnyObject { | ||
func didLogin(withEmail: String?, _ password: String?) | ||
} | ||
|
||
final class LoggedOutInteractor: PresentableInteractor<LoggedOutPresentable>, LoggedOutInteractable, LoggedOutPresentableListener { | ||
|
||
weak var router: LoggedOutRouting? | ||
weak var listener: LoggedOutListener? | ||
|
||
// TODO: Add additional dependencies to constructor. Do not perform any logic | ||
// in constructor. | ||
override init(presenter: LoggedOutPresentable) { | ||
super.init(presenter: presenter) | ||
presenter.listener = self | ||
} | ||
|
||
override func didBecomeActive() { | ||
super.didBecomeActive() | ||
// TODO: Implement business logic here. | ||
} | ||
|
||
override func willResignActive() { | ||
super.willResignActive() | ||
// TODO: Pause any business logic. | ||
} | ||
|
||
// MARK: - LoggedOut Listener | ||
|
||
func login(withEmail: String?, _ password: String?) { | ||
listener?.didLogin(withEmail: withEmail, password) | ||
} | ||
} |
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,26 @@ | ||
// | ||
// LoggedOutRouter.swift | ||
// TodoList | ||
// | ||
// Created by 김종권 on 2021/04/28. | ||
// | ||
|
||
import RIBs | ||
|
||
protocol LoggedOutInteractable: Interactable { | ||
var router: LoggedOutRouting? { get set } | ||
var listener: LoggedOutListener? { get set } | ||
} | ||
|
||
protocol LoggedOutViewControllable: ViewControllable { | ||
// TODO: Declare methods the router invokes to manipulate the view hierarchy. | ||
} | ||
|
||
final class LoggedOutRouter: ViewableRouter<LoggedOutInteractable, LoggedOutViewControllable>, LoggedOutRouting { | ||
|
||
// TODO: Constructor inject child builder protocols to allow building children. | ||
override init(interactor: LoggedOutInteractable, viewController: LoggedOutViewControllable) { | ||
super.init(interactor: interactor, viewController: viewController) | ||
interactor.router = self | ||
} | ||
} |
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,74 @@ | ||
// | ||
// LoggedOutViewController.swift | ||
// TodoList | ||
// | ||
// Created by 김종권 on 2021/04/28. | ||
// | ||
|
||
import RIBs | ||
import RxSwift | ||
import RxCocoa | ||
import UIKit | ||
import SnapKit | ||
|
||
protocol LoggedOutPresentableListener: AnyObject { | ||
func login(withEmail: String?, _ password: String?) | ||
} | ||
|
||
final class LoggedOutViewController: UIViewController, LoggedOutPresentable, LoggedOutViewControllable { | ||
|
||
weak var listener: LoggedOutPresentableListener? | ||
let bag = DisposeBag() | ||
|
||
lazy var emailTextField: UITextField = { | ||
let textField = UITextField() | ||
textField.borderStyle = .line | ||
textField.placeholder = "email" | ||
view.addSubview(textField) | ||
return textField | ||
}() | ||
|
||
lazy var passwordTextField: UITextField = { | ||
let textField = UITextField() | ||
textField.borderStyle = .line | ||
textField.placeholder = "password" | ||
view.addSubview(textField) | ||
return textField | ||
}() | ||
|
||
lazy var confirmButton: UIButton = { | ||
let button = UIButton() | ||
button.setTitle("confirm", for: .normal) | ||
button.setTitleColor(.white, for: .normal) | ||
button.backgroundColor = .black | ||
view.addSubview(button) | ||
button.rx.tap.subscribe(onNext: { [weak self] in | ||
self?.listener?.login(withEmail: self?.emailTextField.text, self?.passwordTextField.text) | ||
}).disposed(by: bag) | ||
return button | ||
}() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
view.backgroundColor = .white | ||
setupLayout() | ||
} | ||
|
||
private func setupLayout() { | ||
emailTextField.snp.makeConstraints { | ||
$0.top.equalTo(view).offset(120) | ||
$0.leading.trailing.equalTo(view).inset(40) | ||
$0.height.equalTo(40) | ||
} | ||
|
||
passwordTextField.snp.makeConstraints { | ||
$0.top.equalTo(emailTextField.snp.bottom).offset(20) | ||
$0.leading.trailing.height.equalTo(emailTextField) | ||
} | ||
|
||
confirmButton.snp.makeConstraints { | ||
$0.top.equalTo(passwordTextField.snp.bottom).offset(20) | ||
$0.leading.trailing.height.equalTo(passwordTextField) | ||
} | ||
} | ||
} |
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,20 @@ | ||
// | ||
// RootComponent+LoggedOut.swift | ||
// TodoList | ||
// | ||
// Created by 김종권 on 2021/04/28. | ||
// | ||
|
||
import RIBs | ||
|
||
/// The dependencies needed from the parent scope of Root to provide for the LoggedOut scope. | ||
// TODO: Update RootDependency protocol to inherit this protocol. | ||
protocol RootDependencyLoggedOut: Dependency { | ||
// TODO: Declare dependencies needed from the parent scope of Root to provide dependencies | ||
// for the LoggedOut scope. | ||
} | ||
|
||
extension RootComponent: LoggedOutDependency { | ||
|
||
// TODO: Implement properties to provide for LoggedOut scope. | ||
} |
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
Oops, something went wrong.