Skip to content

Commit

Permalink
feature: GameRepository 주입 시점 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
choijungp committed Dec 2, 2024
1 parent dcbf288 commit ef883ee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion AirplaIN/AirplaIN/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
whiteboardObjectSet: whiteboardObjectSet,
textFieldDefaultSize: CGSize(width: 200, height: 50))
let drawObjectUseCase = DrawObjectUseCase()
let gameObjectUseCase = GameObjectUseCase(repository: GameRepository(persistenceService: PersistenceService()))
let gameRepository = GameRepository(persistenceService: PersistenceService())
let gameObjectUseCase = GameObjectUseCase(repository: gameRepository)
let photoUseCase = PhotoUseCase(photoRepository: photoRepository)
let chatUseCase = ChatUseCase(chatRepository: chatRepository)

Expand All @@ -72,6 +73,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
drawObjectUseCase: drawObjectUseCase,
textObjectUseCase: textObjectUseCase,
chatUseCase: chatUseCase,
gameRepository: gameRepository,
gameObjectUseCase: gameObjectUseCase,
manageWhiteboardToolUseCase: manageWhiteboardToolUseCase,
manageWhiteboardObjectUseCase: manageWhiteboardObjectUseCase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public protocol GameRepositoryInterface {
func randomGameAnswer() -> String

/// 게임 정답 Set을 저장합니다.
/// - Parameter wordleAnswerSet: 게임 정답 Set
func saveWordleAnswerSet(wordleAnswerSet: [String])
func saveWordleAnswerSet()

/// 입력한 단어가 게임 정답 Set에 포함되어 있는지 여부를 판단합니다.
/// - Parameter word: 입력한 단어
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ public final class WhiteboardViewController: UIViewController {
}
private let profileRepository: ProfileRepositoryInterface
private let chatUseCase: ChatUseCaseInterface
private let gameRepository: GameRepositoryInterface

public init(
viewModel: WhiteboardViewModel,
objectViewFactory: WhiteboardObjectViewFactoryable,
profileRepository: ProfileRepositoryInterface,
chatUseCase: ChatUseCaseInterface
chatUseCase: ChatUseCaseInterface,
gameRepository: GameRepositoryInterface
) {
self.viewModel = viewModel
self.objectViewFactory = objectViewFactory
self.profileRepository = profileRepository
self.chatUseCase = chatUseCase
self.gameRepository = gameRepository
cancellables = []
whiteboardObjectViews = [:]
super.init(nibName: nil, bundle: nil)
Expand Down Expand Up @@ -363,7 +366,6 @@ extension WhiteboardViewController: UITextViewDelegate {
extension WhiteboardViewController: GameObjectViewDelegate {
public func gameObjectViewDidDoubleTap(_ sender: GameObjectView, gameObject: GameObject) {
viewModel.action(input: .deselectObject)
let gameRepository = GameRepository(persistenceService: PersistenceService())
let wordelViewModel = WordleViewModel(gameRepository: gameRepository, gameObject: gameObject)
let wordleView = WordleView(viewModel: wordelViewModel)
let hostingController = UIHostingController(rootView: NavigationStack { wordleView })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public final class WhiteboardListViewController: UIViewController {
private let drawObjectUseCase: DrawObjectUseCaseInterface
private let textObjectUseCase: TextObjectUseCaseInterface
private let chatUseCase: ChatUseCaseInterface
private let gameRepository: GameRepositoryInterface
private let gameObjectUseCase: GameObjectUseCaseInterface
private let manageWhiteboardToolUseCase: ManageWhiteboardToolUseCaseInterface
private let manageWhiteboardObjectUseCase: ManageWhiteboardObjectUseCaseInterface
Expand All @@ -83,6 +84,7 @@ public final class WhiteboardListViewController: UIViewController {
drawObjectUseCase: DrawObjectUseCaseInterface,
textObjectUseCase: TextObjectUseCaseInterface,
chatUseCase: ChatUseCaseInterface,
gameRepository: GameRepositoryInterface,
gameObjectUseCase: GameObjectUseCaseInterface,
manageWhiteboardToolUseCase: ManageWhiteboardToolUseCaseInterface,
manageWhiteboardObjectUseCase: ManageWhiteboardObjectUseCaseInterface
Expand All @@ -96,6 +98,7 @@ public final class WhiteboardListViewController: UIViewController {
self.drawObjectUseCase = drawObjectUseCase
self.textObjectUseCase = textObjectUseCase
self.chatUseCase = chatUseCase
self.gameRepository = gameRepository
self.gameObjectUseCase = gameObjectUseCase
self.manageWhiteboardToolUseCase = manageWhiteboardToolUseCase
self.manageWhiteboardObjectUseCase = manageWhiteboardObjectUseCase
Expand Down Expand Up @@ -138,6 +141,7 @@ public final class WhiteboardListViewController: UIViewController {
let drawObjectUseCase = self?.drawObjectUseCase,
let textObjectUseCase = self?.textObjectUseCase,
let chatUseCase = self?.chatUseCase,
let gameRepository = self?.gameRepository,
let gameObjectUseCase = self?.gameObjectUseCase,
let manageWhiteboardToolUseCase = self?.manageWhiteboardToolUseCase,
let manageWhiteboardObjectUseCase = self?.manageWhiteboardObjectUseCase
Expand All @@ -156,7 +160,8 @@ public final class WhiteboardListViewController: UIViewController {
viewModel: whiteboardViewModel,
objectViewFactory: whiteboardObjectViewFactory,
profileRepository: profileRepository,
chatUseCase: chatUseCase)
chatUseCase: chatUseCase,
gameRepository: gameRepository)
self?.navigationController?.isNavigationBarHidden = false
self?.navigationController?.pushViewController(whiteboardViewController, animated: true)
}
Expand Down Expand Up @@ -326,7 +331,8 @@ extension WhiteboardListViewController: UICollectionViewDelegate {
viewModel: whiteboardViewModel,
objectViewFactory: whiteboardObjectViewFactory,
profileRepository: profileRepository,
chatUseCase: chatUseCase)
chatUseCase: chatUseCase,
gameRepository: gameRepository)
self.navigationController?.isNavigationBarHidden = false
self.navigationController?.pushViewController(whiteboardViewController, animated: true)
}
Expand Down

0 comments on commit ef883ee

Please sign in to comment.