Skip to content

Commit

Permalink
[#18] Update
Browse files Browse the repository at this point in the history
  • Loading branch information
gon125 committed Apr 13, 2021
1 parent 689a883 commit 383fe06
Show file tree
Hide file tree
Showing 31 changed files with 1,619 additions and 25 deletions.
8 changes: 6 additions & 2 deletions RIBs Study/RIBsStudy/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ target 'RIBsStudy' do
use_frameworks!

# Pods for RIBsStudy
pod 'RIBs', '~> 0.9'
pod 'SnapKit', '~> 5.0.0'
pod 'RIBs'
pod 'SnapKit'
pod 'RxCocoa'

target 'RIBsStudyTests' do
inherit! :search_paths
end
end
11 changes: 8 additions & 3 deletions RIBs Study/RIBsStudy/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
PODS:
- RIBs (0.9.1):
- RxSwift (~> 4.0)
- RxCocoa (4.5.0):
- RxSwift (>= 4.4.2, ~> 4.4)
- RxSwift (4.5.0)
- SnapKit (5.0.1)

DEPENDENCIES:
- RIBs (~> 0.9)
- SnapKit (~> 5.0.0)
- RIBs
- RxCocoa
- SnapKit

SPEC REPOS:
trunk:
- RIBs
- RxCocoa
- RxSwift
- SnapKit

SPEC CHECKSUMS:
RIBs: 879184fbca567425c488d6b3d14a9c5abfbf9d47
RxCocoa: cbf70265dc65a981d4ac982e513c10cf23df24a0
RxSwift: f172070dfd1a93d70a9ab97a5a01166206e1c575
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb

PODFILE CHECKSUM: b8f3e20bd14f0a6129105a0e926ce752d55b3d68
PODFILE CHECKSUM: 5958a1d48f49574bf1aaa346945aa5227424dddf

COCOAPODS: 1.10.1
272 changes: 270 additions & 2 deletions RIBs Study/RIBsStudy/RIBsStudy.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1240"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F31AB9C7261585D700D7821D"
BuildableName = "RIBsStudy.app"
BlueprintName = "RIBsStudy"
ReferencedContainer = "container:RIBsStudy.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F398CE2926252D0A00B144B9"
BuildableName = "RIBsStudyTests.xctest"
BlueprintName = "RIBsStudyTests"
ReferencedContainer = "container:RIBsStudy.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F31AB9C7261585D700D7821D"
BuildableName = "RIBsStudy.app"
BlueprintName = "RIBsStudy"
ReferencedContainer = "container:RIBsStudy.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F31AB9C7261585D700D7821D"
BuildableName = "RIBsStudy.app"
BlueprintName = "RIBsStudy"
ReferencedContainer = "container:RIBsStudy.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
51 changes: 51 additions & 0 deletions RIBs Study/RIBsStudy/RIBsStudy/LoggedIn/LoggedInBuilder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// LoggedInBuilder.swift
// RIBsStudy
//
// Created by Geonhyeong LIm on 2021/04/01.
//

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<LoggedInDependency> {

// 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<LoggedInDependency>, 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

let offGameBuilder = OffGameBuilder(dependency: component)
let ticTacToeBuilder = TicTacToeBuilder(dependency: component)
return LoggedInRouter(interactor: interactor,
viewController: component.LoggedInViewController,
offGameBuilder: offGameBuilder,
ticTacToeBuilder: ticTacToeBuilder)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// LoggedInComponent+OffGame.swift
// RIBsStudy
//
// Created by Geonhyeong LIm on 2021/04/08.
//

import RIBs

protocol LoggedInDependencyOffGame: Dependency {

}

extension LoggedInComponent: OffGameDependency {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// LoggedInComponent+TicTacToe.swift
// RIBsStudy
//
// Created by Geonhyeong LIm on 2021/04/08.
//

import RIBs

protocol LoggedInDependencyTicTacToe: Dependency {

}

extension LoggedInComponent: TicTacToeDependency { }
49 changes: 49 additions & 0 deletions RIBs Study/RIBsStudy/RIBsStudy/LoggedIn/LoggedInInteractor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// LoggedInInteractor.swift
// RIBsStudy
//
// Created by Geonhyeong LIm on 2021/04/01.
//

import RIBs
import RxSwift

protocol LoggedInRouting: Routing {
func cleanupViews()
func routeToTicTacToe()
func routeToOffGame()
}

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.
}

func startTicTacToe() {
router?.routeToTicTacToe()
}

func gameDidEnd() {
router?.routeToOffGame()
}
}
80 changes: 80 additions & 0 deletions RIBs Study/RIBsStudy/RIBsStudy/LoggedIn/LoggedInRouter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//
// LoggedInRouter.swift
// RIBsStudy
//
// Created by Geonhyeong LIm on 2021/04/01.
//

import RIBs

protocol LoggedInInteractable: Interactable, OffGameListener, TicTacToeListener {
var router: LoggedInRouting? { get set }
var listener: LoggedInListener? { get set }
}

protocol LoggedInViewControllable: ViewControllable {
func present(viewController: ViewControllable)
func dismiss(viewController: ViewControllable)
}

final class LoggedInRouter: Router<LoggedInInteractable>, LoggedInRouting {

// TODO: Constructor inject child builder protocols to allow building children.
init(interactor: LoggedInInteractable,
viewController: LoggedInViewControllable,
offGameBuilder: OffGameBuildable,
ticTacToeBuilder: TicTacToeBuildable) {
self.viewController = viewController
self.offGameBuilder = offGameBuilder
self.ticTacToeBuilder = ticTacToeBuilder
super.init(interactor: interactor)
interactor.router = self
}

override func didLoad() {
super.didLoad()
attachOffGame()
}

func cleanupViews() {
if let currentChild = currentChild {
viewController.dismiss(viewController: currentChild.viewControllable)
}
}

func routeToTicTacToe() {
detachCurrentChild()
let ticTacToe = ticTacToeBuilder.build(withListener: interactor)
currentChild = ticTacToe
attachChild(ticTacToe)
viewController.present(viewController: ticTacToe.viewControllable)

}

func routeToOffGame() {
detachCurrentChild()
attachOffGame()
}

// MARK: - Private

private let viewController: LoggedInViewControllable
private let offGameBuilder: OffGameBuildable
private let ticTacToeBuilder: TicTacToeBuildable

private var currentChild: ViewableRouting?

private func attachOffGame() {
let offGame = offGameBuilder.build(withListener: interactor)
self.currentChild = offGame
attachChild(offGame)
viewController.present(viewController: offGame.viewControllable)
}

private func detachCurrentChild() {
if let currentchild = currentChild {
detachChild(currentchild)
viewController.dismiss(viewController: currentchild.viewControllable)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class LoggedOutBuilder: Builder<LoggedOutDependency>, LoggedOutBuildable {
}

func build(withListener listener: LoggedOutListener) -> LoggedOutRouting {
let component = LoggedOutComponent(dependency: dependency)
_ = LoggedOutComponent(dependency: dependency)
let viewController = LoggedOutViewController()
let interactor = LoggedOutInteractor(presenter: viewController)
interactor.listener = listener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ protocol LoggedOutPresentable: Presentable {
}

protocol LoggedOutListener: class {
// TODO: Declare methods the interactor can invoke to communicate with other RIBs.
func didLogin(withPlayer1Name player1Name: String, player2Name: String)
}

final class LoggedOutInteractor: PresentableInteractor<LoggedOutPresentable>, LoggedOutInteractable, LoggedOutPresentableListener {
func login(withPlayer1Name player1Name: String?, player2Name: String?) {
let player1NameWithDefault = playerName(player1Name, withDefaultName: "Player 1")
let player2NameWithDefault = playerName(player2Name, withDefaultName: "Player 2")

print("\(player1NameWithDefault) vs \(player2NameWithDefault)")
listener?.didLogin(withPlayer1Name: player1NameWithDefault, player2Name: player2NameWithDefault)
}

private func playerName(_ name: String?, withDefaultName defaultName: String) -> String {
Expand Down
Loading

0 comments on commit 383fe06

Please sign in to comment.