Skip to content

Commit

Permalink
[Fix] #241 - Factory 파일 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongdung-eo committed Mar 23, 2024
1 parent b088969 commit f10072a
Show file tree
Hide file tree
Showing 15 changed files with 395 additions and 231 deletions.
64 changes: 60 additions & 4 deletions iOS-NOTTODO/iOS-NOTTODO.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// AchieveViewControllerFactory.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 3/23/24.
//

import Foundation

extension ViewControllerFactoryImpl {

func makeAchieveViewModel(coordinator: AchieveCoordinator) -> any AchievementViewModel {
let missionAPI = DefaultMissionService()
let manager = AchieveManagerImpl(missionAPI: missionAPI)
let viewModel = AchievementViewModelImpl(coordinator: coordinator, manager: manager)
return viewModel
}

func makeAchieveViewController(coordinator: AchieveCoordinator) -> AchievementViewController {
let viewModel = self.makeAchieveViewModel(coordinator: coordinator)
let viewController = AchievementViewController(viewModel: viewModel)
return viewController
}

func makeAchieveDetailViewModel(coordinator: AchieveCoordinator) -> any DetailAchievementViewModel & DetailAchievementViewModelPresentable {
let missionAPI = DefaultMissionService()
let manager = AchieveManagerImpl(missionAPI: missionAPI)
let viewModel = DetailAchievementViewModelImpl(coordinator: coordinator, manager: manager)
return viewModel
}

func makeAchieveDetailViewController(coordinator: AchieveCoordinator, date: String) -> DetailAchievementViewController {
let viewModel = self.makeAchieveDetailViewModel(coordinator: coordinator)
viewModel.selectedDate(date)
let viewController = DetailAchievementViewController(viewModel: viewModel)
return viewController
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// AuthViewControllerFactory.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 3/23/24.
//

import Foundation

extension ViewControllerFactoryImpl {
func makeAuthViewController(coordinator: AuthCoordinator) -> AuthViewController {
let viewController = AuthViewController(coordinator: coordinator)
return viewController
}

func makeNotificationDialogViewController(coordinator: AuthCoordinator, completion: @escaping () -> Void) -> NotificationDialogViewController {
let viewController = NotificationDialogViewController()
viewController.buttonHandler = {
completion()
}
return viewController
}
}

// Onboarding
extension ViewControllerFactoryImpl {
func makeValueOnboardingViewController(coordinator: AuthCoordinator) -> ValueOnboardingViewController {
let viewController = ValueOnboardingViewController(coordinator: coordinator)
return viewController
}
func makeLogoOnboardingViewController(coordinator: AuthCoordinator) -> LogoOnboardingViewController {
let viewController = LogoOnboardingViewController(coordinator: coordinator)
return viewController
}
func makeSecondOnboardingViewController(coordinator: AuthCoordinator) -> SecondOnboardingViewController {
let viewController = SecondOnboardingViewController(coordinator: coordinator)
return viewController
}
func makeThirdOnboardingViewController(coordinator: AuthCoordinator) -> ThirdOnboardingViewController {
let viewController = ThirdOnboardingViewController(coordinator: coordinator)
return viewController
}
func makeFourthOnboardingViewController(coordinator: AuthCoordinator) -> FourthOnboardingViewController {
let viewController = FourthOnboardingViewController(coordinator: coordinator)
return viewController
}
func makeFifthOnboardingViewController(coordinator: AuthCoordinator) -> FifthOnboardingViewController {
let viewController = FifthOnboardingViewController(coordinator: coordinator)
return viewController
}
}

Check failure on line 52 in iOS-NOTTODO/iOS-NOTTODO/Coordinator/Factory/AuthViewControllerFactory.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Trailing Newline Violation: Files should have a single trailing newline (trailing_newline)

Check warning on line 52 in iOS-NOTTODO/iOS-NOTTODO/Coordinator/Factory/AuthViewControllerFactory.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Trailing Newline Violation: Files should have a single trailing newline (trailing_newline)
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//
// HomeViewControllerFactory.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 3/23/24.
//

import Foundation

// Home
extension ViewControllerFactoryImpl {
func makePopupViewController(coordinator: HomeCoordinator, completion: @escaping () -> Void) -> CommonNotificationViewController {
let viewController = CommonNotificationViewController(coordinator: coordinator)
viewController.tapCloseButton = {
completion()
}
return viewController
}

func makeHomeViewController(coordinator: HomeCoordinator) -> HomeViewController {
let viewController = HomeViewController(coordinator: coordinator)
return viewController
}
}

// HomeDetail
extension ViewControllerFactoryImpl {
func makeDeleteViewController(coordinator: HomeCoordinator, completion: @escaping () -> Void) -> HomeDeleteViewController {
let viewController = HomeDeleteViewController(coordinator: coordinator)
viewController.deleteClosure = {
completion()
}
return viewController
}

func makeMissionDetailViewController(coordinator: HomeCoordinator, id: Int, deleteClosure: @escaping () -> Void, moveDateClosure: @escaping (String) -> Void) -> MissionDetailViewController {
let viewController = MissionDetailViewController(coordinator: coordinator)
viewController.userId = id
viewController.deleteClosure = {
deleteClosure()
}
viewController.moveDateClosure = { date in
moveDateClosure(date)
}
return viewController
}

func makeModifyViewController(coordinator: HomeCoordinator, id: Int = 0, type: MissionType) -> AddMissionViewController {
let viewController = AddMissionViewController(coordinator: coordinator)
viewController.setViewType(type)
viewController.setMissionId(id)
return viewController
}

func makeSelectDateViewController(coordinator: HomeCoordinator, data: MissionDetailResponseDTO, id: Int, moveDateClosure: @escaping (String) -> Void) -> DetailCalendarViewController {
let viewController = DetailCalendarViewController(coordinator: coordinator)
viewController.detailModel = data
viewController.userId = id
viewController.movedateClosure = { date in
moveDateClosure(date)
}
return viewController
}
}

// Add Mission
extension ViewControllerFactoryImpl {

func makeRecommendViewController(coordinator: HomeCoordinator, date: String) -> RecommendViewController {
let viewController = RecommendViewController(coordinator: coordinator)
viewController.setSelectDate(date)
return viewController
}

func makeRecommendDetailViewController(coordinator: HomeCoordinator, data: RecommendActionData) -> RecommendActionViewController {
let viewController = RecommendActionViewController(coordinator: coordinator)
viewController.actionHeaderData = data
return viewController
}

func makeAddViewController(coordinator: HomeCoordinator, data: AddMissionData, type: MissionType) -> AddMissionViewController {
let viewController = AddMissionViewController(coordinator: coordinator)
viewController.setViewType(type)
viewController.setNottodoLabel(data.nottodo ?? "")
viewController.setSituationLabel(data.situation ?? "")
viewController.setActionLabel(data.action ?? "")
viewController.setDate(data.date)

return viewController
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// MyPageViewControllerFactory.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 3/23/24.
//

import Foundation

extension ViewControllerFactoryImpl {
func makeMyInfoViewController(coordinator: MypageCoordinator) -> MyInfoViewController {
let viewController = MyInfoViewController(coordinator: coordinator)
return viewController
}

func makeMyInfoAccountViewController(coordinator: MypageCoordinator) -> MyInfoAccountViewController {
let viewController = MyInfoAccountViewController(coordinator: coordinator)
return viewController
}

func makeWithdrawViewController(coordinator: MypageCoordinator) -> NottodoModalViewController {
let viewController = NottodoModalViewController(coordinator: coordinator)
return viewController
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// AchieveFlowControllerFactory.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 3/23/24.
//

import Foundation

protocol AchieveFlowControllerFactory {
func makeAchieveViewController(coordinator: AchieveCoordinator) -> AchievementViewController
func makeAchieveDetailViewController(coordinator: AchieveCoordinator, date: String) -> DetailAchievementViewController
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// AuthFlowControllerFactory.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 3/23/24.
//

import Foundation
protocol AuthFlowControllerFactory {
func makeValueOnboardingViewController(coordinator: AuthCoordinator) -> ValueOnboardingViewController
func makeLogoOnboardingViewController(coordinator: AuthCoordinator) -> LogoOnboardingViewController
func makeSecondOnboardingViewController(coordinator: AuthCoordinator) -> SecondOnboardingViewController
func makeThirdOnboardingViewController(coordinator: AuthCoordinator) -> ThirdOnboardingViewController
func makeFourthOnboardingViewController(coordinator: AuthCoordinator) -> FourthOnboardingViewController
func makeFifthOnboardingViewController(coordinator: AuthCoordinator) -> FifthOnboardingViewController
func makeAuthViewController(coordinator: AuthCoordinator) -> AuthViewController
func makeNotificationDialogViewController(coordinator: AuthCoordinator, completion: @escaping () -> Void) -> NotificationDialogViewController
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// HomeFlowControllerFactory.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 3/23/24.
//

import Foundation

protocol HomeFlowControllerFactory {
func makePopupViewController(coordinator: HomeCoordinator, completion: @escaping () -> Void) -> CommonNotificationViewController
func makeHomeViewController(coordinator: HomeCoordinator) -> HomeViewController
func makeRecommendViewController(coordinator: HomeCoordinator, date: String) -> RecommendViewController
func makeRecommendDetailViewController(coordinator: HomeCoordinator, data: RecommendActionData) -> RecommendActionViewController
func makeAddViewController(coordinator: HomeCoordinator, data: AddMissionData, type: MissionType) -> AddMissionViewController
func makeDeleteViewController(coordinator: HomeCoordinator, completion: @escaping () -> Void) -> HomeDeleteViewController
func makeMissionDetailViewController(coordinator: HomeCoordinator, id: Int, deleteClosure: @escaping () -> Void, moveDateClosure: @escaping (String) -> Void) -> MissionDetailViewController
func makeModifyViewController(coordinator: HomeCoordinator, id: Int, type: MissionType) -> AddMissionViewController
func makeSelectDateViewController(coordinator: HomeCoordinator, data: MissionDetailResponseDTO, id: Int, moveDateClosure: @escaping (String) -> Void) -> DetailCalendarViewController
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// MyPageFlowControllerFactory.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 3/23/24.
//

import Foundation

protocol MyPageFlowControllerFactory {
func makeMyInfoViewController(coordinator: MypageCoordinator) -> MyInfoViewController
func makeMyInfoAccountViewController(coordinator: MypageCoordinator) -> MyInfoAccountViewController
func makeWithdrawViewController(coordinator: MypageCoordinator) -> NottodoModalViewController
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// TabBarFlowControllerFactory.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 3/23/24.
//

import UIKit

protocol TabBarControllerFactory {
func makeTabBarController(_ navigationController: UINavigationController) -> (UITabBarController, [UINavigationController])
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// UpdateFlowcontrollerFactory.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 3/23/24.
//

import Foundation

protocol UpdateFlowcontrollerFactory {
func makeUpdateCheckViewController(coordinator: UpdateCoordinator) -> UpdateCheckViewController
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// TabBarViewControllerFactory.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 3/23/24.
//

import UIKit

extension ViewControllerFactoryImpl {
func makeTabBarController(_: UINavigationController) -> (UITabBarController, [UINavigationController]) {
let tabBarController = TabBarController()
let navigationControllers = tabBarController.setTabBarItems().map(makeNavigationController)

return (tabBarController, navigationControllers)
}

func makeNavigationController(_ tabBarItem: UITabBarItem) -> UINavigationController {
let navigationController = UINavigationController()
navigationController.tabBarItem = tabBarItem
navigationController.setNavigationBarHidden(true, animated: false)
return navigationController
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// UpdateViewControllerFactory.swift
// iOS-NOTTODO
//
// Created by JEONGEUN KIM on 3/23/24.
//

import Foundation

extension ViewControllerFactoryImpl {
func makeUpdateCheckViewController(coordinator: UpdateCoordinator) -> UpdateCheckViewController {
let viewController = UpdateCheckViewController(coordinator: coordinator)
return viewController
}
}
Loading

0 comments on commit f10072a

Please sign in to comment.