diff --git a/DailyQuest/DailyQuest/Application/DIContainer/HomeSceneDIContainer.swift b/DailyQuest/DailyQuest/Application/DIContainer/HomeSceneDIContainer.swift index 4c21450..9a8cd22 100644 --- a/DailyQuest/DailyQuest/Application/DIContainer/HomeSceneDIContainer.swift +++ b/DailyQuest/DailyQuest/Application/DIContainer/HomeSceneDIContainer.swift @@ -9,15 +9,26 @@ import UIKit final class HomeSceneDIContainer { + lazy var questsStorage: QuestsStorage = RealmQuestsStorage() + // MARK: - Repositories + func makeQuestsRepository() -> QuestsRepository { + return DefaultQuestsRepository(persistentStorage: questsStorage) + } // MARK: - Use Cases + func makeQuestUseCase() -> QuestUseCase { + return DefaultQuestUseCase(questsRepository: makeQuestsRepository()) + } // MARK: - View Models + func makeQuestViewModel() -> QuestViewModel { + return QuestViewModel(questUseCase: makeQuestUseCase()) + } // MARK: - View Controller func makeHomeViewController() -> HomeViewController { - return HomeViewController.create() + return HomeViewController.create(with: makeQuestViewModel()) } // MARK: - Flow diff --git a/DailyQuest/DailyQuest/Presentation/Home/ViewController/HomeViewController.swift b/DailyQuest/DailyQuest/Presentation/Home/ViewController/HomeViewController.swift index a22e344..c67a908 100644 --- a/DailyQuest/DailyQuest/Presentation/Home/ViewController/HomeViewController.swift +++ b/DailyQuest/DailyQuest/Presentation/Home/ViewController/HomeViewController.swift @@ -23,7 +23,6 @@ final class HomeViewController: UIViewController { private lazy var questView: QuestView = { let questView = QuestView() -// questView.setup(with: QuestViewModel()) return questView }() @@ -33,9 +32,11 @@ final class HomeViewController: UIViewController { }() // MARK: - Life Cycle - // static func create(with viewModel: HomeViewModel) - static func create() -> HomeViewController { - return HomeViewController() + static func create(with viewModel: QuestViewModel) -> HomeViewController { + let vc = HomeViewController() + vc.setup(questViewModel: viewModel) + + return vc } override func viewDidLoad() { @@ -69,4 +70,8 @@ final class HomeViewController: UIViewController { }) .disposed(by: disposableBag) } + + private func setup(questViewModel: QuestViewModel) { + questView.setup(with: questViewModel) + } }