Skip to content

Commit

Permalink
Merge pull request #1 from JK0369/feature/LoggedOut_RIB
Browse files Browse the repository at this point in the history
Feature/logged out rib
  • Loading branch information
JK0369 committed Apr 29, 2021
2 parents 1d25823 + 78239be commit 3fc2b30
Show file tree
Hide file tree
Showing 12 changed files with 286 additions and 5 deletions.
1 change: 1 addition & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ target 'TodoList' do

pod 'SnapKit'
pod 'RIBs', :git => 'https://github.com/uber/RIBs.git', :tag => '0.9.2'
pod 'RxCocoa'

end
8 changes: 7 additions & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ PODS:
- RIBs (0.9.3):
- RxRelay (~> 5.0)
- RxSwift (~> 5.0)
- RxCocoa (5.1.1):
- RxRelay (~> 5)
- RxSwift (~> 5)
- RxRelay (5.1.1):
- RxSwift (~> 5)
- RxSwift (5.1.2)
- SnapKit (5.0.1)

DEPENDENCIES:
- RIBs (from `https://github.com/uber/RIBs.git`, tag `0.9.2`)
- RxCocoa
- SnapKit

SPEC REPOS:
trunk:
- RxCocoa
- RxRelay
- RxSwift
- SnapKit
Expand All @@ -29,10 +34,11 @@ CHECKOUT OPTIONS:

SPEC CHECKSUMS:
RIBs: efceda5df20c1a1e05139232a4638a6242caa92a
RxCocoa: 32065309a38d29b5b0db858819b5bf9ef038b601
RxRelay: d77f7d771495f43c556cbc43eebd1bb54d01e8e9
RxSwift: 1e2e1f9570186967f617e49128ed26ccf1bafc8e
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb

PODFILE CHECKSUM: f8c2551f92fc7a00bad8537aa366abce9ec4309d
PODFILE CHECKSUM: 445ec4af465b364eab25cd468581cdd97d5d669c

