Skip to content

Commit

Permalink
✨ :: [#130] HomeFeature / InputDialog present HomeMoordinator에 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
baekteun committed Jul 30, 2023
1 parent af28b2d commit 14ac260
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ConfirmationDialogFeature
import InputDialogFeatureInterface
import MassageDomainInterface
import MealDomainInterface
import Moordinator
Expand All @@ -24,7 +25,8 @@ public final class HomeAssembly: Assembly {
cancelMassageUseCase: resolver.resolve(CancelMassageUseCase.self)!,
logoutUseCase: resolver.resolve(LogoutUseCase.self)!,
confirmationDialogFactory: resolver.resolve(ConfirmationDialogFactory.self)!,
myViolationListFactory: resolver.resolve(MyViolationListFactory.self)!
myViolationListFactory: resolver.resolve(MyViolationListFactory.self)!,
inputDialogFactory: resolver.resolve(InputDialogFactory.self)!
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ConfirmationDialogFeature
import InputDialogFeatureInterface
import MassageDomainInterface
import MealDomainInterface
import Moordinator
Expand All @@ -20,6 +21,7 @@ struct HomeFactoryImpl: HomeFactory {
private let logoutUseCase: any LogoutUseCase
private let confirmationDialogFactory: any ConfirmationDialogFactory
private let myViolationListFactory: any MyViolationListFactory
private let inputDialogFactory: any InputDialogFactory

init(
repeatableTimer: any RepeatableTimer,
Expand All @@ -33,7 +35,8 @@ struct HomeFactoryImpl: HomeFactory {
cancelMassageUseCase: any CancelMassageUseCase,
logoutUseCase: any LogoutUseCase,
confirmationDialogFactory: any ConfirmationDialogFactory,
myViolationListFactory: any MyViolationListFactory
myViolationListFactory: any MyViolationListFactory,
inputDialogFactory: any InputDialogFactory
) {
self.repeatableTimer = repeatableTimer
self.fetchSelfStudyInfoUseCase = fetchSelfStudyInfoUseCase
Expand All @@ -47,6 +50,7 @@ struct HomeFactoryImpl: HomeFactory {
self.logoutUseCase = logoutUseCase
self.confirmationDialogFactory = confirmationDialogFactory
self.myViolationListFactory = myViolationListFactory
self.inputDialogFactory = inputDialogFactory
}

func makeMoordinator() -> Moordinator {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import BaseFeature
import BaseFeatureInterface
import ConfirmationDialogFeature
import DWebKit
import InputDialogFeatureInterface
import Moordinator
import MyViolationListFeature
import TimerInterface
Expand All @@ -12,18 +14,21 @@ final class HomeMoordinator: Moordinator {
private let homeViewController: any StoredViewControllable
private let confirmationDialogFactory: any ConfirmationDialogFactory
private let myViolationListFactory: any MyViolationListFactory
private let inputDialogFactory: any InputDialogFactory
var root: Presentable {
rootVC
}

init(
homeViewController: any StoredViewControllable,
confirmationDialogFactory: any ConfirmationDialogFactory,
myViolationListFactory: any MyViolationListFactory
myViolationListFactory: any MyViolationListFactory,
inputDialogFactory: any InputDialogFactory
) {
self.homeViewController = homeViewController
self.confirmationDialogFactory = confirmationDialogFactory
self.myViolationListFactory = myViolationListFactory
self.inputDialogFactory = inputDialogFactory
}

func route(to path: RoutePath) -> MoordinatorContributors {
Expand Down Expand Up @@ -64,6 +69,14 @@ final class HomeMoordinator: Moordinator {
case .signin:
return .end(DotoriRoutePath.signin)

case let .inputDialog(title, placeholder, inputType, confirmAction):
return presentToInputDialog(
title: title,
placeholder: placeholder,
inputType: inputType,
confirmAction: confirmAction
)

default:
return .none
}
Expand Down Expand Up @@ -104,4 +117,25 @@ private extension HomeMoordinator {
self.rootVC.topViewController?.present(alert, animated: true)
return .none
}

func presentToInputDialog(
title: String,
placeholder: String,
inputType: DialogInputType,
confirmAction: @escaping (String) async -> Void
) -> MoordinatorContributors {
let viewController = inputDialogFactory.makeViewController(
title: title,
placeholder: placeholder,
inputType: inputType,
confirmAction: confirmAction
)
self.rootVC.topViewController?.modalPresent(viewController)
return .one(
.contribute(
withNextPresentable: viewController,
withNextRouter: viewController.router
)
)
}
}

0 comments on commit 14ac260

Please sign in to comment.