From 0e4e9b74287b6a155216c3359ccfda9149380957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Junnos=20=EF=A3=BF?= Date: Thu, 4 Jan 2024 20:40:23 +0900 Subject: [PATCH] =?UTF-8?q?:recycle:=20SelectSong=EA=B3=BC=20SaveJourney?= =?UTF-8?q?=20Coordinator=EB=A5=BC=20=ED=95=98=EB=82=98=EC=9D=98=20FlowCoo?= =?UTF-8?q?rdinator=EB=A1=9C=20=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SaveJourneyNavigationDelegate.swift | 2 +- .../SaveJourneyViewController.swift | 2 +- .../MusicSpot.xcodeproj/project.pbxproj | 12 ++-- .../Coordinator/HomeCoordinator.swift | 2 +- .../Coordinator/SaveJourneyCoordinator.swift | 60 ------------------- ...swift => SaveJourneyFlowCoordinator.swift} | 36 ++++++++--- 6 files changed, 34 insertions(+), 80 deletions(-) delete mode 100644 iOS/MusicSpot/MusicSpot/Coordinator/SaveJourneyCoordinator.swift rename iOS/MusicSpot/MusicSpot/Coordinator/{SelectSongCoordinator.swift => SaveJourneyFlowCoordinator.swift} (55%) diff --git a/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/Coordinator/SaveJourneyNavigationDelegate.swift b/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/Coordinator/SaveJourneyNavigationDelegate.swift index 6d98b2e..eef19ad 100644 --- a/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/Coordinator/SaveJourneyNavigationDelegate.swift +++ b/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/Coordinator/SaveJourneyNavigationDelegate.swift @@ -11,7 +11,7 @@ import MSDomain public protocol SaveJourneyNavigationDelegate: AnyObject { - func popToHome(with endedJourney: Journey) + func popToHome() func popToSelectSong() } diff --git a/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/SaveJourneyViewController.swift b/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/SaveJourneyViewController.swift index 6a79cee..3a5f198 100644 --- a/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/SaveJourneyViewController.swift +++ b/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/SaveJourneyViewController.swift @@ -199,7 +199,7 @@ public final class SaveJourneyViewController: UIViewController { self.viewModel.state.endJourneySucceed .receive(on: DispatchQueue.main) .sink { [weak self] endedJourney in - self?.navigationDelegate?.popToHome(with: endedJourney) + self?.navigationDelegate?.popToHome() } .store(in: &self.cancellables) } diff --git a/iOS/MusicSpot/MusicSpot.xcodeproj/project.pbxproj b/iOS/MusicSpot/MusicSpot.xcodeproj/project.pbxproj index 9854743..fc80d34 100644 --- a/iOS/MusicSpot/MusicSpot.xcodeproj/project.pbxproj +++ b/iOS/MusicSpot/MusicSpot.xcodeproj/project.pbxproj @@ -7,12 +7,11 @@ objects = { /* Begin PBXBuildFile section */ - 08CBF8782B18468E007D3797 /* SaveJourneyCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8702B18468E007D3797 /* SaveJourneyCoordinator.swift */; }; 08CBF8792B18468E007D3797 /* AppCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8712B18468E007D3797 /* AppCoordinator.swift */; }; 08CBF87A2B18468E007D3797 /* RewindJourneyCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8722B18468E007D3797 /* RewindJourneyCoordinator.swift */; }; 08CBF87B2B18468E007D3797 /* HomeCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8732B18468E007D3797 /* HomeCoordinator.swift */; }; 08CBF87D2B18468E007D3797 /* SpotCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8752B18468E007D3797 /* SpotCoordinator.swift */; }; - 08CBF87E2B18468E007D3797 /* SelectSongCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8762B18468E007D3797 /* SelectSongCoordinator.swift */; }; + 08CBF87E2B18468E007D3797 /* SaveJourneyFlowCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8762B18468E007D3797 /* SaveJourneyFlowCoordinator.swift */; }; 08CBF87F2B18468E007D3797 /* Coordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8772B18468E007D3797 /* Coordinator.swift */; }; DD0194E92B25C42E007CE082 /* Home in Frameworks */ = {isa = PBXBuildFile; productRef = DD0194E82B25C42E007CE082 /* Home */; }; DD0194EB2B25C42E007CE082 /* NavigateMap in Frameworks */ = {isa = PBXBuildFile; productRef = DD0194EA2B25C42E007CE082 /* NavigateMap */; }; @@ -35,12 +34,11 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 08CBF8702B18468E007D3797 /* SaveJourneyCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SaveJourneyCoordinator.swift; sourceTree = ""; }; 08CBF8712B18468E007D3797 /* AppCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppCoordinator.swift; sourceTree = ""; }; 08CBF8722B18468E007D3797 /* RewindJourneyCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RewindJourneyCoordinator.swift; sourceTree = ""; }; 08CBF8732B18468E007D3797 /* HomeCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeCoordinator.swift; sourceTree = ""; }; 08CBF8752B18468E007D3797 /* SpotCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpotCoordinator.swift; sourceTree = ""; }; - 08CBF8762B18468E007D3797 /* SelectSongCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectSongCoordinator.swift; sourceTree = ""; }; + 08CBF8762B18468E007D3797 /* SaveJourneyFlowCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SaveJourneyFlowCoordinator.swift; sourceTree = ""; }; 08CBF8772B18468E007D3797 /* Coordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Coordinator.swift; sourceTree = ""; }; DD73F8552B024C4900EE9BF2 /* MusicSpot.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MusicSpot.app; sourceTree = BUILT_PRODUCTS_DIR; }; DD73F8582B024C4900EE9BF2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -83,8 +81,7 @@ 08CBF8712B18468E007D3797 /* AppCoordinator.swift */, 08CBF8732B18468E007D3797 /* HomeCoordinator.swift */, 08CBF8752B18468E007D3797 /* SpotCoordinator.swift */, - 08CBF8762B18468E007D3797 /* SelectSongCoordinator.swift */, - 08CBF8702B18468E007D3797 /* SaveJourneyCoordinator.swift */, + 08CBF8762B18468E007D3797 /* SaveJourneyFlowCoordinator.swift */, 08CBF8722B18468E007D3797 /* RewindJourneyCoordinator.swift */, ); path = Coordinator; @@ -232,10 +229,9 @@ files = ( DDB22F752B433EC300F83D84 /* CoordinatorFinishDelegate.swift in Sources */, 08CBF8792B18468E007D3797 /* AppCoordinator.swift in Sources */, - 08CBF8782B18468E007D3797 /* SaveJourneyCoordinator.swift in Sources */, 08CBF87F2B18468E007D3797 /* Coordinator.swift in Sources */, 08CBF87D2B18468E007D3797 /* SpotCoordinator.swift in Sources */, - 08CBF87E2B18468E007D3797 /* SelectSongCoordinator.swift in Sources */, + 08CBF87E2B18468E007D3797 /* SaveJourneyFlowCoordinator.swift in Sources */, 08CBF87A2B18468E007D3797 /* RewindJourneyCoordinator.swift in Sources */, DD73F8592B024C4900EE9BF2 /* AppDelegate.swift in Sources */, 08CBF87B2B18468E007D3797 /* HomeCoordinator.swift in Sources */, diff --git a/iOS/MusicSpot/MusicSpot/Coordinator/HomeCoordinator.swift b/iOS/MusicSpot/MusicSpot/Coordinator/HomeCoordinator.swift index ff23a1d..bc68236 100644 --- a/iOS/MusicSpot/MusicSpot/Coordinator/HomeCoordinator.swift +++ b/iOS/MusicSpot/MusicSpot/Coordinator/HomeCoordinator.swift @@ -89,7 +89,7 @@ extension HomeCoordinator: HomeNavigationDelegate { } func navigateToSelectSong(lastCoordinate: Coordinate) { - let selectSongCoordinator = SelectSongCoordinator(navigationController: self.navigationController) + let selectSongCoordinator = SaveJourneyFlowCoordinator(navigationController: self.navigationController) selectSongCoordinator.finishDelegate = self self.childCoordinators.append(selectSongCoordinator) selectSongCoordinator.start(lastCoordinate: lastCoordinate) diff --git a/iOS/MusicSpot/MusicSpot/Coordinator/SaveJourneyCoordinator.swift b/iOS/MusicSpot/MusicSpot/Coordinator/SaveJourneyCoordinator.swift deleted file mode 100644 index e16d29b..0000000 --- a/iOS/MusicSpot/MusicSpot/Coordinator/SaveJourneyCoordinator.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// SearchMusicCoordinator.swift -// MusicSpot -// -// Created by 윤동주 on 11/29/23. -// - -import MusicKit -import UIKit - -import MSData -import MSDomain -import SaveJourney - -final class SaveJourneyCoordinator: Coordinator { - - // MARK: - Properties - - let navigationController: UINavigationController - var rootViewController: UIViewController? - - var childCoordinators: [Coordinator] = [] - weak var finishDelegate: CoordinatorFinishDelegate? - - // MARK: - Initializer - - init(navigationController: UINavigationController) { - self.navigationController = navigationController - } - - // MARK: - Functions - - func start(lastCoordinate: Coordinate, - selectedSong: Song) { - let journeyRepository = JourneyRepositoryImplementation() - let saveJourneyViewModel = SaveJourneyViewModel(lastCoordinate: lastCoordinate, - selectedSong: selectedSong, - journeyRepository: journeyRepository) - let saveJourneyViewController = SaveJourneyViewController(viewModel: saveJourneyViewModel) - saveJourneyViewController.navigationDelegate = self - self.rootViewController = saveJourneyViewController - - self.navigationController.pushViewController(saveJourneyViewController, animated: true) - } - -} - -// MARK: - SaveJourney Navigation - -extension SaveJourneyCoordinator: SaveJourneyNavigationDelegate { - - func popToHome(with endedJourney: Journey) { - - } - - func popToSelectSong() { - self.finish() - } - -} diff --git a/iOS/MusicSpot/MusicSpot/Coordinator/SelectSongCoordinator.swift b/iOS/MusicSpot/MusicSpot/Coordinator/SaveJourneyFlowCoordinator.swift similarity index 55% rename from iOS/MusicSpot/MusicSpot/Coordinator/SelectSongCoordinator.swift rename to iOS/MusicSpot/MusicSpot/Coordinator/SaveJourneyFlowCoordinator.swift index 7dc26cd..adef178 100644 --- a/iOS/MusicSpot/MusicSpot/Coordinator/SelectSongCoordinator.swift +++ b/iOS/MusicSpot/MusicSpot/Coordinator/SaveJourneyFlowCoordinator.swift @@ -1,5 +1,5 @@ // -// SelectSongCoordinator.swift +// SaveJourneyFlowCoordinator.swift // MusicSpot // // Created by 윤동주 on 11/29/23. @@ -13,7 +13,7 @@ import MSDomain import SaveJourney import SelectSong -final class SelectSongCoordinator: Coordinator { +final class SaveJourneyFlowCoordinator: Coordinator { // MARK: - Properties @@ -31,6 +31,7 @@ final class SelectSongCoordinator: Coordinator { // MARK: - Functions + /// rootViewController: SelectSongViewController func start(lastCoordinate: Coordinate) { let songRepository = SongRepositoryImplementation() let selectSongViewModel = SelectSongViewModel(lastCoordinate: lastCoordinate, @@ -46,7 +47,7 @@ final class SelectSongCoordinator: Coordinator { // MARK: - Finish Delegate -extension SelectSongCoordinator: CoordinatorFinishDelegate { +extension SaveJourneyFlowCoordinator: CoordinatorFinishDelegate { func shouldFinish(childCoordinator: Coordinator) { guard let selectSongViewController = self.rootViewController else { return } @@ -59,13 +60,18 @@ extension SelectSongCoordinator: CoordinatorFinishDelegate { // MARK: - SelectSong Navigation -extension SelectSongCoordinator: SelectSongNavigationDelegate { +extension SaveJourneyFlowCoordinator: SelectSongNavigationDelegate { - func navigateToSaveJourney(lastCoordinate: Coordinate, selectedSong: Song) { - let saveJourneyCoordinator = SaveJourneyCoordinator(navigationController: self.navigationController) - saveJourneyCoordinator.finishDelegate = self - self.childCoordinators.append(saveJourneyCoordinator) - saveJourneyCoordinator.start(lastCoordinate: lastCoordinate, selectedSong: selectedSong) + func navigateToSaveJourney(lastCoordinate: Coordinate, + selectedSong: Song) { + let journeyRepository = JourneyRepositoryImplementation() + let saveJourneyViewModel = SaveJourneyViewModel(lastCoordinate: lastCoordinate, + selectedSong: selectedSong, + journeyRepository: journeyRepository) + let saveJourneyViewController = SaveJourneyViewController(viewModel: saveJourneyViewModel) + saveJourneyViewController.navigationDelegate = self + + self.navigationController.pushViewController(saveJourneyViewController, animated: true) } func popToHome() { @@ -73,3 +79,15 @@ extension SelectSongCoordinator: SelectSongNavigationDelegate { } } + +// MARK: - SaveJourney Navigation + +extension SaveJourneyFlowCoordinator: SaveJourneyNavigationDelegate { + + func popToSelectSong() { + guard self.navigationController.topViewController is SaveJourneyViewController else { return } + + self.navigationController.popViewController(animated: true) + } + +}