Skip to content

Commit

Permalink
🐛 SearchMusic에 대한 잘못된 흐름을 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
SwiftyJunnos committed Nov 30, 2023
1 parent 3446a9f commit ef74cfc
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 83 deletions.
16 changes: 0 additions & 16 deletions iOS/MusicSpot/MusicSpot/MSCoordinator/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,3 @@ final class AppCoordinator: Coordinator {
}

}

// MARK: - App Coordinator

extension AppCoordinator: AppCoordinatorDelegate {

func popToHomeMap(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
self.start()
}

func popToSearchMusic(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
self.navigationController.popToRootViewController(animated: true)
}

}
25 changes: 18 additions & 7 deletions iOS/MusicSpot/MusicSpot/MSCoordinator/HomeMapCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

import UIKit

protocol HomeMapCoordinatorDelegate: AnyObject {

func popToHomeMap(from coordinator: Coordinator)

}

final class HomeMapCoordinator: Coordinator {

// MARK: - Properties
Expand Down Expand Up @@ -39,35 +45,40 @@ extension HomeMapCoordinator: HomeMapViewControllerDelegate {

func navigateToSpot() {
let spotCoordinator = SpotCoordinator(navigationController: self.navigationController)
spotCoordinator.delegate = self
self.childCoordinators.append(spotCoordinator)
spotCoordinator.start()
}

func navigateToSearchMusic() {
let searchMusicCoordinator = SearchMusicCoordinator(navigationController: self.navigationController)
searchMusicCoordinator.delegate = self
self.childCoordinators.append(searchMusicCoordinator)
searchMusicCoordinator.start()
}

func navigateToRewind() {
let rewindCoordinator = RewindCoordinator(navigationController: self.navigationController)
rewindCoordinator.delegate = self
self.childCoordinators.append(rewindCoordinator)
rewindCoordinator.start()
}

func navigateToSetting() {
let settingCoordinator = SettingCoordinator(navigationController: self.navigationController)
settingCoordinator.delegate = self
self.childCoordinators.append(settingCoordinator)
settingCoordinator.start()
}

}

// MARK: - App Coordinator
// MARK: - HomeMap Coordinator

extension HomeMapCoordinator: AppCoordinatorDelegate {
extension HomeMapCoordinator: HomeMapCoordinatorDelegate {

func popToHomeMap(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
}

func popToSearchMusic(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
self.navigationController.popViewController(animated: true)
self.delegate?.popToSearchMusic(from: self)
}
}
12 changes: 3 additions & 9 deletions iOS/MusicSpot/MusicSpot/MSCoordinator/RewindCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class RewindCoordinator: Coordinator {

var childCoordinators: [Coordinator] = []

var delegate: AppCoordinatorDelegate?
var delegate: HomeMapCoordinatorDelegate?

// MARK: - Initializer

Expand Down Expand Up @@ -43,20 +43,14 @@ extension RewindCoordinator: RewindViewControllerDelegate {

}

// MARK: - App Coordinator
// MARK: - HomeMap Coordinator

extension RewindCoordinator: AppCoordinatorDelegate {
extension RewindCoordinator: HomeMapCoordinatorDelegate {

func popToHomeMap(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
self.navigationController.popViewController(animated: true)
self.delegate?.popToHomeMap(from: self)
}

func popToSearchMusic(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
self.navigationController.popViewController(animated: true)
self.delegate?.popToSearchMusic(from: self)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class SaveJourneyCoordinator: Coordinator {

var childCoordinators: [Coordinator] = []

var delegate: AppCoordinatorDelegate?
var delegate: SearchMusicCoordinatorDelegate?

// MARK: - Initializer

Expand Down Expand Up @@ -46,21 +46,3 @@ extension SaveJourneyCoordinator: SaveJourneyViewControllerDelegate {
}

}

// MARK: - App Coordinator

extension SaveJourneyCoordinator: AppCoordinatorDelegate {

func popToHomeMap(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
self.navigationController.popViewController(animated: true)
self.delegate?.popToHomeMap(from: self)
}

func popToSearchMusic(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
self.navigationController.popViewController(animated: true)
self.delegate?.popToSearchMusic(from: self)
}

}
12 changes: 10 additions & 2 deletions iOS/MusicSpot/MusicSpot/MSCoordinator/SearchMusicCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

import UIKit

protocol SearchMusicCoordinatorDelegate {

func popToHomeMap(from coordinator: Coordinator)
func popToSearchMusic(from coordinator: Coordinator)

}

final class SearchMusicCoordinator: Coordinator {

// MARK: - Properties
Expand All @@ -15,7 +22,7 @@ final class SearchMusicCoordinator: Coordinator {

var childCoordinators: [Coordinator] = []

var delegate: AppCoordinatorDelegate?
var delegate: HomeMapCoordinatorDelegate?

// MARK: - Initializer

Expand Down Expand Up @@ -43,6 +50,7 @@ extension SearchMusicCoordinator: SearchMusicViewControllerDelegate {

func navigateToSaveJourney() {
let saveJourneyCoordinator = SaveJourneyCoordinator(navigationController: self.navigationController)
saveJourneyCoordinator.delegate = self
self.childCoordinators.append(saveJourneyCoordinator)
saveJourneyCoordinator.start()
}
Expand All @@ -51,7 +59,7 @@ extension SearchMusicCoordinator: SearchMusicViewControllerDelegate {

// MARK: - App Coordinator

extension SearchMusicCoordinator: AppCoordinatorDelegate {
extension SearchMusicCoordinator: SearchMusicCoordinatorDelegate {

func popToHomeMap(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
Expand Down
12 changes: 3 additions & 9 deletions iOS/MusicSpot/MusicSpot/MSCoordinator/SettingCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class SettingCoordinator: Coordinator {

var childCoordinators: [Coordinator] = []

var delegate: AppCoordinatorDelegate?
var delegate: HomeMapCoordinatorDelegate?

// MARK: - Initializer

Expand Down Expand Up @@ -43,20 +43,14 @@ extension SettingCoordinator: SettingViewControllerDelegate {

}

// MARK: - App Coordinator
// MARK: - HomeMap Coordinator

extension SettingCoordinator: AppCoordinatorDelegate {
extension SettingCoordinator: HomeMapCoordinatorDelegate {

func popToHomeMap(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
self.navigationController.popViewController(animated: true)
self.delegate?.popToHomeMap(from: self)
}

func popToSearchMusic(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
self.navigationController.popViewController(animated: true)
self.delegate?.popToSearchMusic(from: self)
}

}
18 changes: 3 additions & 15 deletions iOS/MusicSpot/MusicSpot/MSCoordinator/SpotCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class SpotCoordinator: Coordinator {

var childCoordinators: [Coordinator] = []

var delegate: AppCoordinatorDelegate?
var delegate: HomeMapCoordinatorDelegate?

// MARK: - Initializer

Expand All @@ -41,28 +41,16 @@ extension SpotCoordinator: SpotViewControllerDelegate {
self.delegate?.popToHomeMap(from: self)
}

func navigateToSearchMusic() {
let searchMusicCoordinator = SearchMusicCoordinator(navigationController: self.navigationController)
self.childCoordinators.append(searchMusicCoordinator)
searchMusicCoordinator.start()
}

}

// MARK: - App Coordinator
// MARK: - HomeMap Coordinator

extension SpotCoordinator: AppCoordinatorDelegate {
extension SpotCoordinator: HomeMapCoordinatorDelegate {

func popToHomeMap(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
self.navigationController.popViewController(animated: true)
self.delegate?.popToHomeMap(from: self)
}

func popToSearchMusic(from coordinator: Coordinator) {
self.childCoordinators.removeAll()
self.navigationController.popViewController(animated: true)
self.delegate?.popToSearchMusic(from: self)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import UIKit

protocol HomeMapViewControllerDelegate: AnyObject {
func navigateToSpot()
func navigateToSearchMusic()
func navigateToRewind()
func navigateToSetting()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import UIKit

protocol SpotViewControllerDelegate: AnyObject {
func navigateToHomeMap()
func navigateToSearchMusic()
}

class SpotViewController: UIViewController {
Expand Down Expand Up @@ -45,6 +44,12 @@ class SpotViewController: UIViewController {
self.configureStyle()
self.configureLayout()
}

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)

self.delegate?.navigateToHomeMap()
}

// MARK: - Functions

Expand Down Expand Up @@ -77,10 +82,5 @@ class SpotViewController: UIViewController {
func navigateToHomeMap() {
self.delegate?.navigateToHomeMap()
}

@objc
func navigateToSearchMusic() {
self.delegate?.navigateToSearchMusic()
}

}

0 comments on commit ef74cfc

Please sign in to comment.