From 6c149477600b82a505cb10895ae03a3ff2fa87c4 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Tue, 17 Oct 2023 11:09:35 +0900 Subject: [PATCH 1/8] =?UTF-8?q?[REFACTOR]=20splash=20coordinator=EC=97=90?= =?UTF-8?q?=20adaptor=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 16 ++++-- .../Scenes/Adaptor/SplashAdaptor.swift | 25 ++++++++ .../Scenes/Adaptor/TodayAdaptor.swift | 2 +- .../SplashViewControllerable.swift | 2 +- .../TodayViewControllerable.swift | 2 +- .../SplashCoordinatorImpl.swift | 48 ++++++++++++++++ .../CoordinatorInterface/AppCoordinator.swift | 2 +- .../AuthCoordinator.swift | 8 +-- .../SplashCoordinator.swift | 57 ++----------------- .../FactoryImpl/SplashFactoryImpl.swift | 4 +- .../FactoryInterface/SpalshFactory.swift | 2 +- .../Common/PopNavigation.swift | 2 +- .../Scenes/Splash/SplashViewController.swift | 13 +++-- .../ViewControllers/TodayViewController.swift | 12 ++-- 14 files changed, 116 insertions(+), 79 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/SplashAdaptor.swift create mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/SplashCoordinatorImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 2133a042..d246bd20 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -110,7 +110,7 @@ B5F323E92A6A8F0000047869 /* CurriculumWeekBackgroundDummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5F323E82A6A8F0000047869 /* CurriculumWeekBackgroundDummy.swift */; }; C003CC1B2AD9176B00AFFAAC /* Coordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC1A2AD9176B00AFFAAC /* Coordinator.swift */; }; C003CC1D2AD917CF00AFFAAC /* AppCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC1C2AD917CF00AFFAAC /* AppCoordinator.swift */; }; - C003CC1F2AD917F900AFFAAC /* SplashCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC1E2AD917F900AFFAAC /* SplashCoordinator.swift */; }; + C003CC1F2AD917F900AFFAAC /* SplashCoordinatorImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC1E2AD917F900AFFAAC /* SplashCoordinatorImpl.swift */; }; C003CC212AD9181600AFFAAC /* TodayCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC202AD9181600AFFAAC /* TodayCoordinator.swift */; }; C003CC232AD9183600AFFAAC /* AuthCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC222AD9183600AFFAAC /* AuthCoordinator.swift */; }; C003CC252AD9184700AFFAAC /* TabbbarCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC242AD9184700AFFAAC /* TabbbarCoordinator.swift */; }; @@ -161,6 +161,8 @@ C009E9FA2ADBC4DE00112F18 /* BookmarkViewControllerable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C009E9F92ADBC4DE00112F18 /* BookmarkViewControllerable.swift */; }; C009E9FC2ADBC4FD00112F18 /* ChallengeViewControllerable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C009E9FB2ADBC4FD00112F18 /* ChallengeViewControllerable.swift */; }; C009E9FE2ADBC51400112F18 /* ArticleCategoryViewControllerable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C009E9FD2ADBC51400112F18 /* ArticleCategoryViewControllerable.swift */; }; + C034EDD62ADE21BD00AD6FF3 /* SplashCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDD52ADE21BD00AD6FF3 /* SplashCoordinator.swift */; }; + C034EDD82ADE21D200AD6FF3 /* SplashAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDD72ADE21D200AD6FF3 /* SplashAdaptor.swift */; }; C04BE3AD2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04BE3AC2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift */; }; C04BE3AF2ADD4F7F001967B5 /* TodayAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04BE3AE2ADD4F7F001967B5 /* TodayAdaptor.swift */; }; C065F0032ADBD2270094912C /* AuthFactoryImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C065F0022ADBD2270094912C /* AuthFactoryImpl.swift */; }; @@ -408,7 +410,7 @@ B5F323E82A6A8F0000047869 /* CurriculumWeekBackgroundDummy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumWeekBackgroundDummy.swift; sourceTree = ""; }; C003CC1A2AD9176B00AFFAAC /* Coordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Coordinator.swift; sourceTree = ""; }; C003CC1C2AD917CF00AFFAAC /* AppCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppCoordinator.swift; sourceTree = ""; }; - C003CC1E2AD917F900AFFAAC /* SplashCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashCoordinator.swift; sourceTree = ""; }; + C003CC1E2AD917F900AFFAAC /* SplashCoordinatorImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashCoordinatorImpl.swift; sourceTree = ""; }; C003CC202AD9181600AFFAAC /* TodayCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayCoordinator.swift; sourceTree = ""; }; C003CC222AD9183600AFFAAC /* AuthCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthCoordinator.swift; sourceTree = ""; }; C003CC242AD9184700AFFAAC /* TabbbarCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabbbarCoordinator.swift; sourceTree = ""; }; @@ -459,6 +461,8 @@ C009E9F92ADBC4DE00112F18 /* BookmarkViewControllerable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkViewControllerable.swift; sourceTree = ""; }; C009E9FB2ADBC4FD00112F18 /* ChallengeViewControllerable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewControllerable.swift; sourceTree = ""; }; C009E9FD2ADBC51400112F18 /* ArticleCategoryViewControllerable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryViewControllerable.swift; sourceTree = ""; }; + C034EDD52ADE21BD00AD6FF3 /* SplashCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashCoordinator.swift; sourceTree = ""; }; + C034EDD72ADE21D200AD6FF3 /* SplashAdaptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashAdaptor.swift; sourceTree = ""; }; C04BE3AC2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayCoordinatorImpl.swift; sourceTree = ""; }; C04BE3AE2ADD4F7F001967B5 /* TodayAdaptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayAdaptor.swift; sourceTree = ""; }; C065F0022ADBD2270094912C /* AuthFactoryImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthFactoryImpl.swift; sourceTree = ""; }; @@ -1429,6 +1433,7 @@ isa = PBXGroup; children = ( C04BE3AE2ADD4F7F001967B5 /* TodayAdaptor.swift */, + C034EDD72ADE21D200AD6FF3 /* SplashAdaptor.swift */, ); path = Adaptor; sourceTree = ""; @@ -1437,7 +1442,6 @@ isa = PBXGroup; children = ( C003CC1C2AD917CF00AFFAAC /* AppCoordinator.swift */, - C003CC1E2AD917F900AFFAAC /* SplashCoordinator.swift */, C003CC202AD9181600AFFAAC /* TodayCoordinator.swift */, C003CC222AD9183600AFFAAC /* AuthCoordinator.swift */, C003CC242AD9184700AFFAAC /* TabbbarCoordinator.swift */, @@ -1447,6 +1451,7 @@ C003CC2C2AD9189100AFFAAC /* BookmarkCoordinator.swift */, C003CC2E2AD9189F00AFFAAC /* MypageCoordinator.swift */, C003CC302AD918AB00AFFAAC /* ArticleCoordinator.swift */, + C034EDD52ADE21BD00AD6FF3 /* SplashCoordinator.swift */, ); path = CoordinatorInterface; sourceTree = ""; @@ -1455,6 +1460,7 @@ isa = PBXGroup; children = ( C04BE3AC2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift */, + C003CC1E2AD917F900AFFAAC /* SplashCoordinatorImpl.swift */, ); path = CoordinatorImpl; sourceTree = ""; @@ -1927,7 +1933,7 @@ C0DF039A2A5B908E0037F740 /* CGColor+.swift in Sources */, C003CC662ADA518E00AFFAAC /* ArticleDetailManager.swift in Sources */, 4AD216402A69AC1E00C9F2F2 /* MyPageResponse.swift in Sources */, - C003CC1F2AD917F900AFFAAC /* SplashCoordinator.swift in Sources */, + C003CC1F2AD917F900AFFAAC /* SplashCoordinatorImpl.swift in Sources */, C003CC6E2ADA51E200AFFAAC /* CurriculumListManager.swift in Sources */, D35272D12A681E13002D7FCB /* ChallengeData.swift in Sources */, C065F00D2ADBD29A0094912C /* OnboardingViewControllerable.swift in Sources */, @@ -2042,6 +2048,7 @@ C065F0072ADBD24B0094912C /* TodayFactoryImpl.swift in Sources */, C0DF034D2A5A9B8D0037F740 /* (null) in Sources */, 4A52DD9B2ADBBF2C00858230 /* SpalshFactory.swift in Sources */, + C034EDD82ADE21D200AD6FF3 /* SplashAdaptor.swift in Sources */, 4A81C2912ACC7DC80056E815 /* UICollectionViewCell+.swift in Sources */, C003CC2D2AD9189100AFFAAC /* BookmarkCoordinator.swift in Sources */, C0856B772ABFC4EA0026D9F8 /* MyPageServiceImpl.swift in Sources */, @@ -2068,6 +2075,7 @@ C0DF03592A5A9BF80037F740 /* ArticleCategoryViewController.swift in Sources */, C00780BA2A60149D0043EB36 /* LHTodayArticleTitle.swift in Sources */, B51220602A60111C006CBE2D /* Token.swift in Sources */, + C034EDD62ADE21BD00AD6FF3 /* SplashCoordinator.swift in Sources */, B53F4EE32ADBC1A3001C5752 /* ArticleFactoryImpl.swift in Sources */, C003CC702ADA51F300AFFAAC /* ChallengeManager.swift in Sources */, C009E9EE2ADBC07700112F18 /* ArticleCategortFactoryImpl.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/SplashAdaptor.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/SplashAdaptor.swift new file mode 100644 index 00000000..3af1cc3e --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/SplashAdaptor.swift @@ -0,0 +1,25 @@ +// +// SplashAdaptor.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/10/17. +// + +import Foundation + +final class SplashAdaptor: SplashNavigation { + + let coordinator: SplashCoordinator + init(coordinator: SplashCoordinator) { + self.coordinator = coordinator + } + + func checkToken(state: TokenState) { + switch state { + case .valid: + coordinator.showTabbarViewContoller() + case .expired: + coordinator.showLoginViewController() + } + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/TodayAdaptor.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/TodayAdaptor.swift index 001413d8..6df90096 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/TodayAdaptor.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/TodayAdaptor.swift @@ -5,7 +5,7 @@ // Created by uiskim on 2023/10/16. // -import UIKit +import Foundation final class TodayAdaptor: TodayNavigation { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/SplashViewControllerable.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/SplashViewControllerable.swift index ac4f28e3..05fb2b8b 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/SplashViewControllerable.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/SplashViewControllerable.swift @@ -8,5 +8,5 @@ import UIKit protocol SplashViewControllerable where Self: UIViewController { - var coordinator: SplashNavigation? { get set } + var navigator: SplashNavigation { get set } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/TodayViewControllerable.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/TodayViewControllerable.swift index 91de8a47..ea3860f8 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/TodayViewControllerable.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/TodayViewControllerable.swift @@ -8,5 +8,5 @@ import UIKit protocol TodayViewControllerable where Self: UIViewController { - var adaptor: TodayNavigation { get set } + var navigator: TodayNavigation { get set } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/SplashCoordinatorImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/SplashCoordinatorImpl.swift new file mode 100644 index 00000000..10530513 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/SplashCoordinatorImpl.swift @@ -0,0 +1,48 @@ +// +// SplashCoordinator.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/10/13. +// + +import UIKit + +final class SplashCoordinatorImpl: SplashCoordinator { + + weak var parentCoordinator: Coordinator? + private let factory: SplashFactory + + var children: [Coordinator] = [] + + var navigationController: UINavigationController + + init(navigationController: UINavigationController, factory: SplashFactory) { + self.navigationController = navigationController + self.factory = factory + } + + func start() { + showSplashViewController() + } + + func showSplashViewController() { + let splashAdaptor = SplashAdaptor(coordinator: self) + let splashViewController = factory.makeSplashViewController(adaptor: splashAdaptor) + self.navigationController.pushViewController(splashViewController, animated: false) + } + + func showTabbarViewContoller() { + let tabbarCoordinator = TabbarCoordinator(navigationController: navigationController) + children.removeAll() + tabbarCoordinator.parentCoordinator = self + tabbarCoordinator.start() + } + + func showLoginViewController() { + let authCoordinator = AuthCoordinator(navigationController: navigationController, factory: AuthFactoryImpl()) + children.removeAll() + authCoordinator.parentCoordinator = self + children.append(authCoordinator) + authCoordinator.start() + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AppCoordinator.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AppCoordinator.swift index 965bf292..291d7010 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AppCoordinator.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AppCoordinator.swift @@ -23,7 +23,7 @@ final class AppCoordinator: Coordinator { } func startSplashCoordinator() { - let splashCoordinator = SplashCoordinator(navigationController: navigationController, factory: SplashFactoryImpl()) + let splashCoordinator = SplashCoordinatorImpl(navigationController: navigationController, factory: SplashFactoryImpl()) children.removeAll() splashCoordinator.parentCoordinator = self children.append(splashCoordinator) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinator.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinator.swift index 08157280..3c832a59 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinator.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinator.swift @@ -40,8 +40,8 @@ extension AuthCoordinator: LoginNavigation, OnboardingNavigation, CompleteOnbard } func startButtonTapped() { - let splashCoorinator = parentCoordinator as? SplashCoordinator - splashCoorinator?.showTabbar() + let splashCoorinator = parentCoordinator as? SplashCoordinatorImpl + splashCoorinator?.showTabbarViewContoller() } func onboardingCompleted(data: UserOnboardingModel) { @@ -56,10 +56,10 @@ extension AuthCoordinator: LoginNavigation, OnboardingNavigation, CompleteOnbard } func checkUserIsVerified(userState: UserState, kakaoToken: String?) { - let splashCoorinator = parentCoordinator as? SplashCoordinator + let splashCoorinator = parentCoordinator as? SplashCoordinatorImpl switch userState { case .verified: - splashCoorinator?.showTabbar() + splashCoorinator?.showTabbarViewContoller() case .nonVerified: let onboardingViewController = factory.makeOnboardingViewController() onboardingViewController.setKakaoAccessToken(kakaoToken) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/SplashCoordinator.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/SplashCoordinator.swift index c704275a..620b127e 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/SplashCoordinator.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/SplashCoordinator.swift @@ -2,58 +2,13 @@ // SplashCoordinator.swift // LionHeart-iOS // -// Created by uiskim on 2023/10/13. +// Created by uiskim on 2023/10/17. // -import UIKit +import Foundation -final class SplashCoordinator: Coordinator { - - weak var parentCoordinator: Coordinator? - private let factory: SplashFactory - - var children: [Coordinator] = [] - - var navigationController: UINavigationController - - init(navigationController: UINavigationController, factory: SplashFactory) { - self.navigationController = navigationController - self.factory = factory - } - - func start() { - showSplashViewController() - } - - func showSplashViewController() { - let splashViewController = factory.makeSplashViewController() - splashViewController.coordinator = self - self.navigationController.pushViewController(splashViewController, animated: false) - } - - func showTabbar() { - let tabbarCoordinator = TabbarCoordinator(navigationController: navigationController) - children.removeAll() - tabbarCoordinator.parentCoordinator = self - tabbarCoordinator.start() - } - - func showLogin() { - let authCoordinator = AuthCoordinator(navigationController: navigationController, factory: AuthFactoryImpl()) - children.removeAll() - authCoordinator.parentCoordinator = self - children.append(authCoordinator) - authCoordinator.start() - } -} - -extension SplashCoordinator: SplashNavigation { - func checkToken(state: TokenState) { - switch state { - case .valid: - showTabbar() - case .expired: - showLogin() - } - } +protocol SplashCoordinator: Coordinator { + func showSplashViewController() + func showTabbarViewContoller() + func showLoginViewController() } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/SplashFactoryImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/SplashFactoryImpl.swift index afbf5057..ecbd9dfb 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/SplashFactoryImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/SplashFactoryImpl.swift @@ -8,7 +8,7 @@ import UIKit struct SplashFactoryImpl: SplashFactory { - func makeSplashViewController() -> SplashViewControllerable { - return SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) + func makeSplashViewController(adaptor: SplashNavigation) -> SplashViewControllerable { + return SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService())), adaptor: adaptor) } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/SpalshFactory.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/SpalshFactory.swift index 8e38ad98..489ab326 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/SpalshFactory.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/SpalshFactory.swift @@ -8,7 +8,7 @@ import UIKit protocol SplashFactory { - func makeSplashViewController() -> SplashViewControllerable + func makeSplashViewController(adaptor: SplashNavigation) -> SplashViewControllerable } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/NavigationInterface/Common/PopNavigation.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/NavigationInterface/Common/PopNavigation.swift index b2d238a3..d54f7429 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/NavigationInterface/Common/PopNavigation.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/NavigationInterface/Common/PopNavigation.swift @@ -7,6 +7,6 @@ import Foundation -protocol PopNavigation { +protocol PopNavigation: AnyObject { func backButtonTapped() } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Splash/SplashViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Splash/SplashViewController.swift index 8a28b100..bb5f476a 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Splash/SplashViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Splash/SplashViewController.swift @@ -12,13 +12,14 @@ import SnapKit final class SplashViewController: UIViewController, SplashViewControllerable { - weak var coordinator: SplashNavigation? + var navigator: SplashNavigation private let manager: SplashManager private let lottieImageView = LHLottie(name: "motion_logo_final") - init(manager: SplashManager) { + init(manager: SplashManager, adaptor: SplashNavigation) { self.manager = manager + self.navigator = adaptor super.init(nibName: nil, bundle: nil) } @@ -36,7 +37,7 @@ final class SplashViewController: UIViewController, SplashViewControllerable { override func viewWillAppear(_ animated: Bool) { lottieImageView.play { _ in guard let accessToken = UserDefaultsManager.tokenKey?.accessToken, let refreshToken = UserDefaultsManager.tokenKey?.refreshToken else { - self.coordinator?.checkToken(state: .expired) + self.navigator.checkToken(state: .expired) return } Task { @@ -77,7 +78,7 @@ private extension SplashViewController { let dtoToken = try await manager.reissueToken(token: Token(accessToken: accessToken, refreshToken: refreshToken)) UserDefaultsManager.tokenKey?.accessToken = dtoToken?.accessToken UserDefaultsManager.tokenKey?.refreshToken = dtoToken?.refreshToken - self.coordinator?.checkToken(state: .valid) + self.navigator.checkToken(state: .valid) } catch { guard let errorModel = error as? NetworkError else { return } await handleError(errorModel) @@ -98,9 +99,9 @@ private extension SplashViewController { if code == NetworkErrorCode.unauthorizedErrorCode { guard let token = UserDefaultsManager.tokenKey else { return } await logout(token: token) - self.coordinator?.checkToken(state: .expired) + self.navigator.checkToken(state: .expired) } else if code == NetworkErrorCode.unfoundUserErrorCode { - self.coordinator?.checkToken(state: .expired) + self.navigator.checkToken(state: .expired) } default: print(error) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift index e65df824..8ff01bb5 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Today/ViewControllers/TodayViewController.swift @@ -12,7 +12,7 @@ import SnapKit final class TodayViewController: UIViewController, TodayViewControllerable { - var adaptor: TodayNavigation + var navigator: TodayNavigation private let manager: TodayManager private lazy var todayNavigationBar = LHNavigationBarView(type: .today, viewController: self) @@ -25,7 +25,7 @@ final class TodayViewController: UIViewController, TodayViewControllerable { init(manager: TodayManager, adaptor: TodayNavigation) { self.manager = manager - self.adaptor = adaptor + self.navigator = adaptor super.init(nibName: nil, bundle: nil) } @@ -129,17 +129,17 @@ private extension TodayViewController { func setButtonAction() { todayNavigationBar.rightFirstBarItemAction { - self.adaptor.navigationLeftButtonTapped() + self.navigator.navigationLeftButtonTapped() } todayNavigationBar.rightSecondBarItemAction { - self.adaptor.navigationRightButtonTapped() + self.navigator.navigationRightButtonTapped() } } @objc func articleTapped(_ sender: UIButton) { guard let todayArticleID else { return } - self.adaptor.todayArticleTapped(articleID: todayArticleID) + self.navigator.todayArticleTapped(articleID: todayArticleID) } } @@ -155,7 +155,7 @@ extension TodayViewController: ViewControllerServiceable { case .fetchImageError: LHToast.show(message: "이미지패치실패", isTabBar: true) case .unAuthorizedError: - self.adaptor.checkTokenIsExpired() + self.navigator.checkTokenIsExpired() case .clientError(_, let message): LHToast.show(message: message, isTabBar: true) case .serverError: From 4724b5966ca6db2097fa7a94d191401e8ead9f86 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Tue, 17 Oct 2023 11:33:10 +0900 Subject: [PATCH 2/8] =?UTF-8?q?[REFACTOR]=20auth=20coordinator=EC=97=90=20?= =?UTF-8?q?adaptor=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 8 +- .../CompleteOnbardingViewControllerable.swift | 2 +- .../LoginViewControllerable.swift | 2 +- .../OnboardingViewControllerable.swift | 2 +- .../SplashCoordinatorImpl.swift | 2 +- ...inator.swift => AuthCoordinatorImpl.swift} | 87 +++++++++++++------ .../Factory/FactoryImpl/AuthFactoryImpl.swift | 15 ++-- .../FactoryInterface/AuthFactory.swift | 6 +- .../Scenes/Login/LoginViewController.swift | 9 +- .../CompleteOnbardingViewController.swift | 14 ++- .../OnboardingViewController.swift | 13 +-- 11 files changed, 106 insertions(+), 54 deletions(-) rename LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/{AuthCoordinator.swift => AuthCoordinatorImpl.swift} (54%) diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index d246bd20..3d95aeab 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -112,7 +112,7 @@ C003CC1D2AD917CF00AFFAAC /* AppCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC1C2AD917CF00AFFAAC /* AppCoordinator.swift */; }; C003CC1F2AD917F900AFFAAC /* SplashCoordinatorImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC1E2AD917F900AFFAAC /* SplashCoordinatorImpl.swift */; }; C003CC212AD9181600AFFAAC /* TodayCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC202AD9181600AFFAAC /* TodayCoordinator.swift */; }; - C003CC232AD9183600AFFAAC /* AuthCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC222AD9183600AFFAAC /* AuthCoordinator.swift */; }; + C003CC232AD9183600AFFAAC /* AuthCoordinatorImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC222AD9183600AFFAAC /* AuthCoordinatorImpl.swift */; }; C003CC252AD9184700AFFAAC /* TabbbarCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC242AD9184700AFFAAC /* TabbbarCoordinator.swift */; }; C003CC272AD9185A00AFFAAC /* ArticleCategoryCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC262AD9185A00AFFAAC /* ArticleCategoryCoordinator.swift */; }; C003CC292AD9186B00AFFAAC /* CurriculumCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC282AD9186B00AFFAAC /* CurriculumCoordinator.swift */; }; @@ -412,7 +412,7 @@ C003CC1C2AD917CF00AFFAAC /* AppCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppCoordinator.swift; sourceTree = ""; }; C003CC1E2AD917F900AFFAAC /* SplashCoordinatorImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashCoordinatorImpl.swift; sourceTree = ""; }; C003CC202AD9181600AFFAAC /* TodayCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayCoordinator.swift; sourceTree = ""; }; - C003CC222AD9183600AFFAAC /* AuthCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthCoordinator.swift; sourceTree = ""; }; + C003CC222AD9183600AFFAAC /* AuthCoordinatorImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthCoordinatorImpl.swift; sourceTree = ""; }; C003CC242AD9184700AFFAAC /* TabbbarCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabbbarCoordinator.swift; sourceTree = ""; }; C003CC262AD9185A00AFFAAC /* ArticleCategoryCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryCoordinator.swift; sourceTree = ""; }; C003CC282AD9186B00AFFAAC /* CurriculumCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumCoordinator.swift; sourceTree = ""; }; @@ -1443,7 +1443,7 @@ children = ( C003CC1C2AD917CF00AFFAAC /* AppCoordinator.swift */, C003CC202AD9181600AFFAAC /* TodayCoordinator.swift */, - C003CC222AD9183600AFFAAC /* AuthCoordinator.swift */, + C003CC222AD9183600AFFAAC /* AuthCoordinatorImpl.swift */, C003CC242AD9184700AFFAAC /* TabbbarCoordinator.swift */, C003CC262AD9185A00AFFAAC /* ArticleCategoryCoordinator.swift */, C003CC282AD9186B00AFFAAC /* CurriculumCoordinator.swift */, @@ -1907,7 +1907,7 @@ B57BEB6E2A6275D600D1727C /* Serviceable.swift in Sources */, D342807A2A67F12200DA1499 /* ChallengeDataResponse.swift in Sources */, B57BEB652A6134B800D1727C /* setRootViewController.swift in Sources */, - C003CC232AD9183600AFFAAC /* AuthCoordinator.swift in Sources */, + C003CC232AD9183600AFFAAC /* AuthCoordinatorImpl.swift in Sources */, C0856B892ABFDA240026D9F8 /* Badge.swift in Sources */, B5C6A2C22A5DEA1B0021BE5E /* CopyRightTableViewCell.swift in Sources */, C0856B7B2ABFC9640026D9F8 /* SplashManagerImpl.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/CompleteOnbardingViewControllerable.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/CompleteOnbardingViewControllerable.swift index e5fb2fdb..fe191a12 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/CompleteOnbardingViewControllerable.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/CompleteOnbardingViewControllerable.swift @@ -8,6 +8,6 @@ import UIKit protocol CompleteOnbardingViewControllerable where Self: UIViewController { - var coordinator: CompleteOnbardingNavigation? { get set } + var navigator: CompleteOnbardingNavigation { get set } var userData: UserOnboardingModel? { get set } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/LoginViewControllerable.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/LoginViewControllerable.swift index f686c198..2dffe0c7 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/LoginViewControllerable.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/LoginViewControllerable.swift @@ -8,5 +8,5 @@ import UIKit protocol LoginViewControllerable where Self: UIViewController { - var coordinator: LoginNavigation? { get set } + var navigator: LoginNavigation { get set } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/OnboardingViewControllerable.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/OnboardingViewControllerable.swift index a4b3b2ce..27f3c121 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/OnboardingViewControllerable.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/OnboardingViewControllerable.swift @@ -8,6 +8,6 @@ import UIKit protocol OnboardingViewControllerable where Self: UIViewController { - var coordinator: OnboardingNavigation? { get set } + var navigator: OnboardingNavigation { get set } func setKakaoAccessToken(_ token: String?) } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/SplashCoordinatorImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/SplashCoordinatorImpl.swift index 10530513..51e0451a 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/SplashCoordinatorImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/SplashCoordinatorImpl.swift @@ -39,7 +39,7 @@ final class SplashCoordinatorImpl: SplashCoordinator { } func showLoginViewController() { - let authCoordinator = AuthCoordinator(navigationController: navigationController, factory: AuthFactoryImpl()) + let authCoordinator = AuthCoordinatorImpl(navigationController: navigationController, factory: AuthFactoryImpl()) children.removeAll() authCoordinator.parentCoordinator = self children.append(authCoordinator) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinator.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinatorImpl.swift similarity index 54% rename from LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinator.swift rename to LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinatorImpl.swift index 3c832a59..21a0a6f9 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinator.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinatorImpl.swift @@ -7,7 +7,46 @@ import UIKit -final class AuthCoordinator: Coordinator { +protocol AuthCoordinator: Coordinator { + func showLoginViewController() + func showTabbarController() + func showOnboardingCompleteViewController(data: UserOnboardingModel) + func showTabbarOrOnboardingViewController(userState: UserState, kakaoToken: String?) + func pop() + func exitApplication() +} + +typealias AuthNaviation = LoginNavigation & OnboardingNavigation & CompleteOnbardingNavigation + +final class AuthAdaptor: AuthNaviation { + + let coordinator: AuthCoordinator + init(coordinator: AuthCoordinator) { + self.coordinator = coordinator + } + + func checkUserIsVerified(userState: UserState, kakaoToken: String?) { + self.coordinator.showTabbarOrOnboardingViewController(userState: userState, kakaoToken: kakaoToken) + } + + func onboardingCompleted(data: UserOnboardingModel) { + self.coordinator.showOnboardingCompleteViewController(data: data) + } + + func startButtonTapped() { + self.coordinator.showTabbarController() + } + + func checkTokenIsExpired() { + self.coordinator.exitApplication() + } + + func backButtonTapped() { + self.coordinator.pop() + } +} + +final class AuthCoordinatorImpl: AuthCoordinator { weak var parentCoordinator: Coordinator? private let factory: AuthFactory @@ -21,50 +60,48 @@ final class AuthCoordinator: Coordinator { } func start() { - showLogin() + showLoginViewController() } - func showLogin() { - let loginViewController = factory.makeLoginViewController() - loginViewController.coordinator = self + func showLoginViewController() { + let authAdaptor = AuthAdaptor(coordinator: self) + let loginViewController = factory.makeLoginViewController(navigator: authAdaptor) self.navigationController.pushViewController(loginViewController, animated: true) } -} - -extension AuthCoordinator: LoginNavigation, OnboardingNavigation, CompleteOnbardingNavigation { - func checkTokenIsExpired() { - UIApplication.shared.perform(#selector(NSXPCConnection.suspend)) - DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - exit(0) - } - } - func startButtonTapped() { + func showTabbarController() { let splashCoorinator = parentCoordinator as? SplashCoordinatorImpl splashCoorinator?.showTabbarViewContoller() } - func onboardingCompleted(data: UserOnboardingModel) { - let completeViewController = factory.makeCompleteOnbardingViewController() - completeViewController.coordinator = self + func showOnboardingCompleteViewController(data: UserOnboardingModel) { + let completeAdaptor = AuthAdaptor(coordinator: self) + let completeViewController = factory.makeCompleteOnbardingViewController(navigator: completeAdaptor) completeViewController.userData = data self.navigationController.pushViewController(completeViewController, animated: true) } - func backButtonTapped() { - self.navigationController.popViewController(animated: true) - } - - func checkUserIsVerified(userState: UserState, kakaoToken: String?) { + func showTabbarOrOnboardingViewController(userState: UserState, kakaoToken: String?) { let splashCoorinator = parentCoordinator as? SplashCoordinatorImpl switch userState { case .verified: splashCoorinator?.showTabbarViewContoller() case .nonVerified: - let onboardingViewController = factory.makeOnboardingViewController() + let onboardingAdaptor = AuthAdaptor(coordinator: self) + let onboardingViewController = factory.makeOnboardingViewController(navigator: onboardingAdaptor) onboardingViewController.setKakaoAccessToken(kakaoToken) - onboardingViewController.coordinator = self self.navigationController.pushViewController(onboardingViewController, animated: true) } } + + func pop() { + self.navigationController.popViewController(animated: true) + } + + func exitApplication() { + UIApplication.shared.perform(#selector(NSXPCConnection.suspend)) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + exit(0) + } + } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/AuthFactoryImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/AuthFactoryImpl.swift index 4e0eadf2..b14e8f1c 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/AuthFactoryImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/AuthFactoryImpl.swift @@ -8,18 +8,21 @@ import UIKit struct AuthFactoryImpl: AuthFactory { - func makeLoginViewController() -> LoginViewControllerable { - let loginViewController = LoginViewController(manager: LoginMangerImpl(authService: AuthServiceImpl(apiService: APIService()))) + + func makeLoginViewController(navigator: LoginNavigation) -> LoginViewControllerable { + let loginViewController = LoginViewController(manager: LoginMangerImpl(authService: AuthServiceImpl(apiService: APIService())), navigator: navigator) return loginViewController } - func makeCompleteOnbardingViewController() -> CompleteOnbardingViewControllerable { - let completeViewController = CompleteOnbardingViewController() + func makeCompleteOnbardingViewController(navigator: CompleteOnbardingNavigation) -> CompleteOnbardingViewControllerable { + let completeViewController = CompleteOnbardingViewController(navigator: navigator) return completeViewController } - func makeOnboardingViewController() -> OnboardingViewControllerable { - let onboardingViewController = OnboardingViewController(manager: OnboardingManagerImpl(authService: AuthServiceImpl(apiService: APIService()))) + func makeOnboardingViewController(navigator: OnboardingNavigation) -> OnboardingViewControllerable { + let onboardingViewController = OnboardingViewController(manager: OnboardingManagerImpl(authService: AuthServiceImpl(apiService: APIService())), navigator: navigator) return onboardingViewController } + + } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/AuthFactory.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/AuthFactory.swift index d80c4a18..41ef656e 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/AuthFactory.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/AuthFactory.swift @@ -8,9 +8,9 @@ import Foundation protocol AuthFactory { - func makeLoginViewController() -> LoginViewControllerable - func makeCompleteOnbardingViewController() -> CompleteOnbardingViewControllerable - func makeOnboardingViewController() -> OnboardingViewControllerable + func makeLoginViewController(navigator: LoginNavigation) -> LoginViewControllerable + func makeCompleteOnbardingViewController(navigator: CompleteOnbardingNavigation) -> CompleteOnbardingViewControllerable + func makeOnboardingViewController(navigator: OnboardingNavigation) -> OnboardingViewControllerable } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Login/LoginViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Login/LoginViewController.swift index 7f42e1a8..ab756422 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Login/LoginViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Login/LoginViewController.swift @@ -26,7 +26,7 @@ final class LoginViewController: UIViewController, LoginViewControllerable { } } - weak var coordinator: LoginNavigation? + var navigator: LoginNavigation private let manager: LoginManager @@ -42,8 +42,9 @@ final class LoginViewController: UIViewController, LoginViewControllerable { .setMarginImageWithText(for: 8) .setBackgroundColor(color: .kakao) - init(manager: LoginManager) { + init(manager: LoginManager, navigator: LoginNavigation) { self.manager = manager + self.navigator = navigator super.init(nibName: nil, bundle: nil) } @@ -73,7 +74,7 @@ extension LoginViewController: ViewControllerServiceable { print(code, message) if code == NetworkErrorCode.unfoundUserErrorCode { LHToast.show(message: "코드 잘돌아감") - self.coordinator?.checkUserIsVerified(userState: .nonVerified, kakaoToken: kakaoAccessToken) + self.navigator.checkUserIsVerified(userState: .nonVerified, kakaoToken: kakaoAccessToken) } default: LHToast.show(message: error.description) @@ -86,7 +87,7 @@ extension LoginViewController { Task { do { try await manager.login(type: .kakao, kakaoToken: kakaoToken) - self.coordinator?.checkUserIsVerified(userState: .verified, kakaoToken: kakaoToken) + self.navigator.checkUserIsVerified(userState: .verified, kakaoToken: kakaoToken) } catch { guard let error = error as? NetworkError else { LHToast.show(message: "넷웤에러 95") diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/CompleteOnbardingViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/CompleteOnbardingViewController.swift index 200b6af4..64d3dec0 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/CompleteOnbardingViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/CompleteOnbardingViewController.swift @@ -23,7 +23,7 @@ final class CompleteOnbardingViewController: UIViewController, CompleteOnbarding } } - weak var coordinator: CompleteOnbardingNavigation? + var navigator: CompleteOnbardingNavigation private let titleLabel = LHOnboardingTitleLabel(nil, align: .center) private let descriptionLabel = LHOnboardingDescriptionLabel("아티클 맞춤 환경이 준비되었어요.") @@ -37,6 +37,16 @@ final class CompleteOnbardingViewController: UIViewController, CompleteOnbarding return imageView }() + init(navigator: CompleteOnbardingNavigation) { + self.navigator = navigator + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + public override func viewDidLoad() { super.viewDidLoad() setUI() @@ -81,7 +91,7 @@ private extension CompleteOnbardingViewController { func setButtonAction() { startButton.addButtonAction { sender in - self.coordinator?.startButtonTapped() + self.navigator.startButtonTapped() } } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift index dcc9bf07..e314c2c8 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Onboarding/ViewControllers/OnboardingViewController.swift @@ -15,7 +15,7 @@ import SnapKit final class OnboardingViewController: UIViewController, OnboardingViewControllerable { typealias OnboardingViews = [UIViewController] - weak var coordinator: OnboardingNavigation? + var navigator: OnboardingNavigation private let manager: OnboardingManager private var fetalNickName: String? @@ -49,8 +49,9 @@ final class OnboardingViewController: UIViewController, OnboardingViewController } } - init(manager: OnboardingManager) { + init(manager: OnboardingManager, navigator: OnboardingNavigation) { self.manager = manager + self.navigator = navigator super.init(nibName: nil, bundle: nil) } @@ -132,7 +133,7 @@ private extension OnboardingViewController { } onboardingNavigationbar.backButtonAction { - self.coordinator?.backButtonTapped() + self.navigator.backButtonTapped() } } @@ -159,7 +160,7 @@ private extension OnboardingViewController { func presentLoginView() { self.navigationController?.popViewController(animated: true) - self.coordinator?.backButtonTapped() + self.navigator.backButtonTapped() } func presentOnboardingView(oldValue: OnbardingFlowType) { @@ -180,7 +181,7 @@ private extension OnboardingViewController { do { try await manager.signUp(type: .kakao, onboardingModel: passingData) hideLoading() - self.coordinator?.onboardingCompleted(data: passingData) + self.navigator.onboardingCompleted(data: passingData) } catch { guard let error = error as? NetworkError else { return } handleError(error) @@ -243,7 +244,7 @@ extension OnboardingViewController: ViewControllerServiceable { case .fetchImageError: LHToast.show(message: "이미지패치에러") case .unAuthorizedError: - coordinator?.checkTokenIsExpired() + navigator.checkTokenIsExpired() case .clientError(_, let message): LHToast.show(message: message) case .serverError: From 61f8bc34fd2429460a7048d0eae4eaef1c26fc89 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Tue, 17 Oct 2023 11:35:29 +0900 Subject: [PATCH 3/8] =?UTF-8?q?[REFACTOR]=20auth=20coordinator=EC=97=90=20?= =?UTF-8?q?adaptor=20=ED=8F=B4=EB=8D=94=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 10 ++++- .../Scenes/Adaptor/AuthAdaptor.swift | 38 ++++++++++++++++++ .../AuthCoordinatorImpl.swift | 39 ------------------- .../AuthCoordinator.swift | 17 ++++++++ 4 files changed, 64 insertions(+), 40 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/AuthAdaptor.swift rename LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/{CoordinatorInterface => CoordinatorImpl}/AuthCoordinatorImpl.swift (67%) create mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinator.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 3d95aeab..ebf64674 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -163,6 +163,8 @@ C009E9FE2ADBC51400112F18 /* ArticleCategoryViewControllerable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C009E9FD2ADBC51400112F18 /* ArticleCategoryViewControllerable.swift */; }; C034EDD62ADE21BD00AD6FF3 /* SplashCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDD52ADE21BD00AD6FF3 /* SplashCoordinator.swift */; }; C034EDD82ADE21D200AD6FF3 /* SplashAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDD72ADE21D200AD6FF3 /* SplashAdaptor.swift */; }; + C034EDDA2ADE2A0E00AD6FF3 /* AuthCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDD92ADE2A0E00AD6FF3 /* AuthCoordinator.swift */; }; + C034EDDC2ADE2A2C00AD6FF3 /* AuthAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDDB2ADE2A2C00AD6FF3 /* AuthAdaptor.swift */; }; C04BE3AD2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04BE3AC2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift */; }; C04BE3AF2ADD4F7F001967B5 /* TodayAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04BE3AE2ADD4F7F001967B5 /* TodayAdaptor.swift */; }; C065F0032ADBD2270094912C /* AuthFactoryImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C065F0022ADBD2270094912C /* AuthFactoryImpl.swift */; }; @@ -463,6 +465,8 @@ C009E9FD2ADBC51400112F18 /* ArticleCategoryViewControllerable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryViewControllerable.swift; sourceTree = ""; }; C034EDD52ADE21BD00AD6FF3 /* SplashCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashCoordinator.swift; sourceTree = ""; }; C034EDD72ADE21D200AD6FF3 /* SplashAdaptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashAdaptor.swift; sourceTree = ""; }; + C034EDD92ADE2A0E00AD6FF3 /* AuthCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthCoordinator.swift; sourceTree = ""; }; + C034EDDB2ADE2A2C00AD6FF3 /* AuthAdaptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAdaptor.swift; sourceTree = ""; }; C04BE3AC2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayCoordinatorImpl.swift; sourceTree = ""; }; C04BE3AE2ADD4F7F001967B5 /* TodayAdaptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayAdaptor.swift; sourceTree = ""; }; C065F0022ADBD2270094912C /* AuthFactoryImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthFactoryImpl.swift; sourceTree = ""; }; @@ -1434,6 +1438,7 @@ children = ( C04BE3AE2ADD4F7F001967B5 /* TodayAdaptor.swift */, C034EDD72ADE21D200AD6FF3 /* SplashAdaptor.swift */, + C034EDDB2ADE2A2C00AD6FF3 /* AuthAdaptor.swift */, ); path = Adaptor; sourceTree = ""; @@ -1443,7 +1448,6 @@ children = ( C003CC1C2AD917CF00AFFAAC /* AppCoordinator.swift */, C003CC202AD9181600AFFAAC /* TodayCoordinator.swift */, - C003CC222AD9183600AFFAAC /* AuthCoordinatorImpl.swift */, C003CC242AD9184700AFFAAC /* TabbbarCoordinator.swift */, C003CC262AD9185A00AFFAAC /* ArticleCategoryCoordinator.swift */, C003CC282AD9186B00AFFAAC /* CurriculumCoordinator.swift */, @@ -1452,6 +1456,7 @@ C003CC2E2AD9189F00AFFAAC /* MypageCoordinator.swift */, C003CC302AD918AB00AFFAAC /* ArticleCoordinator.swift */, C034EDD52ADE21BD00AD6FF3 /* SplashCoordinator.swift */, + C034EDD92ADE2A0E00AD6FF3 /* AuthCoordinator.swift */, ); path = CoordinatorInterface; sourceTree = ""; @@ -1459,6 +1464,7 @@ C04BE3AB2ADD4F34001967B5 /* CoordinatorImpl */ = { isa = PBXGroup; children = ( + C003CC222AD9183600AFFAAC /* AuthCoordinatorImpl.swift */, C04BE3AC2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift */, C003CC1E2AD917F900AFFAAC /* SplashCoordinatorImpl.swift */, ); @@ -1880,6 +1886,7 @@ C0DF034F2A5A9B9C0037F740 /* MyPageViewController.swift in Sources */, C0DF03A92A5CF0460037F740 /* UserOnboardingModel.swift in Sources */, C0B15E212AC0450E0058D56B /* ArticleListTableView.swift in Sources */, + C034EDDA2ADE2A0E00AD6FF3 /* AuthCoordinator.swift in Sources */, C065F0092ADBD2640094912C /* TodayViewControllerable.swift in Sources */, B5C6A2B42A5DB11A0021BE5E /* ThumnailTableViewCell.swift in Sources */, B59BFD412ADBBFB2005D2D81 /* MyPageFactory.swift in Sources */, @@ -1958,6 +1965,7 @@ C0DF03352A5A93530037F740 /* UIControl+.swift in Sources */, C003CC592ADA4FFF00AFFAAC /* TokenState.swift in Sources */, C0F029E22A5FAE2700E0D185 /* LHOnboardingErrorLabel.swift in Sources */, + C034EDDC2ADE2A2C00AD6FF3 /* AuthAdaptor.swift in Sources */, B57BEB702A6275F500D1727C /* ViewControllerServiceable.swift in Sources */, C0DF032F2A5A92170037F740 /* NameSpace.swift in Sources */, C0856B6D2ABFBD840026D9F8 /* BookmarkServiceImpl.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/AuthAdaptor.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/AuthAdaptor.swift new file mode 100644 index 00000000..73422c1f --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/AuthAdaptor.swift @@ -0,0 +1,38 @@ +// +// AuthAdaptor.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/10/17. +// + +import Foundation + +typealias AuthNaviation = LoginNavigation & OnboardingNavigation & CompleteOnbardingNavigation + +final class AuthAdaptor: AuthNaviation { + + let coordinator: AuthCoordinator + init(coordinator: AuthCoordinator) { + self.coordinator = coordinator + } + + func checkUserIsVerified(userState: UserState, kakaoToken: String?) { + self.coordinator.showTabbarOrOnboardingViewController(userState: userState, kakaoToken: kakaoToken) + } + + func onboardingCompleted(data: UserOnboardingModel) { + self.coordinator.showOnboardingCompleteViewController(data: data) + } + + func startButtonTapped() { + self.coordinator.showTabbarController() + } + + func checkTokenIsExpired() { + self.coordinator.exitApplication() + } + + func backButtonTapped() { + self.coordinator.pop() + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinatorImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/AuthCoordinatorImpl.swift similarity index 67% rename from LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinatorImpl.swift rename to LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/AuthCoordinatorImpl.swift index 21a0a6f9..6f5bcb85 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinatorImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/AuthCoordinatorImpl.swift @@ -7,45 +7,6 @@ import UIKit -protocol AuthCoordinator: Coordinator { - func showLoginViewController() - func showTabbarController() - func showOnboardingCompleteViewController(data: UserOnboardingModel) - func showTabbarOrOnboardingViewController(userState: UserState, kakaoToken: String?) - func pop() - func exitApplication() -} - -typealias AuthNaviation = LoginNavigation & OnboardingNavigation & CompleteOnbardingNavigation - -final class AuthAdaptor: AuthNaviation { - - let coordinator: AuthCoordinator - init(coordinator: AuthCoordinator) { - self.coordinator = coordinator - } - - func checkUserIsVerified(userState: UserState, kakaoToken: String?) { - self.coordinator.showTabbarOrOnboardingViewController(userState: userState, kakaoToken: kakaoToken) - } - - func onboardingCompleted(data: UserOnboardingModel) { - self.coordinator.showOnboardingCompleteViewController(data: data) - } - - func startButtonTapped() { - self.coordinator.showTabbarController() - } - - func checkTokenIsExpired() { - self.coordinator.exitApplication() - } - - func backButtonTapped() { - self.coordinator.pop() - } -} - final class AuthCoordinatorImpl: AuthCoordinator { weak var parentCoordinator: Coordinator? private let factory: AuthFactory diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinator.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinator.swift new file mode 100644 index 00000000..7f791f12 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/AuthCoordinator.swift @@ -0,0 +1,17 @@ +// +// AuthCoordinator.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/10/17. +// + +import Foundation + +protocol AuthCoordinator: Coordinator { + func showLoginViewController() + func showTabbarController() + func showOnboardingCompleteViewController(data: UserOnboardingModel) + func showTabbarOrOnboardingViewController(userState: UserState, kakaoToken: String?) + func pop() + func exitApplication() +} From 76b57584f694f59c4d656ed314af2978654e7715 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Tue, 17 Oct 2023 13:31:37 +0900 Subject: [PATCH 4/8] =?UTF-8?q?[REFACTOR]=20article=20category=EC=97=90=20?= =?UTF-8?q?adaptor=20pattern=EB=8F=84=EC=9E=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 24 ++++-- .../Adaptor/ArticleCategoryAdaptor.swift | 40 +++++++++ .../ArticleCategoryViewController.swift | 17 +++- .../ArticleListByCategoryViewController.swift | 16 ++-- .../ArticleCategoryViewControllerable.swift | 2 +- ...icleListByCategoryViewControllerable.swift | 13 +++ .../ArticleCategoryCoordinatorImpl.swift | 79 ++++++++++++++++++ .../ArticleCategoryCoordinator.swift | 82 +++---------------- .../TabbbarCoordinator.swift | 9 +- .../ArticleCategortFactoryImpl.swift | 10 +-- .../ArticleCategortFactory.swift | 4 +- 11 files changed, 190 insertions(+), 106 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/ArticleCategoryAdaptor.swift create mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/ArticleListByCategoryViewControllerable.swift create mode 100644 LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/ArticleCategoryCoordinatorImpl.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index ebf64674..c9d38f56 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -41,7 +41,6 @@ B532E8342A5525C600F0DB19 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B532E8332A5525C600F0DB19 /* SceneDelegate.swift */; }; B532E83B2A5525C700F0DB19 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B532E83A2A5525C700F0DB19 /* Assets.xcassets */; }; B532E83E2A5525C700F0DB19 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B532E83C2A5525C700F0DB19 /* LaunchScreen.storyboard */; }; - B532E8492A5525C800F0DB19 /* LionHeart_iOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B532E8482A5525C800F0DB19 /* LionHeart_iOSTests.swift */; }; B532E8532A5525C800F0DB19 /* LionHeart_iOSUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B532E8522A5525C800F0DB19 /* LionHeart_iOSUITests.swift */; }; B532E8552A5525C800F0DB19 /* LionHeart_iOSUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B532E8542A5525C800F0DB19 /* LionHeart_iOSUITestsLaunchTests.swift */; }; B532E8632A5529B000F0DB19 /* HTTPHeaderField.swift in Sources */ = {isa = PBXBuildFile; fileRef = B532E8622A5529B000F0DB19 /* HTTPHeaderField.swift */; }; @@ -114,7 +113,7 @@ C003CC212AD9181600AFFAAC /* TodayCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC202AD9181600AFFAAC /* TodayCoordinator.swift */; }; C003CC232AD9183600AFFAAC /* AuthCoordinatorImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC222AD9183600AFFAAC /* AuthCoordinatorImpl.swift */; }; C003CC252AD9184700AFFAAC /* TabbbarCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC242AD9184700AFFAAC /* TabbbarCoordinator.swift */; }; - C003CC272AD9185A00AFFAAC /* ArticleCategoryCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC262AD9185A00AFFAAC /* ArticleCategoryCoordinator.swift */; }; + C003CC272AD9185A00AFFAAC /* ArticleCategoryCoordinatorImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC262AD9185A00AFFAAC /* ArticleCategoryCoordinatorImpl.swift */; }; C003CC292AD9186B00AFFAAC /* CurriculumCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC282AD9186B00AFFAAC /* CurriculumCoordinator.swift */; }; C003CC2B2AD9187B00AFFAAC /* ChallengeCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC2A2AD9187B00AFFAAC /* ChallengeCoordinator.swift */; }; C003CC2D2AD9189100AFFAAC /* BookmarkCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CC2C2AD9189100AFFAAC /* BookmarkCoordinator.swift */; }; @@ -165,6 +164,10 @@ C034EDD82ADE21D200AD6FF3 /* SplashAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDD72ADE21D200AD6FF3 /* SplashAdaptor.swift */; }; C034EDDA2ADE2A0E00AD6FF3 /* AuthCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDD92ADE2A0E00AD6FF3 /* AuthCoordinator.swift */; }; C034EDDC2ADE2A2C00AD6FF3 /* AuthAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDDB2ADE2A2C00AD6FF3 /* AuthAdaptor.swift */; }; + C034EDDE2ADE2F3500AD6FF3 /* ArticleListByCategoryViewControllerable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDDD2ADE2F3500AD6FF3 /* ArticleListByCategoryViewControllerable.swift */; }; + C034EDE02ADE3A4A00AD6FF3 /* LionHeart_iOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B532E8482A5525C800F0DB19 /* LionHeart_iOSTests.swift */; }; + C034EE1E2ADE44E200AD6FF3 /* ArticleCategoryAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EE1D2ADE44E200AD6FF3 /* ArticleCategoryAdaptor.swift */; }; + C034EE202ADE450600AD6FF3 /* ArticleCategoryCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EE1F2ADE450600AD6FF3 /* ArticleCategoryCoordinator.swift */; }; C04BE3AD2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04BE3AC2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift */; }; C04BE3AF2ADD4F7F001967B5 /* TodayAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04BE3AE2ADD4F7F001967B5 /* TodayAdaptor.swift */; }; C065F0032ADBD2270094912C /* AuthFactoryImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C065F0022ADBD2270094912C /* AuthFactoryImpl.swift */; }; @@ -416,7 +419,7 @@ C003CC202AD9181600AFFAAC /* TodayCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayCoordinator.swift; sourceTree = ""; }; C003CC222AD9183600AFFAAC /* AuthCoordinatorImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthCoordinatorImpl.swift; sourceTree = ""; }; C003CC242AD9184700AFFAAC /* TabbbarCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabbbarCoordinator.swift; sourceTree = ""; }; - C003CC262AD9185A00AFFAAC /* ArticleCategoryCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryCoordinator.swift; sourceTree = ""; }; + C003CC262AD9185A00AFFAAC /* ArticleCategoryCoordinatorImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryCoordinatorImpl.swift; sourceTree = ""; }; C003CC282AD9186B00AFFAAC /* CurriculumCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumCoordinator.swift; sourceTree = ""; }; C003CC2A2AD9187B00AFFAAC /* ChallengeCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeCoordinator.swift; sourceTree = ""; }; C003CC2C2AD9189100AFFAAC /* BookmarkCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkCoordinator.swift; sourceTree = ""; }; @@ -467,6 +470,9 @@ C034EDD72ADE21D200AD6FF3 /* SplashAdaptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashAdaptor.swift; sourceTree = ""; }; C034EDD92ADE2A0E00AD6FF3 /* AuthCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthCoordinator.swift; sourceTree = ""; }; C034EDDB2ADE2A2C00AD6FF3 /* AuthAdaptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAdaptor.swift; sourceTree = ""; }; + C034EDDD2ADE2F3500AD6FF3 /* ArticleListByCategoryViewControllerable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListByCategoryViewControllerable.swift; sourceTree = ""; }; + C034EE1D2ADE44E200AD6FF3 /* ArticleCategoryAdaptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryAdaptor.swift; sourceTree = ""; }; + C034EE1F2ADE450600AD6FF3 /* ArticleCategoryCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryCoordinator.swift; sourceTree = ""; }; C04BE3AC2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayCoordinatorImpl.swift; sourceTree = ""; }; C04BE3AE2ADD4F7F001967B5 /* TodayAdaptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayAdaptor.swift; sourceTree = ""; }; C065F0022ADBD2270094912C /* AuthFactoryImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthFactoryImpl.swift; sourceTree = ""; }; @@ -1280,6 +1286,7 @@ C065F00C2ADBD29A0094912C /* OnboardingViewControllerable.swift */, C065F00E2ADBD2AD0094912C /* CompleteOnbardingViewControllerable.swift */, C065F0102ADBD2C40094912C /* SplashViewControllerable.swift */, + C034EDDD2ADE2F3500AD6FF3 /* ArticleListByCategoryViewControllerable.swift */, ); path = ControllerableInterface; sourceTree = ""; @@ -1439,6 +1446,7 @@ C04BE3AE2ADD4F7F001967B5 /* TodayAdaptor.swift */, C034EDD72ADE21D200AD6FF3 /* SplashAdaptor.swift */, C034EDDB2ADE2A2C00AD6FF3 /* AuthAdaptor.swift */, + C034EE1D2ADE44E200AD6FF3 /* ArticleCategoryAdaptor.swift */, ); path = Adaptor; sourceTree = ""; @@ -1449,7 +1457,6 @@ C003CC1C2AD917CF00AFFAAC /* AppCoordinator.swift */, C003CC202AD9181600AFFAAC /* TodayCoordinator.swift */, C003CC242AD9184700AFFAAC /* TabbbarCoordinator.swift */, - C003CC262AD9185A00AFFAAC /* ArticleCategoryCoordinator.swift */, C003CC282AD9186B00AFFAAC /* CurriculumCoordinator.swift */, C003CC2A2AD9187B00AFFAAC /* ChallengeCoordinator.swift */, C003CC2C2AD9189100AFFAAC /* BookmarkCoordinator.swift */, @@ -1457,6 +1464,7 @@ C003CC302AD918AB00AFFAAC /* ArticleCoordinator.swift */, C034EDD52ADE21BD00AD6FF3 /* SplashCoordinator.swift */, C034EDD92ADE2A0E00AD6FF3 /* AuthCoordinator.swift */, + C034EE1F2ADE450600AD6FF3 /* ArticleCategoryCoordinator.swift */, ); path = CoordinatorInterface; sourceTree = ""; @@ -1467,6 +1475,7 @@ C003CC222AD9183600AFFAAC /* AuthCoordinatorImpl.swift */, C04BE3AC2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift */, C003CC1E2AD917F900AFFAAC /* SplashCoordinatorImpl.swift */, + C003CC262AD9185A00AFFAAC /* ArticleCategoryCoordinatorImpl.swift */, ); path = CoordinatorImpl; sourceTree = ""; @@ -1938,6 +1947,7 @@ F4DB30BC2A61691F00413EB9 /* CurriculumArticleByWeekRowZeroTableViewCell.swift in Sources */, C009E9FC2ADBC4FD00112F18 /* ChallengeViewControllerable.swift in Sources */, C0DF039A2A5B908E0037F740 /* CGColor+.swift in Sources */, + C034EE1E2ADE44E200AD6FF3 /* ArticleCategoryAdaptor.swift in Sources */, C003CC662ADA518E00AFFAAC /* ArticleDetailManager.swift in Sources */, 4AD216402A69AC1E00C9F2F2 /* MyPageResponse.swift in Sources */, C003CC1F2AD917F900AFFAAC /* SplashCoordinatorImpl.swift in Sources */, @@ -1990,7 +2000,7 @@ C0856B6B2ABFBC9D0026D9F8 /* ArticleDetailManagerImpl.swift in Sources */, C0B15E272AC104D50058D56B /* LHImageButton.swift in Sources */, B5C6A2B62A5DD5FE0021BE5E /* TitleTableViewCell.swift in Sources */, - C003CC272AD9185A00AFFAAC /* ArticleCategoryCoordinator.swift in Sources */, + C003CC272AD9185A00AFFAAC /* ArticleCategoryCoordinatorImpl.swift in Sources */, C0DF03962A5B8FB10037F740 /* Palette.swift in Sources */, C003CC682ADA51A700AFFAAC /* ArticleListByCategoryManager.swift in Sources */, C003CC6A2ADA51C000AFFAAC /* MyPageManager.swift in Sources */, @@ -2018,6 +2028,7 @@ C003CC3F2ADA4EC300AFFAAC /* CurriculumNavigation.swift in Sources */, C009E9FA2ADBC4DE00112F18 /* BookmarkViewControllerable.swift in Sources */, F435E04C2A5DA6A40098E691 /* CurriculumUserInfoView.swift in Sources */, + C034EDDE2ADE2F3500AD6FF3 /* ArticleListByCategoryViewControllerable.swift in Sources */, C003CC452ADA4F1E00AFFAAC /* ArticleListByCategoryNavigation.swift in Sources */, 4A8980C72A6146DA00746C58 /* MyPageCustomerServiceCollectionViewCell.swift in Sources */, C0856B752ABFC4CB0026D9F8 /* MyPageManagerImpl.swift in Sources */, @@ -2108,6 +2119,7 @@ D3AB54C12A62CE3F0017BF53 /* ChallengeDayCheckCollectionViewCollectionViewCell.swift in Sources */, B5C6A2B22A5DB0B10021BE5E /* ArticleDetailTableView.swift in Sources */, C003CC4F2ADA4F8D00AFFAAC /* OnboardingNavigation.swift in Sources */, + C034EE202ADE450600AD6FF3 /* ArticleCategoryCoordinator.swift in Sources */, B59892E12A5AF39300CE1FEB /* LHNavigationBarView.swift in Sources */, C0F029E62A5FB9E000E0D185 /* ContainerView.swift in Sources */, C0856B712ABFC0FB0026D9F8 /* ChallengeManagerImpl.swift in Sources */, @@ -2123,7 +2135,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - B532E8492A5525C800F0DB19 /* LionHeart_iOSTests.swift in Sources */, + C034EDE02ADE3A4A00AD6FF3 /* LionHeart_iOSTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/ArticleCategoryAdaptor.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/ArticleCategoryAdaptor.swift new file mode 100644 index 00000000..a99aa75a --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/ArticleCategoryAdaptor.swift @@ -0,0 +1,40 @@ +// +// ArticleCategoryAdaptor.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/10/17. +// + +import Foundation + +final class ArticleCategoryAdaptor: ArticleCategoryNavigation, ArticleListByCategoryNavigation { + + let coordinator: ArticleCategoryCoordinator + init(coordinator: ArticleCategoryCoordinator) { + self.coordinator = coordinator + } + + func articleListCellTapped(categoryName: String) { + self.coordinator.showArticleListbyCategoryViewController(categoryName: categoryName) + } + + func articleListByCategoryCellTapped(articleID: Int) { + self.coordinator.showArticleDetailViewController(articleID: articleID) + } + + func checkTokenIsExpired() { + self.coordinator.exitApplication() + } + + func navigationRightButtonTapped() { + self.coordinator.showMypageViewController() + } + + func navigationLeftButtonTapped() { + self.coordinator.showBookmarkViewController() + } + + func backButtonTapped() { + self.coordinator.pop() + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/ViewControllers/ArticleCategoryViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/ViewControllers/ArticleCategoryViewController.swift index 1bb57677..2cad7d4b 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/ViewControllers/ArticleCategoryViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleCategory/ViewControllers/ArticleCategoryViewController.swift @@ -12,7 +12,7 @@ import SnapKit final class ArticleCategoryViewController: UIViewController, ArticleCategoryViewControllerable { - weak var coordinator: ArticleCategoryNavigation? + var navigator: ArticleCategoryNavigation private lazy var navigationBar = LHNavigationBarView(type: .explore, viewController: self) private lazy var titleLabel = LHLabel(type: .head2, color: .white, lines: 2, basicText: "카테고리별\n아티클 모아보기") @@ -31,6 +31,15 @@ final class ArticleCategoryViewController: UIViewController, ArticleCategoryView setDelegate() setCollectionView() } + + init(navigator: ArticleCategoryNavigation) { + self.navigator = navigator + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } } private extension ArticleCategoryViewController { @@ -69,11 +78,11 @@ private extension ArticleCategoryViewController { func setAddTarget() { navigationBar.rightFirstBarItemAction { - self.coordinator?.navigationLeftButtonTapped() + self.navigator.navigationLeftButtonTapped() } navigationBar.rightSecondBarItemAction { - self.coordinator?.navigationRightButtonTapped() + self.navigator.navigationRightButtonTapped() } } @@ -108,7 +117,7 @@ extension ArticleCategoryViewController: UICollectionViewDataSource { } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - coordinator?.articleListCellTapped(categoryName: dummyCase[indexPath.item].categoryString) + navigator.articleListCellTapped(categoryName: dummyCase[indexPath.item].categoryString) } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift index 65b71eec..137669e9 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Article/ArticleListByCategory/ViewControllers/ArticleListByCategoryViewController.swift @@ -10,14 +10,9 @@ import UIKit import SnapKit -protocol ArticleListByCategoryViewControllerable where Self: UIViewController { - var coordinator: ArticleListByCategoryNavigation? { get set } - var categoryString: String? { get set } -} - final class ArticleListByCategoryViewController: UIViewController, ArticleListByCategoryViewControllerable { - weak var coordinator: ArticleListByCategoryNavigation? + var navigator: ArticleListByCategoryNavigation private let manager: ArticleListByCategoryManager private lazy var navigationBar = LHNavigationBarView(type: .exploreEachCategory, viewController: self) @@ -30,8 +25,9 @@ final class ArticleListByCategoryViewController: UIViewController, ArticleListBy } } - init(manager: ArticleListByCategoryManager) { + init(manager: ArticleListByCategoryManager, navigator: ArticleListByCategoryNavigation) { self.manager = manager + self.navigator = navigator super.init(nibName: nil, bundle: nil) } @@ -99,7 +95,7 @@ private extension ArticleListByCategoryViewController { func setAddTarget() { navigationBar.backButtonAction { - self.coordinator?.backButtonTapped() + self.navigator.backButtonTapped() } } } @@ -116,7 +112,7 @@ extension ArticleListByCategoryViewController: ViewControllerServiceable { case .fetchImageError: LHToast.show(message: "Image Error") case .unAuthorizedError: - coordinator?.checkTokenIsExpired() + navigator.checkTokenIsExpired() case .clientError(_, let message): LHToast.show(message: message) case .serverError: @@ -152,6 +148,6 @@ extension ArticleListByCategoryViewController: UITableViewDataSource { extension ArticleListByCategoryViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - self.coordinator?.articleListByCategoryCellTapped(articleID: articleListData[indexPath.row].articleId) + self.navigator.articleListByCategoryCellTapped(articleID: articleListData[indexPath.row].articleId) } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/ArticleCategoryViewControllerable.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/ArticleCategoryViewControllerable.swift index af08d7ce..92d9dec8 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/ArticleCategoryViewControllerable.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/ArticleCategoryViewControllerable.swift @@ -8,5 +8,5 @@ import UIKit protocol ArticleCategoryViewControllerable where Self: UIViewController { - var coordinator: ArticleCategoryNavigation? {get set} + var navigator: ArticleCategoryNavigation {get set} } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/ArticleListByCategoryViewControllerable.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/ArticleListByCategoryViewControllerable.swift new file mode 100644 index 00000000..544148be --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/ControllerableInterface/ArticleListByCategoryViewControllerable.swift @@ -0,0 +1,13 @@ +// +// ArticleListByCategoryViewControllerable.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/10/17. +// + +import UIKit + +protocol ArticleListByCategoryViewControllerable where Self: UIViewController { + var navigator: ArticleListByCategoryNavigation { get set } + var categoryString: String? { get set } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/ArticleCategoryCoordinatorImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/ArticleCategoryCoordinatorImpl.swift new file mode 100644 index 00000000..0aefffbf --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/ArticleCategoryCoordinatorImpl.swift @@ -0,0 +1,79 @@ +// +// ArticleCategoryCoordinator.swift +// LionHeart-iOS +// +// Created by uiskim on 2023/10/13. +// + +import UIKit + +final class ArticleCategoryCoordinatorImpl: ArticleCategoryCoordinator { + + weak var parentCoordinator: Coordinator? + + private let factory: ArticleCategortFactory + + var children: [Coordinator] = [] + + var navigationController: UINavigationController + + init(navigationController: UINavigationController, factory: ArticleCategortFactory) { + self.navigationController = navigationController + self.factory = factory + } + + func start() { + showArticleCategoryViewController() + } + + func showArticleCategoryViewController() { + let articleCategoryAdaptor = ArticleCategoryAdaptor(coordinator: self) + let articleCategoryViewController = factory.makeArticleCategoryViewController(navigator: articleCategoryAdaptor) + self.navigationController.pushViewController(articleCategoryViewController, animated: true) + } + + func showArticleDetailViewController(articleID: Int) { + let articleCoordinator = ArticleCoordinator( + navigationController: navigationController, + factory: ArticleFactoryImpl(), + articleId: articleID + ) + articleCoordinator.parentCoordinator = self + children.append(articleCoordinator) + articleCoordinator.start() + } + + func showArticleListbyCategoryViewController(categoryName: String) { + let articleListbyCategoryAdaptor = ArticleCategoryAdaptor(coordinator: self) + let articleListbyCategoryViewController = factory.makeArticleListByCategoryViewController(navigator: articleListbyCategoryAdaptor) + articleListbyCategoryViewController.categoryString = categoryName + self.navigationController.pushViewController(articleListbyCategoryViewController, animated: true) + } + + func showBookmarkViewController() { + let bookmarkFactory = BookmarkFactoryImpl() + let bookmarkCoordinator = BookmarkCoordinator(navigationController: navigationController, factory: bookmarkFactory) + bookmarkCoordinator.start() + children.append(bookmarkCoordinator) + } + + func showMypageViewController() { + let mypageCoordinator = MypageCoordinator( + navigationController: navigationController, + factory: MyPageFactoryImpl() + ) + mypageCoordinator.start() + children.append(mypageCoordinator) + } + + func pop() { + self.navigationController.popViewController(animated: true) + } + + func exitApplication() { + UIApplication.shared.perform(#selector(NSXPCConnection.suspend)) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + exit(0) + } + } +} diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/ArticleCategoryCoordinator.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/ArticleCategoryCoordinator.swift index 2d746e56..0c81d8a3 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/ArticleCategoryCoordinator.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/ArticleCategoryCoordinator.swift @@ -2,79 +2,17 @@ // ArticleCategoryCoordinator.swift // LionHeart-iOS // -// Created by uiskim on 2023/10/13. +// Created by uiskim on 2023/10/17. // -import UIKit +import Foundation -final class ArticleCategoryCoordinator: Coordinator { - weak var parentCoordinator: Coordinator? - - private let factory: ArticleCategortFactory - - var children: [Coordinator] = [] - - var navigationController: UINavigationController - - init(navigationController: UINavigationController, factory: ArticleCategortFactory) { - self.navigationController = navigationController - self.factory = factory - } - - func start() { - showArticleCategoryViewController() - } - - func showArticleCategoryViewController() { - let articleCategoryViewController = factory.makeArticleCategoryViewController() - articleCategoryViewController.coordinator = self - self.navigationController.pushViewController(articleCategoryViewController, animated: true) - } -} - -extension ArticleCategoryCoordinator: ArticleCategoryNavigation, ArticleListByCategoryNavigation { - func checkTokenIsExpired() { - UIApplication.shared.perform(#selector(NSXPCConnection.suspend)) - DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - exit(0) - } - } - - func articleListByCategoryCellTapped(articleID: Int) { - let articleCoordinator = ArticleCoordinator( - navigationController: navigationController, - factory: ArticleFactoryImpl(), - articleId: articleID - ) - articleCoordinator.parentCoordinator = self - children.append(articleCoordinator) - articleCoordinator.start() - } - - func backButtonTapped() { - self.navigationController.popViewController(animated: true) - } - - func articleListCellTapped(categoryName: String) { - let articleListbyCategoryViewController = factory.makeArticleListByCategoryViewController() - articleListbyCategoryViewController.categoryString = categoryName - articleListbyCategoryViewController.coordinator = self - self.navigationController.pushViewController(articleListbyCategoryViewController, animated: true) - } - - func navigationRightButtonTapped() { - let mypageCoordinator = MypageCoordinator( - navigationController: navigationController, - factory: MyPageFactoryImpl() - ) - mypageCoordinator.start() - children.append(mypageCoordinator) - } - - func navigationLeftButtonTapped() { - let bookmarkFactory = BookmarkFactoryImpl() - let bookmarkCoordinator = BookmarkCoordinator(navigationController: navigationController, factory: bookmarkFactory) - bookmarkCoordinator.start() - children.append(bookmarkCoordinator) - } +protocol ArticleCategoryCoordinator: Coordinator { + func showArticleCategoryViewController() + func exitApplication() + func showArticleDetailViewController(articleID: Int) + func showArticleListbyCategoryViewController(categoryName: String) + func showBookmarkViewController() + func showMypageViewController() + func pop() } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/TabbbarCoordinator.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/TabbbarCoordinator.swift index 065a8c48..94a98638 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/TabbbarCoordinator.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/TabbbarCoordinator.swift @@ -19,10 +19,10 @@ final class TabbarCoordinator: Coordinator { } func start() { - showTabbar() + showTabbarController() } - func showTabbar() { + func showTabbarController() { let tabbarController = TabBarViewController() let todayNavigationController = UINavigationController() @@ -31,7 +31,7 @@ final class TabbarCoordinator: Coordinator { todayNavigationController.tabBarItem = UITabBarItem(title: "투데이", image: .assetImage(.home), tag: 0) let articleCategoryNavigationController = UINavigationController() - let articleCategoryCoordinator = ArticleCategoryCoordinator(navigationController: articleCategoryNavigationController, factory: ArticleCategortFactoryImpl()) + let articleCategoryCoordinator = ArticleCategoryCoordinatorImpl(navigationController: articleCategoryNavigationController, factory: ArticleCategortFactoryImpl()) articleCategoryCoordinator.parentCoordinator = parentCoordinator articleCategoryNavigationController.tabBarItem = UITabBarItem(title: "탐색", image: .assetImage(.search), tag: 1) @@ -60,7 +60,4 @@ final class TabbarCoordinator: Coordinator { curriculumCoordinator.start() challengeCoordinator.start() } - - - } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/ArticleCategortFactoryImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/ArticleCategortFactoryImpl.swift index 4ca9211a..b0a871a8 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/ArticleCategortFactoryImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/ArticleCategortFactoryImpl.swift @@ -8,12 +8,12 @@ import Foundation struct ArticleCategortFactoryImpl: ArticleCategortFactory { - func makeArticleCategoryViewController() -> ArticleCategoryViewControllerable { - return ArticleCategoryViewController() + func makeArticleListByCategoryViewController(navigator: ArticleListByCategoryNavigation) -> ArticleListByCategoryViewControllerable { + return ArticleListByCategoryViewController(manager: ArticleListByCategoryMangerImpl(articleService: ArticleServiceImpl(apiService: APIService()), bookmarkService: BookmarkServiceImpl(apiService: APIService())), navigator: navigator) } - func makeArticleListByCategoryViewController() -> ArticleListByCategoryViewControllerable { - let articleListbyCategoryViewController = ArticleListByCategoryViewController(manager: ArticleListByCategoryMangerImpl(articleService: ArticleServiceImpl(apiService: APIService()), bookmarkService: BookmarkServiceImpl(apiService: APIService()))) - return articleListbyCategoryViewController + func makeArticleCategoryViewController(navigator: ArticleCategoryNavigation) -> ArticleCategoryViewControllerable { + return ArticleCategoryViewController(navigator: navigator) } + } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/ArticleCategortFactory.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/ArticleCategortFactory.swift index 0779d07f..1d4c7bb2 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/ArticleCategortFactory.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/ArticleCategortFactory.swift @@ -8,6 +8,6 @@ import Foundation protocol ArticleCategortFactory { - func makeArticleCategoryViewController() -> ArticleCategoryViewControllerable - func makeArticleListByCategoryViewController() -> ArticleListByCategoryViewControllerable + func makeArticleCategoryViewController(navigator: ArticleCategoryNavigation) -> ArticleCategoryViewControllerable + func makeArticleListByCategoryViewController(navigator: ArticleListByCategoryNavigation) -> ArticleListByCategoryViewControllerable } From 060952de4f619edc5c0d9ad1e4493ac70cddbf57 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Thu, 19 Oct 2023 16:58:32 +0900 Subject: [PATCH 5/8] =?UTF-8?q?[REFACTOR]=20AuthCoordinator=EC=97=90?= =?UTF-8?q?=EC=84=9C=20Adator=EC=83=9D=EC=84=B1=EB=B6=84=EB=A6=AC(#156)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Adaptor/AuthAdaptor.swift | 4 ++-- .../CoordinatorImpl/AuthCoordinatorImpl.swift | 9 +++------ .../CoordinatorInterface/MypageCoordinator.swift | 7 +++++++ .../Factory/FactoryImpl/AuthFactoryImpl.swift | 15 +++++++++------ .../Factory/FactoryInterface/AuthFactory.swift | 7 ++++--- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/AuthAdaptor.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/AuthAdaptor.swift index 73422c1f..3183ee28 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/AuthAdaptor.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/AuthAdaptor.swift @@ -7,9 +7,9 @@ import Foundation -typealias AuthNaviation = LoginNavigation & OnboardingNavigation & CompleteOnbardingNavigation +typealias EntireAuthNaviation = LoginNavigation & OnboardingNavigation & CompleteOnbardingNavigation -final class AuthAdaptor: AuthNaviation { +final class AuthAdaptor: EntireAuthNaviation { let coordinator: AuthCoordinator init(coordinator: AuthCoordinator) { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/AuthCoordinatorImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/AuthCoordinatorImpl.swift index 6f5bcb85..bfada5d7 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/AuthCoordinatorImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/AuthCoordinatorImpl.swift @@ -25,8 +25,7 @@ final class AuthCoordinatorImpl: AuthCoordinator { } func showLoginViewController() { - let authAdaptor = AuthAdaptor(coordinator: self) - let loginViewController = factory.makeLoginViewController(navigator: authAdaptor) + let loginViewController = factory.makeLoginViewController(coordinator: self) self.navigationController.pushViewController(loginViewController, animated: true) } @@ -36,8 +35,7 @@ final class AuthCoordinatorImpl: AuthCoordinator { } func showOnboardingCompleteViewController(data: UserOnboardingModel) { - let completeAdaptor = AuthAdaptor(coordinator: self) - let completeViewController = factory.makeCompleteOnbardingViewController(navigator: completeAdaptor) + let completeViewController = factory.makeCompleteOnbardingViewController(coordinator: self) completeViewController.userData = data self.navigationController.pushViewController(completeViewController, animated: true) } @@ -48,8 +46,7 @@ final class AuthCoordinatorImpl: AuthCoordinator { case .verified: splashCoorinator?.showTabbarViewContoller() case .nonVerified: - let onboardingAdaptor = AuthAdaptor(coordinator: self) - let onboardingViewController = factory.makeOnboardingViewController(navigator: onboardingAdaptor) + let onboardingViewController = factory.makeOnboardingViewController(coordinator: self) onboardingViewController.setKakaoAccessToken(kakaoToken) self.navigationController.pushViewController(onboardingViewController, animated: true) } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/MypageCoordinator.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/MypageCoordinator.swift index 74a2398f..185b5fd9 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/MypageCoordinator.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorInterface/MypageCoordinator.swift @@ -30,6 +30,13 @@ final class MypageCoordinator: Coordinator { myPageViewController.coordinator = self self.navigationController.pushViewController(myPageViewController, animated: true) } + func dismiss() { + + } + + func pop() { + + } } extension MypageCoordinator: MyPageNavigation { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/AuthFactoryImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/AuthFactoryImpl.swift index b14e8f1c..82e2eac3 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/AuthFactoryImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/AuthFactoryImpl.swift @@ -8,19 +8,22 @@ import UIKit struct AuthFactoryImpl: AuthFactory { + func makeAuthAdaptor(coordinator: AuthCoordinator) -> EntireAuthNaviation { + return AuthAdaptor(coordinator: coordinator) + } - func makeLoginViewController(navigator: LoginNavigation) -> LoginViewControllerable { - let loginViewController = LoginViewController(manager: LoginMangerImpl(authService: AuthServiceImpl(apiService: APIService())), navigator: navigator) + func makeLoginViewController(coordinator: AuthCoordinator) -> LoginViewControllerable { + let loginViewController = LoginViewController(manager: LoginMangerImpl(authService: AuthServiceImpl(apiService: APIService())), navigator: self.makeAuthAdaptor(coordinator: coordinator)) return loginViewController } - func makeCompleteOnbardingViewController(navigator: CompleteOnbardingNavigation) -> CompleteOnbardingViewControllerable { - let completeViewController = CompleteOnbardingViewController(navigator: navigator) + func makeCompleteOnbardingViewController(coordinator: AuthCoordinator) -> CompleteOnbardingViewControllerable { + let completeViewController = CompleteOnbardingViewController(navigator: self.makeAuthAdaptor(coordinator: coordinator)) return completeViewController } - func makeOnboardingViewController(navigator: OnboardingNavigation) -> OnboardingViewControllerable { - let onboardingViewController = OnboardingViewController(manager: OnboardingManagerImpl(authService: AuthServiceImpl(apiService: APIService())), navigator: navigator) + func makeOnboardingViewController(coordinator: AuthCoordinator) -> OnboardingViewControllerable { + let onboardingViewController = OnboardingViewController(manager: OnboardingManagerImpl(authService: AuthServiceImpl(apiService: APIService())), navigator: self.makeAuthAdaptor(coordinator: coordinator)) return onboardingViewController } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/AuthFactory.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/AuthFactory.swift index 41ef656e..a60a8072 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/AuthFactory.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/AuthFactory.swift @@ -8,9 +8,10 @@ import Foundation protocol AuthFactory { - func makeLoginViewController(navigator: LoginNavigation) -> LoginViewControllerable - func makeCompleteOnbardingViewController(navigator: CompleteOnbardingNavigation) -> CompleteOnbardingViewControllerable - func makeOnboardingViewController(navigator: OnboardingNavigation) -> OnboardingViewControllerable + func makeAuthAdaptor(coordinator: AuthCoordinator) -> EntireAuthNaviation + func makeLoginViewController(coordinator: AuthCoordinator) -> LoginViewControllerable + func makeCompleteOnbardingViewController(coordinator: AuthCoordinator) -> CompleteOnbardingViewControllerable + func makeOnboardingViewController(coordinator: AuthCoordinator) -> OnboardingViewControllerable } From 387f95de208a5588a10045fd33cadb15de62a8ab Mon Sep 17 00:00:00 2001 From: kimscastle Date: Thu, 19 Oct 2023 17:09:47 +0900 Subject: [PATCH 6/8] =?UTF-8?q?[REFACTOR]=20TodayCoordinator=EC=97=90?= =?UTF-8?q?=EC=84=9C=20Adaptor=EC=83=9D=EC=84=B1=EB=B6=84=EB=A6=AC(#156)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS/Scenes/Adaptor/TodayAdaptor.swift | 4 +++- .../CoordinatorImpl/TodayCoordinatorImpl.swift | 5 ++--- .../Scenes/Factory/FactoryImpl/TodayFactoryImpl.swift | 8 ++++++-- .../Scenes/Factory/FactoryInterface/TodayFactory.swift | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/TodayAdaptor.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/TodayAdaptor.swift index 6df90096..b665e5ea 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/TodayAdaptor.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/TodayAdaptor.swift @@ -7,7 +7,9 @@ import Foundation -final class TodayAdaptor: TodayNavigation { +typealias EntireTodayNavigation = TodayNavigation + +final class TodayAdaptor: EntireTodayNavigation { let coordinator: TodayCoordinator init(coordinator: TodayCoordinator) { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/TodayCoordinatorImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/TodayCoordinatorImpl.swift index f6a76639..ef5bfe27 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/TodayCoordinatorImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/TodayCoordinatorImpl.swift @@ -25,9 +25,8 @@ final class TodayCoordinatorImpl: TodayCoordinator { } func showTodayViewController() { - let todayAdaptor = TodayAdaptor(coordinator: self) - let todayVC = factory.makeTodayViewController(adaptor: todayAdaptor) - self.navigationController.pushViewController(todayVC, animated: true) + let todayViweController = factory.makeTodayViewController(coordinator: self) + self.navigationController.pushViewController(todayViweController, animated: true) } func showArticleDetaileViewController(articleID: Int) { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/TodayFactoryImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/TodayFactoryImpl.swift index 3bb3ceb5..0eb8e092 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/TodayFactoryImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/TodayFactoryImpl.swift @@ -8,7 +8,11 @@ import UIKit struct TodayFactoryImpl: TodayFactory { - func makeTodayViewController(adaptor: TodayNavigation) -> TodayViewControllerable { - return TodayViewController(manager: TodayManagerImpl(articleService: ArticleServiceImpl(apiService: APIService())), adaptor: adaptor) + func makeAuthAdaptor(coordinator: TodayCoordinator) -> EntireTodayNavigation { + return TodayAdaptor(coordinator: coordinator) + } + + func makeTodayViewController(coordinator: TodayCoordinator) -> TodayViewControllerable { + return TodayViewController(manager: TodayManagerImpl(articleService: ArticleServiceImpl(apiService: APIService())), adaptor: TodayAdaptor(coordinator: coordinator)) } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/TodayFactory.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/TodayFactory.swift index b23dafb2..fe84ca1c 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/TodayFactory.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/TodayFactory.swift @@ -8,7 +8,8 @@ import UIKit protocol TodayFactory { - func makeTodayViewController(adaptor: TodayNavigation) -> TodayViewControllerable + func makeAuthAdaptor(coordinator: TodayCoordinator) -> EntireTodayNavigation + func makeTodayViewController(coordinator: TodayCoordinator) -> TodayViewControllerable } From f7ea8f5bc580bfff3a1d2fb9ff86589b52789d26 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Thu, 19 Oct 2023 17:14:05 +0900 Subject: [PATCH 7/8] =?UTF-8?q?[REFACTOR]=20SplashCoordinator=EC=97=90?= =?UTF-8?q?=EC=84=9C=20Adaptor=EC=83=9D=EC=84=B1=EB=B6=84=EB=A6=AC(#156)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS/Scenes/Adaptor/SplashAdaptor.swift | 4 +++- .../CoordinatorImpl/SplashCoordinatorImpl.swift | 3 +-- .../Scenes/Factory/FactoryImpl/SplashFactoryImpl.swift | 8 ++++++-- .../Scenes/Factory/FactoryInterface/SpalshFactory.swift | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/SplashAdaptor.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/SplashAdaptor.swift index 3af1cc3e..0daa845d 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/SplashAdaptor.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/SplashAdaptor.swift @@ -7,7 +7,9 @@ import Foundation -final class SplashAdaptor: SplashNavigation { +typealias EntireSplashNavigation = SplashNavigation + +final class SplashAdaptor: EntireSplashNavigation { let coordinator: SplashCoordinator init(coordinator: SplashCoordinator) { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/SplashCoordinatorImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/SplashCoordinatorImpl.swift index 51e0451a..3fbc5bd3 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/SplashCoordinatorImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/SplashCoordinatorImpl.swift @@ -26,8 +26,7 @@ final class SplashCoordinatorImpl: SplashCoordinator { } func showSplashViewController() { - let splashAdaptor = SplashAdaptor(coordinator: self) - let splashViewController = factory.makeSplashViewController(adaptor: splashAdaptor) + let splashViewController = factory.makeSplashViewController(coordinator: self) self.navigationController.pushViewController(splashViewController, animated: false) } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/SplashFactoryImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/SplashFactoryImpl.swift index ecbd9dfb..95aff7d3 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/SplashFactoryImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/SplashFactoryImpl.swift @@ -8,7 +8,11 @@ import UIKit struct SplashFactoryImpl: SplashFactory { - func makeSplashViewController(adaptor: SplashNavigation) -> SplashViewControllerable { - return SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService())), adaptor: adaptor) + func makeSplashAdaptor(coordinator: SplashCoordinator) -> EntireSplashNavigation { + return SplashAdaptor(coordinator: coordinator) + } + + func makeSplashViewController(coordinator: SplashCoordinator) -> SplashViewControllerable { + return SplashViewController(manager: SplashManagerImpl(authService: AuthServiceImpl(apiService: APIService())), adaptor: self.makeSplashAdaptor(coordinator: coordinator)) } } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/SpalshFactory.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/SpalshFactory.swift index 489ab326..7f67370d 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/SpalshFactory.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/SpalshFactory.swift @@ -8,7 +8,8 @@ import UIKit protocol SplashFactory { - func makeSplashViewController(adaptor: SplashNavigation) -> SplashViewControllerable + func makeSplashAdaptor(coordinator: SplashCoordinator) -> EntireSplashNavigation + func makeSplashViewController(coordinator: SplashCoordinator) -> SplashViewControllerable } From 001b4ab0f014207cabbd763ff690dd27d81d463a Mon Sep 17 00:00:00 2001 From: kimscastle Date: Thu, 19 Oct 2023 17:20:11 +0900 Subject: [PATCH 8/8] =?UTF-8?q?[REFACTOR]=20ArticleCategoryCoordinator?= =?UTF-8?q?=EC=97=90=EC=84=9C=20Adaptor=EC=83=9D=EC=84=B1=EB=B6=84?= =?UTF-8?q?=EB=A6=AC(#156)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Adaptor/ArticleCategoryAdaptor.swift | 4 +++- .../CoordinatorImpl/ArticleCategoryCoordinatorImpl.swift | 3 +-- .../Factory/FactoryImpl/ArticleCategortFactoryImpl.swift | 9 ++++++--- .../FactoryInterface/ArticleCategortFactory.swift | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/ArticleCategoryAdaptor.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/ArticleCategoryAdaptor.swift index a99aa75a..eaba6d0b 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/ArticleCategoryAdaptor.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/ArticleCategoryAdaptor.swift @@ -7,7 +7,9 @@ import Foundation -final class ArticleCategoryAdaptor: ArticleCategoryNavigation, ArticleListByCategoryNavigation { +typealias EntireArticleCategoryNavigation = ArticleCategoryNavigation & ArticleListByCategoryNavigation + +final class ArticleCategoryAdaptor: EntireArticleCategoryNavigation { let coordinator: ArticleCategoryCoordinator init(coordinator: ArticleCategoryCoordinator) { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/ArticleCategoryCoordinatorImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/ArticleCategoryCoordinatorImpl.swift index 0aefffbf..b1acc0bf 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/ArticleCategoryCoordinatorImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/ArticleCategoryCoordinatorImpl.swift @@ -44,8 +44,7 @@ final class ArticleCategoryCoordinatorImpl: ArticleCategoryCoordinator { } func showArticleListbyCategoryViewController(categoryName: String) { - let articleListbyCategoryAdaptor = ArticleCategoryAdaptor(coordinator: self) - let articleListbyCategoryViewController = factory.makeArticleListByCategoryViewController(navigator: articleListbyCategoryAdaptor) + let articleListbyCategoryViewController = factory.makeArticleListByCategoryViewController(coordinator: self) articleListbyCategoryViewController.categoryString = categoryName self.navigationController.pushViewController(articleListbyCategoryViewController, animated: true) } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/ArticleCategortFactoryImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/ArticleCategortFactoryImpl.swift index b0a871a8..6990f49a 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/ArticleCategortFactoryImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryImpl/ArticleCategortFactoryImpl.swift @@ -8,12 +8,15 @@ import Foundation struct ArticleCategortFactoryImpl: ArticleCategortFactory { - func makeArticleListByCategoryViewController(navigator: ArticleListByCategoryNavigation) -> ArticleListByCategoryViewControllerable { - return ArticleListByCategoryViewController(manager: ArticleListByCategoryMangerImpl(articleService: ArticleServiceImpl(apiService: APIService()), bookmarkService: BookmarkServiceImpl(apiService: APIService())), navigator: navigator) + func makeArticleCategoryAdaptor(coordinator: ArticleCategoryCoordinator) -> EntireArticleCategoryNavigation { + return ArticleCategoryAdaptor(coordinator: coordinator) + } + + func makeArticleListByCategoryViewController(coordinator: ArticleCategoryCoordinator) -> ArticleListByCategoryViewControllerable { + return ArticleListByCategoryViewController(manager: ArticleListByCategoryMangerImpl(articleService: ArticleServiceImpl(apiService: APIService()), bookmarkService: BookmarkServiceImpl(apiService: APIService())), navigator: self.makeArticleCategoryAdaptor(coordinator: coordinator)) } func makeArticleCategoryViewController(navigator: ArticleCategoryNavigation) -> ArticleCategoryViewControllerable { return ArticleCategoryViewController(navigator: navigator) } - } diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/ArticleCategortFactory.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/ArticleCategortFactory.swift index 1d4c7bb2..6acd1c09 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/ArticleCategortFactory.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Factory/FactoryInterface/ArticleCategortFactory.swift @@ -8,6 +8,7 @@ import Foundation protocol ArticleCategortFactory { + func makeArticleCategoryAdaptor(coordinator: ArticleCategoryCoordinator) -> EntireArticleCategoryNavigation + func makeArticleListByCategoryViewController(coordinator: ArticleCategoryCoordinator) -> ArticleListByCategoryViewControllerable func makeArticleCategoryViewController(navigator: ArticleCategoryNavigation) -> ArticleCategoryViewControllerable - func makeArticleListByCategoryViewController(navigator: ArticleListByCategoryNavigation) -> ArticleListByCategoryViewControllerable }