Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔀 :: Moordinator 2.0.0 버전 대응 및 Interface 모듈 제거 #21

Merged
merged 6 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,14 @@ public extension TargetDependency {
}

public extension TargetDependency.Feature {
static let RenewalPasswordFeatureInterface = TargetDependency.project(
target: ModulePaths.Feature.RenewalPasswordFeature.targetName(type: .interface),
path: .relativeToFeature(ModulePaths.Feature.RenewalPasswordFeature.rawValue)
)
static let RenewalPasswordFeature = TargetDependency.project(
target: ModulePaths.Feature.RenewalPasswordFeature.targetName(type: .sources),
path: .relativeToFeature(ModulePaths.Feature.RenewalPasswordFeature.rawValue)
)
static let SignupFeatureInterface = TargetDependency.project(
target: ModulePaths.Feature.SignupFeature.targetName(type: .interface),
path: .relativeToFeature(ModulePaths.Feature.SignupFeature.rawValue)
)
static let SignupFeature = TargetDependency.project(
target: ModulePaths.Feature.SignupFeature.targetName(type: .sources),
path: .relativeToFeature(ModulePaths.Feature.SignupFeature.rawValue)
)
static let MainFeatureInterface = TargetDependency.project(
target: ModulePaths.Feature.MainFeature.targetName(type: .interface),
path: .relativeToFeature(ModulePaths.Feature.MainFeature.rawValue)
)
static let MainFeature = TargetDependency.project(
target: ModulePaths.Feature.MainFeature.targetName(type: .sources),
path: .relativeToFeature(ModulePaths.Feature.MainFeature.rawValue)
Expand All @@ -38,10 +26,6 @@ public extension TargetDependency.Feature {
target: ModulePaths.Feature.RootFeature.targetName(type: .sources),
path: .relativeToFeature(ModulePaths.Feature.RootFeature.rawValue)
)
static let SigninFeatureInterface = TargetDependency.project(
target: ModulePaths.Feature.SigninFeature.targetName(type: .interface),
path: .relativeToFeature(ModulePaths.Feature.SigninFeature.rawValue)
)
static let SigninFeature = TargetDependency.project(
target: ModulePaths.Feature.SigninFeature.targetName(type: .sources),
path: .relativeToFeature(ModulePaths.Feature.SigninFeature.rawValue)
Expand Down
3 changes: 2 additions & 1 deletion Projects/App/Sources/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?
private let moordinatorWorker = MoordinatorWorker()
private let rootRouter = RootRouter()

func scene(
_ scene: UIScene,
Expand All @@ -15,7 +16,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let scene = (scene as? UIWindowScene) else { return }
let window = UIWindow(windowScene: scene)
let rootMoordinator = AppDelegate.container.resolve(RootMoordinator.self, argument: window)!
moordinatorWorker.coordinate(moordinator: rootMoordinator)
moordinatorWorker.coordinate(moordinator: rootMoordinator, with: rootRouter)
self.window = window
}

Expand Down
8 changes: 6 additions & 2 deletions Projects/Feature/BaseFeature/Sources/Base/BaseStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ import Combine
import Foundation
import Moordinator

public protocol BaseStore {
public protocol BaseStore: Router, HasCancellableBag {
associatedtype State
associatedtype Action

var stateSubject: CurrentValueSubject<State, Never> { get }
var currentState: State { get }
var state: AnyPublisher<State, Never> { get }
var bag: Set<AnyCancellable> { get }

func process(_ action: Action)
}

public extension BaseStore {
var currentState: State {
stateSubject.value
}

var state: AnyPublisher<State, Never> {
stateSubject.eraseToAnyPublisher()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import Combine
import DesignSystem
import UIKit

open class BaseViewController<Store: BaseStore>: UIViewController, BoundsProviable {
open class BaseViewController<Store: BaseStore>:
UIViewController,
baekteun marked this conversation as resolved.
Show resolved Hide resolved
HasCancellableBag,
ViewControllable {

// MARK: - Properties

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Combine
import Foundation

public protocol HasCancellableBag {
var bag: Set<AnyCancellable> { get }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

public protocol HasStore {
associatedtype Store: BaseStore
var store: Store { get }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import UIKit

public protocol ViewControllable: UIViewController, HasStore, BoundsProviable {}
5 changes: 0 additions & 5 deletions Projects/Feature/BaseFeature/Sources/RouterProvidable.swift

This file was deleted.

5 changes: 1 addition & 4 deletions Projects/Feature/MainFeature/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import DependencyPlugin
let project = Project.makeModule(
name: ModulePaths.Feature.MainFeature.rawValue,
product: .staticLibrary,
targets: [.interface, .unitTest],
targets: [.unitTest],
internalDependencies: [
.Feature.BaseFeature
],
interfaceDependencies: [
.SPM.Moordinator
]
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import MainFeatureInterface
import Swinject

public final class MainAssembly: Assembly {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import MainFeatureInterface
import Moordinator

public struct MainFactoryImpl: MainFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Moordinator

final class MainMoordinator: Moordinator {
private let rootVC = UINavigationController()
let router: any Router = MainRouter()

var root: Presentable {
rootVC
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion Projects/Feature/RenewalPasswordFeature/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DependencyPlugin
let project = Project.makeModule(
name: ModulePaths.Feature.RenewalPasswordFeature.rawValue,
product: .staticLibrary,
targets: [.interface, .unitTest],
targets: [.unitTest],
internalDependencies: [
.Feature.BaseFeature,
.Domain.AuthDomainInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import AuthDomainInterface
import RenewalPasswordFeatureInterface
import Swinject

public final class RenewalPasswordAssembly: Assembly {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import UIKit
import BaseFeature
import Moordinator
import UIKit

public protocol RenewalPasswordFactory {
func makeViewController(router: any Router) -> UIViewController
func makeViewController() -> UIViewController
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import AuthDomainInterface
import DWebKit
import RenewalPasswordFeatureInterface
import Moordinator
import UIKit

Expand All @@ -11,7 +10,7 @@ struct RenewalPasswordFactoryImpl: RenewalPasswordFactory {
self.loadJwtTokenUseCase = loadJwtTokenUseCase
}

func makeViewController(router: Router) -> UIViewController {
func makeViewController() -> UIViewController {
let token = loadJwtTokenUseCase.execute()
let url = "https://www.dotori-gsm.com/changePasswd"

Expand Down
7 changes: 2 additions & 5 deletions Projects/Feature/RootFeature/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ let project = Project.makeModule(
product: .staticLibrary,
targets: [],
internalDependencies: [
.Feature.SigninFeatureInterface,
.Feature.MainFeatureInterface,
.Feature.SigninFeature,
.Feature.MainFeature,
.Feature.BaseFeature
],
interfaceDependencies: [
.SPM.Moordinator
]
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MainFeatureInterface
import SigninFeatureInterface
import MainFeature
import SigninFeature
import Swinject

public final class RootAssembly: Assembly {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BaseFeature
import Combine
import MainFeatureInterface
import MainFeature
import Moordinator
import SigninFeatureInterface
import SigninFeature
import UIKit

public final class RootMoordinator: Moordinator {
Expand All @@ -14,7 +14,6 @@ public final class RootMoordinator: Moordinator {
viewController.view.backgroundColor = .white
return viewController
}()
public let router: any Router = RootRouter()

public var root: Presentable {
rootVC
Expand All @@ -33,6 +32,7 @@ public final class RootMoordinator: Moordinator {
}

public func route(to path: RoutePath) -> MoordinatorContributors {
print(path)
guard let path = path.asDotori else { return .none }
switch path {
case .signin:
Expand All @@ -47,7 +47,12 @@ public final class RootMoordinator: Moordinator {
completion: nil
)
}
return .one(.contribute(signinMoordinator))
return .one(
.contribute(
withNextPresentable: signinMoordinator,
withNextRouter: DisposableRouter(singlePath: DotoriRoutePath.signin)
)
)

case .main:
let mainMoordinator = mainFactory.makeMoordinator()
Expand All @@ -61,7 +66,12 @@ public final class RootMoordinator: Moordinator {
completion: nil
)
}
return .one(.contribute(mainMoordinator))
return .one(
.contribute(
withNextPresentable: mainMoordinator,
withNextRouter: DisposableRouter(singlePath: DotoriRoutePath.main)
)
)

default:
return .none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import BaseFeature
import Combine
import Moordinator

final class RootRouter: Router {
let route: PassthroughSubject<any RoutePath, Never> = .init()
var initialPath: RoutePath {
public final class RootRouter: Router {
public init() {}
public let route: PassthroughSubject<any RoutePath, Never> = .init()
public var initialPath: RoutePath {
DotoriRoutePath.signin
}
}
7 changes: 1 addition & 6 deletions Projects/Feature/SigninFeature/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ import DependencyPlugin
let project = Project.makeModule(
name: ModulePaths.Feature.SigninFeature.rawValue,
product: .staticLibrary,
targets: [.interface, .unitTest],
targets: [.unitTest],
internalDependencies: [
.Feature.BaseFeature,
.Feature.SignupFeatureInterface,
.Feature.RenewalPasswordFeatureInterface,
.Domain.AuthDomainInterface
],
interfaceDependencies: [
.SPM.Moordinator
]
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import AuthDomainInterface
import SigninFeatureInterface
import SignupFeatureInterface
import RenewalPasswordFeatureInterface
import SignupFeature
import RenewalPasswordFeature
import Swinject

public final class SigninAssembly: Assembly {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Moordinator
import UIKit

public protocol SigninFactory {
func makeMoordinator() -> Moordinator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import AuthDomainInterface
import SigninFeatureInterface
import SignupFeatureInterface
import RenewalPasswordFeatureInterface
import SignupFeature
import RenewalPasswordFeature
import Moordinator

struct SigninFactoryImpl: SigninFactory {
Expand All @@ -20,14 +19,11 @@ struct SigninFactoryImpl: SigninFactory {
}

func makeMoordinator() -> Moordinator {
let signinRouter = SigninRouter()
let signinStore = SigninStore(
router: signinRouter,
signinUseCase: self.signinUseCase
)
let signinViewController = SigninViewController(store: signinStore)
return SigninMoordinator(
router: signinRouter,
signinViewController: signinViewController,
signupFactory: self.signupFactory,
renewalPasswordFactory: self.renewalPasswordFactory
Expand Down
Loading