Skip to content

Commit

Permalink
♻️ SelectSong과 SaveJourney Coordinator를 하나의 FlowCoordinator로 통합
Browse files Browse the repository at this point in the history
  • Loading branch information
SwiftyJunnos committed Jan 4, 2024
1 parent bbc3b1f commit 0e4e9b7
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MSDomain

public protocol SaveJourneyNavigationDelegate: AnyObject {

func popToHome(with endedJourney: Journey)
func popToHome()
func popToSelectSong()

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
12 changes: 4 additions & 8 deletions iOS/MusicSpot/MusicSpot.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -35,12 +34,11 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
08CBF8702B18468E007D3797 /* SaveJourneyCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SaveJourneyCoordinator.swift; sourceTree = "<group>"; };
08CBF8712B18468E007D3797 /* AppCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppCoordinator.swift; sourceTree = "<group>"; };
08CBF8722B18468E007D3797 /* RewindJourneyCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RewindJourneyCoordinator.swift; sourceTree = "<group>"; };
08CBF8732B18468E007D3797 /* HomeCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeCoordinator.swift; sourceTree = "<group>"; };
08CBF8752B18468E007D3797 /* SpotCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpotCoordinator.swift; sourceTree = "<group>"; };
08CBF8762B18468E007D3797 /* SelectSongCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectSongCoordinator.swift; sourceTree = "<group>"; };
08CBF8762B18468E007D3797 /* SaveJourneyFlowCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SaveJourneyFlowCoordinator.swift; sourceTree = "<group>"; };
08CBF8772B18468E007D3797 /* Coordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Coordinator.swift; sourceTree = "<group>"; };
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 = "<group>"; };
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */,
Expand Down
2 changes: 1 addition & 1 deletion iOS/MusicSpot/MusicSpot/Coordinator/HomeCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
60 changes: 0 additions & 60 deletions iOS/MusicSpot/MusicSpot/Coordinator/SaveJourneyCoordinator.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// SelectSongCoordinator.swift
// SaveJourneyFlowCoordinator.swift
// MusicSpot
//
// Created by 윤동주 on 11/29/23.
Expand All @@ -13,7 +13,7 @@ import MSDomain
import SaveJourney
import SelectSong

final class SelectSongCoordinator: Coordinator {
final class SaveJourneyFlowCoordinator: Coordinator {

// MARK: - Properties

Expand All @@ -31,6 +31,7 @@ final class SelectSongCoordinator: Coordinator {

// MARK: - Functions

/// rootViewController: SelectSongViewController
func start(lastCoordinate: Coordinate) {
let songRepository = SongRepositoryImplementation()
let selectSongViewModel = SelectSongViewModel(lastCoordinate: lastCoordinate,
Expand All @@ -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 }
Expand All @@ -59,17 +60,34 @@ 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() {
self.finish()
}

}

// MARK: - SaveJourney Navigation

extension SaveJourneyFlowCoordinator: SaveJourneyNavigationDelegate {

func popToSelectSong() {
guard self.navigationController.topViewController is SaveJourneyViewController else { return }

self.navigationController.popViewController(animated: true)
}

}

0 comments on commit 0e4e9b7

Please sign in to comment.