COCOAPODS: 1.10.1
30 changes: 30 additions & 0 deletions TodoList.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
E0868DB826397F77003D9D87 /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0868DB426397F77003D9D87 /* RootViewController.swift */; };
E0868DB926397F77003D9D87 /* RootBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0868DB526397F77003D9D87 /* RootBuilder.swift */; };
E0868DBA26397F77003D9D87 /* RootInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0868DB626397F77003D9D87 /* RootInteractor.swift */; };
E0868DC2263985BD003D9D87 /* LoggedOutRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0868DBE263985BD003D9D87 /* LoggedOutRouter.swift */; };
E0868DC3263985BD003D9D87 /* LoggedOutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0868DBF263985BD003D9D87 /* LoggedOutViewController.swift */; };
E0868DC4263985BD003D9D87 /* LoggedOutBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0868DC0263985BD003D9D87 /* LoggedOutBuilder.swift */; };
E0868DC5263985BD003D9D87 /* LoggedOutInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0868DC1263985BD003D9D87 /* LoggedOutInteractor.swift */; };
E0868DC726398A45003D9D87 /* RootComponent+LoggedOut.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0868DC626398A45003D9D87 /* RootComponent+LoggedOut.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -36,6 +41,11 @@
E0868DB426397F77003D9D87 /* RootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = "<group>"; };
E0868DB526397F77003D9D87 /* RootBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootBuilder.swift; sourceTree = "<group>"; };
E0868DB626397F77003D9D87 /* RootInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootInteractor.swift; sourceTree = "<group>"; };
E0868DBE263985BD003D9D87 /* LoggedOutRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedOutRouter.swift; sourceTree = "<group>"; };
E0868DBF263985BD003D9D87 /* LoggedOutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedOutViewController.swift; sourceTree = "<group>"; };
E0868DC0263985BD003D9D87 /* LoggedOutBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedOutBuilder.swift; sourceTree = "<group>"; };
E0868DC1263985BD003D9D87 /* LoggedOutInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedOutInteractor.swift; sourceTree = "<group>"; };
E0868DC626398A45003D9D87 /* RootComponent+LoggedOut.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RootComponent+LoggedOut.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -88,6 +98,7 @@
E0868D9826397BCC003D9D87 /* TodoList */ = {
isa = PBXGroup;
children = (
E0868DBB263982D5003D9D87 /* LoggedOut */,
E0868DAD26397E5C003D9D87 /* AppStart */,
E0868DB226397F65003D9D87 /* Root */,
E0868D9B26397BCC003D9D87 /* SceneDelegate.swift */,
Expand Down Expand Up @@ -115,10 +126,22 @@
E0868DB426397F77003D9D87 /* RootViewController.swift */,
E0868DB526397F77003D9D87 /* RootBuilder.swift */,
E0868DB626397F77003D9D87 /* RootInteractor.swift */,
E0868DC626398A45003D9D87 /* RootComponent+LoggedOut.swift */,
);
path = Root;
sourceTree = "<group>";
};
E0868DBB263982D5003D9D87 /* LoggedOut */ = {
isa = PBXGroup;
children = (
E0868DBE263985BD003D9D87 /* LoggedOutRouter.swift */,
E0868DBF263985BD003D9D87 /* LoggedOutViewController.swift */,
E0868DC0263985BD003D9D87 /* LoggedOutBuilder.swift */,
E0868DC1263985BD003D9D87 /* LoggedOutInteractor.swift */,
);
path = LoggedOut;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -233,13 +256,18 @@
buildActionMask = 2147483647;
files = (
E0868D9E26397BCC003D9D87 /* ViewController.swift in Sources */,
E0868DC4263985BD003D9D87 /* LoggedOutBuilder.swift in Sources */,
E0868DB926397F77003D9D87 /* RootBuilder.swift in Sources */,
E0868DB726397F77003D9D87 /* RootRouter.swift in Sources */,
E0868DB826397F77003D9D87 /* RootViewController.swift in Sources */,
E0868DC5263985BD003D9D87 /* LoggedOutInteractor.swift in Sources */,
E0868DC2263985BD003D9D87 /* LoggedOutRouter.swift in Sources */,
E0868DC726398A45003D9D87 /* RootComponent+LoggedOut.swift in Sources */,
E0868DAF26397E72003D9D87 /* AppComponent.swift in Sources */,
E0868D9A26397BCC003D9D87 /* AppDelegate.swift in Sources */,
E0868DBA26397F77003D9D87 /* RootInteractor.swift in Sources */,
E0868D9C26397BCC003D9D87 /* SceneDelegate.swift in Sources */,
E0868DC3263985BD003D9D87 /* LoggedOutViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -382,6 +410,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = SS7U83UJNK;
INFOPLIST_FILE = TodoList/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.3;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -402,6 +431,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = SS7U83UJNK;
INFOPLIST_FILE = TodoList/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.3;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
39 changes: 39 additions & 0 deletions TodoList/LoggedOut/LoggedOutBuilder.swift
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)
}
}
51 changes: 51 additions & 0 deletions TodoList/LoggedOut/LoggedOutInteractor.swift
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)
}
}
26 changes: 26 additions & 0 deletions TodoList/LoggedOut/LoggedOutRouter.swift
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
}
}
74 changes: 74 additions & 0 deletions TodoList/LoggedOut/LoggedOutViewController.swift
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)
}
}
}
7 changes: 6 additions & 1 deletion TodoList/Root/RootBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ final class RootBuilder: Builder<RootDependency>, RootBuildable {

func build() -> LaunchRouting {
let component = RootComponent(dependency: dependency)

let viewController = RootViewController()
let interactor = RootInteractor(presenter: viewController)
return RootRouter(interactor: interactor, viewController: viewController)

let loggedOutBuilder = LoggedOutBuilder(dependency: component)
return RootRouter(interactor: interactor,
viewController: viewController,
loggedOutBuilder: loggedOutBuilder)
}
}
20 changes: 20 additions & 0 deletions TodoList/Root/RootComponent+LoggedOut.swift
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.
}
4 changes: 4 additions & 0 deletions TodoList/Root/RootInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ final class RootInteractor: PresentableInteractor<RootPresentable>, RootInteract
super.willResignActive()
// TODO: Pause any business logic.
}

func didLogin(withEmail: String?, _ password: String?) {
print("didLogin")
}
}

0 comments on commit 3fc2b30

Please sign in to comment.