diff --git a/TodoList.xcodeproj/project.pbxproj b/TodoList.xcodeproj/project.pbxproj index a002990..db95ee9 100644 --- a/TodoList.xcodeproj/project.pbxproj +++ b/TodoList.xcodeproj/project.pbxproj @@ -8,6 +8,9 @@ /* Begin PBXBuildFile section */ 1330DC3816EF9BABEA7B2962 /* Pods_TodoList.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4490A86ED0E7BFE3B4FE824F /* Pods_TodoList.framework */; }; + E0840A1C263A83F100D04DF2 /* LoggedInRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0840A19263A83F100D04DF2 /* LoggedInRouter.swift */; }; + E0840A1D263A83F100D04DF2 /* LoggedInBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0840A1A263A83F100D04DF2 /* LoggedInBuilder.swift */; }; + E0840A1E263A83F100D04DF2 /* LoggedInInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0840A1B263A83F100D04DF2 /* LoggedInInteractor.swift */; }; E0868D9A26397BCC003D9D87 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0868D9926397BCC003D9D87 /* AppDelegate.swift */; }; E0868D9C26397BCC003D9D87 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0868D9B26397BCC003D9D87 /* SceneDelegate.swift */; }; E0868D9E26397BCC003D9D87 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0868D9D26397BCC003D9D87 /* ViewController.swift */; }; @@ -23,12 +26,16 @@ 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 */; }; + E0F04ECD263A84DA009A07B2 /* RootComponent+LoggedIn.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0F04ECC263A84DA009A07B2 /* RootComponent+LoggedIn.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 0ED9813823246ED433AD9BB7 /* Pods-TodoList.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TodoList.debug.xcconfig"; path = "Target Support Files/Pods-TodoList/Pods-TodoList.debug.xcconfig"; sourceTree = ""; }; 4490A86ED0E7BFE3B4FE824F /* Pods_TodoList.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TodoList.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CD497FBB6EB1D35CFAD558D3 /* Pods-TodoList.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TodoList.release.xcconfig"; path = "Target Support Files/Pods-TodoList/Pods-TodoList.release.xcconfig"; sourceTree = ""; }; + E0840A19263A83F100D04DF2 /* LoggedInRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedInRouter.swift; sourceTree = ""; }; + E0840A1A263A83F100D04DF2 /* LoggedInBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedInBuilder.swift; sourceTree = ""; }; + E0840A1B263A83F100D04DF2 /* LoggedInInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedInInteractor.swift; sourceTree = ""; }; E0868D9626397BCC003D9D87 /* TodoList.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TodoList.app; sourceTree = BUILT_PRODUCTS_DIR; }; E0868D9926397BCC003D9D87 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; E0868D9B26397BCC003D9D87 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -46,6 +53,7 @@ E0868DC0263985BD003D9D87 /* LoggedOutBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedOutBuilder.swift; sourceTree = ""; }; E0868DC1263985BD003D9D87 /* LoggedOutInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedOutInteractor.swift; sourceTree = ""; }; E0868DC626398A45003D9D87 /* RootComponent+LoggedOut.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RootComponent+LoggedOut.swift"; sourceTree = ""; }; + E0F04ECC263A84DA009A07B2 /* RootComponent+LoggedIn.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RootComponent+LoggedIn.swift"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -77,6 +85,16 @@ path = Pods; sourceTree = ""; }; + E0840A18263A83DB00D04DF2 /* LoggedIn */ = { + isa = PBXGroup; + children = ( + E0840A19263A83F100D04DF2 /* LoggedInRouter.swift */, + E0840A1A263A83F100D04DF2 /* LoggedInBuilder.swift */, + E0840A1B263A83F100D04DF2 /* LoggedInInteractor.swift */, + ); + path = LoggedIn; + sourceTree = ""; + }; E0868D8D26397BCC003D9D87 = { isa = PBXGroup; children = ( @@ -98,6 +116,7 @@ E0868D9826397BCC003D9D87 /* TodoList */ = { isa = PBXGroup; children = ( + E0840A18263A83DB00D04DF2 /* LoggedIn */, E0868DBB263982D5003D9D87 /* LoggedOut */, E0868DAD26397E5C003D9D87 /* AppStart */, E0868DB226397F65003D9D87 /* Root */, @@ -125,6 +144,7 @@ E0868DB326397F77003D9D87 /* RootRouter.swift */, E0868DB426397F77003D9D87 /* RootViewController.swift */, E0868DB526397F77003D9D87 /* RootBuilder.swift */, + E0F04ECC263A84DA009A07B2 /* RootComponent+LoggedIn.swift */, E0868DB626397F77003D9D87 /* RootInteractor.swift */, E0868DC626398A45003D9D87 /* RootComponent+LoggedOut.swift */, ); @@ -257,12 +277,16 @@ files = ( E0868D9E26397BCC003D9D87 /* ViewController.swift in Sources */, E0868DC4263985BD003D9D87 /* LoggedOutBuilder.swift in Sources */, + E0840A1C263A83F100D04DF2 /* LoggedInRouter.swift in Sources */, + E0840A1D263A83F100D04DF2 /* LoggedInBuilder.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 */, + E0840A1E263A83F100D04DF2 /* LoggedInInteractor.swift in Sources */, + E0F04ECD263A84DA009A07B2 /* RootComponent+LoggedIn.swift in Sources */, E0868DAF26397E72003D9D87 /* AppComponent.swift in Sources */, E0868D9A26397BCC003D9D87 /* AppDelegate.swift in Sources */, E0868DBA26397F77003D9D87 /* RootInteractor.swift in Sources */, diff --git a/TodoList/LoggedIn/LoggedInBuilder.swift b/TodoList/LoggedIn/LoggedInBuilder.swift new file mode 100644 index 0000000..61cfc90 --- /dev/null +++ b/TodoList/LoggedIn/LoggedInBuilder.swift @@ -0,0 +1,45 @@ +// +// LoggedInBuilder.swift +// TodoList +// +// Created by 김종권 on 2021/04/29. +// + +import RIBs + +protocol LoggedInDependency: Dependency { + // TODO: Make sure to convert the variable into lower-camelcase. + var LoggedInViewController: LoggedInViewControllable { get } + // TODO: Declare the set of dependencies required by this RIB, but won't be + // created by this RIB. +} + +final class LoggedInComponent: Component { + + // TODO: Make sure to convert the variable into lower-camelcase. + fileprivate var LoggedInViewController: LoggedInViewControllable { + return dependency.LoggedInViewController + } + + // TODO: Declare 'fileprivate' dependencies that are only used by this RIB. +} + +// MARK: - Builder + +protocol LoggedInBuildable: Buildable { + func build(withListener listener: LoggedInListener) -> LoggedInRouting +} + +final class LoggedInBuilder: Builder, LoggedInBuildable { + + override init(dependency: LoggedInDependency) { + super.init(dependency: dependency) + } + + func build(withListener listener: LoggedInListener) -> LoggedInRouting { + let component = LoggedInComponent(dependency: dependency) + let interactor = LoggedInInteractor() + interactor.listener = listener + return LoggedInRouter(interactor: interactor, viewController: component.LoggedInViewController) + } +} diff --git a/TodoList/LoggedIn/LoggedInInteractor.swift b/TodoList/LoggedIn/LoggedInInteractor.swift new file mode 100644 index 0000000..4237969 --- /dev/null +++ b/TodoList/LoggedIn/LoggedInInteractor.swift @@ -0,0 +1,40 @@ +// +// LoggedInInteractor.swift +// TodoList +// +// Created by 김종권 on 2021/04/29. +// + +import RIBs +import RxSwift + +protocol LoggedInRouting: Routing { + func cleanupViews() + // TODO: Declare methods the interactor can invoke to manage sub-tree via the router. +} + +protocol LoggedInListener: class { + // TODO: Declare methods the interactor can invoke to communicate with other RIBs. +} + +final class LoggedInInteractor: Interactor, LoggedInInteractable { + + weak var router: LoggedInRouting? + weak var listener: LoggedInListener? + + // TODO: Add additional dependencies to constructor. Do not perform any logic + // in constructor. + override init() {} + + override func didBecomeActive() { + super.didBecomeActive() + // TODO: Implement business logic here. + } + + override func willResignActive() { + super.willResignActive() + + router?.cleanupViews() + // TODO: Pause any business logic. + } +} diff --git a/TodoList/LoggedIn/LoggedInRouter.swift b/TodoList/LoggedIn/LoggedInRouter.swift new file mode 100644 index 0000000..e6c6608 --- /dev/null +++ b/TodoList/LoggedIn/LoggedInRouter.swift @@ -0,0 +1,38 @@ +// +// LoggedInRouter.swift +// TodoList +// +// Created by 김종권 on 2021/04/29. +// + +import RIBs + +protocol LoggedInInteractable: Interactable { + var router: LoggedInRouting? { get set } + var listener: LoggedInListener? { get set } +} + +protocol LoggedInViewControllable: ViewControllable { + // TODO: Declare methods the router invokes to manipulate the view hierarchy. Since + // this RIB does not own its own view, this protocol is conformed to by one of this + // RIB's ancestor RIBs' view. +} + +final class LoggedInRouter: Router, LoggedInRouting { + + // TODO: Constructor inject child builder protocols to allow building children. + init(interactor: LoggedInInteractable, viewController: LoggedInViewControllable) { + self.viewController = viewController + super.init(interactor: interactor) + interactor.router = self + } + + func cleanupViews() { + // TODO: Since this router does not own its view, it needs to cleanup the views + // it may have added to the view hierarchy, when its interactor is deactivated. + } + + // MARK: - Private + + private let viewController: LoggedInViewControllable +} diff --git a/TodoList/Root/RootBuilder.swift b/TodoList/Root/RootBuilder.swift index 0449b1d..560eed2 100644 --- a/TodoList/Root/RootBuilder.swift +++ b/TodoList/Root/RootBuilder.swift @@ -8,13 +8,17 @@ import RIBs protocol RootDependency: Dependency { - // TODO: Declare the set of dependencies required by this RIB, but cannot be - // created by this RIB. + // parent에서 주입하는 것들 (만약 RootViewController처럼 자신의 RIB에서 생성할 시 이곳에다가 명시 x) -> AppComponent가 RootDependency를 구현하고 있으므로 } final class RootComponent: Component { - // TODO: Declare 'fileprivate' dependencies that are only used by this RIB. + let rootViewController: RootViewController + init(dependency: RootDependency, + rootViewController: RootViewController) { + self.rootViewController = rootViewController + super.init(dependency: dependency) + } } // MARK: - Builder @@ -30,14 +34,16 @@ final class RootBuilder: Builder, RootBuildable { } func build() -> LaunchRouting { - let component = RootComponent(dependency: dependency) - let viewController = RootViewController() + let component = RootComponent(dependency: dependency, + rootViewController: viewController) let interactor = RootInteractor(presenter: viewController) let loggedOutBuilder = LoggedOutBuilder(dependency: component) + let loggedInBuilder = LoggedInBuilder(dependency: component) return RootRouter(interactor: interactor, viewController: viewController, - loggedOutBuilder: loggedOutBuilder) + loggedOutBuilder: loggedOutBuilder, + loggedInBuilder: loggedInBuilder) } } diff --git a/TodoList/Root/RootComponent+LoggedIn.swift b/TodoList/Root/RootComponent+LoggedIn.swift new file mode 100644 index 0000000..35478be --- /dev/null +++ b/TodoList/Root/RootComponent+LoggedIn.swift @@ -0,0 +1,21 @@ +// +// RootComponent+LoggedIn.swift +// TodoList +// +// Created by 김종권 on 2021/04/29. +// + +import RIBs + +/// The dependencies needed from the parent scope of Root to provide for the LoggedIn scope. +// TODO: Update RootDependency protocol to inherit this protocol. +protocol RootDependencyLoggedIn: Dependency { + // TODO: Declare dependencies needed from the parent scope of Root to provide dependencies + // for the LoggedIn scope. +} + +extension RootComponent: LoggedInDependency { + var LoggedInViewController: LoggedInViewControllable { + return rootViewController + } +} diff --git a/TodoList/Root/RootRouter.swift b/TodoList/Root/RootRouter.swift index 4e6b6fe..b39b038 100644 --- a/TodoList/Root/RootRouter.swift +++ b/TodoList/Root/RootRouter.swift @@ -21,8 +21,10 @@ final class RootRouter: LaunchRouter, Ro // TODO: Constructor inject child builder protocols to allow building children. init(interactor: RootInteractable, viewController: RootViewControllable, - loggedOutBuilder: LoggedOutBuilder) { + loggedOutBuilder: LoggedOutBuilder, + loggedInBuilder: LoggedInBuilder) { self.loggedOutBuilder = loggedOutBuilder + self.loggedInBuilder = loggedInBuilder super.init(interactor: interactor, viewController: viewController) interactor.router = self } @@ -35,6 +37,7 @@ final class RootRouter: LaunchRouter, Ro // MARK: - Private private let loggedOutBuilder: LoggedOutBuildable + private let loggedInBuilder: LoggedInBuildable private var loggedOut: ViewableRouting? diff --git a/TodoList/Root/RootViewController.swift b/TodoList/Root/RootViewController.swift index a3329e3..f36f1f1 100644 --- a/TodoList/Root/RootViewController.swift +++ b/TodoList/Root/RootViewController.swift @@ -23,3 +23,9 @@ final class RootViewController: UIViewController, RootPresentable, RootViewContr present(viewController.uiviewController, animated: true, completion: nil) } } + +// MARK: LoggedInViewControllable + +extension RootViewController: LoggedInViewControllable { + +}