Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Coordinator 패턴을 적용한 구조 구현 #135

Merged
merged 10 commits into from
Nov 30, 2023
80 changes: 80 additions & 0 deletions iOS/MusicSpot/MusicSpot.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
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 /* RewindCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8722B18468E007D3797 /* RewindCoordinator.swift */; };
08CBF87B2B18468E007D3797 /* HomeMapCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8732B18468E007D3797 /* HomeMapCoordinator.swift */; };
08CBF87C2B18468E007D3797 /* SettingCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8742B18468E007D3797 /* SettingCoordinator.swift */; };
08CBF87D2B18468E007D3797 /* SpotCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8752B18468E007D3797 /* SpotCoordinator.swift */; };
08CBF87E2B18468E007D3797 /* SearchMusicCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8762B18468E007D3797 /* SearchMusicCoordinator.swift */; };
08CBF87F2B18468E007D3797 /* Coordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8772B18468E007D3797 /* Coordinator.swift */; };
08CBF8872B1846A0007D3797 /* SettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8812B1846A0007D3797 /* SettingViewController.swift */; };
08CBF8882B1846A0007D3797 /* HomeMapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8822B1846A0007D3797 /* HomeMapViewController.swift */; };
08CBF8892B1846A0007D3797 /* SaveJourneyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8832B1846A0007D3797 /* SaveJourneyViewController.swift */; };
08CBF88A2B1846A0007D3797 /* SpotViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8842B1846A0007D3797 /* SpotViewController.swift */; };
08CBF88B2B1846A0007D3797 /* RewindViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8852B1846A0007D3797 /* RewindViewController.swift */; };
08CBF88C2B1846A0007D3797 /* SearchMusicViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CBF8862B1846A0007D3797 /* SearchMusicViewController.swift */; };
DD5EA2552B16EC920080AEC1 /* JourneyList in Frameworks */ = {isa = PBXBuildFile; productRef = DD5EA2542B16EC920080AEC1 /* JourneyList */; };
DD5EA2572B16EC960080AEC1 /* NavigateMap in Frameworks */ = {isa = PBXBuildFile; productRef = DD5EA2562B16EC960080AEC1 /* NavigateMap */; };
DD5EA2592B16EC9B0080AEC1 /* RecordJourney in Frameworks */ = {isa = PBXBuildFile; productRef = DD5EA2582B16EC9B0080AEC1 /* RecordJourney */; };
Expand All @@ -21,6 +35,20 @@
/* 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 /* RewindCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RewindCoordinator.swift; sourceTree = "<group>"; };
08CBF8732B18468E007D3797 /* HomeMapCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeMapCoordinator.swift; sourceTree = "<group>"; };
08CBF8742B18468E007D3797 /* SettingCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingCoordinator.swift; sourceTree = "<group>"; };
08CBF8752B18468E007D3797 /* SpotCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpotCoordinator.swift; sourceTree = "<group>"; };
08CBF8762B18468E007D3797 /* SearchMusicCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchMusicCoordinator.swift; sourceTree = "<group>"; };
08CBF8772B18468E007D3797 /* Coordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Coordinator.swift; sourceTree = "<group>"; };
08CBF8812B1846A0007D3797 /* SettingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingViewController.swift; sourceTree = "<group>"; };
08CBF8822B1846A0007D3797 /* HomeMapViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeMapViewController.swift; sourceTree = "<group>"; };
08CBF8832B1846A0007D3797 /* SaveJourneyViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SaveJourneyViewController.swift; sourceTree = "<group>"; };
08CBF8842B1846A0007D3797 /* SpotViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpotViewController.swift; sourceTree = "<group>"; };
08CBF8852B1846A0007D3797 /* RewindViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RewindViewController.swift; sourceTree = "<group>"; };
08CBF8862B1846A0007D3797 /* SearchMusicViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchMusicViewController.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>"; };
DD73F85A2B024C4900EE9BF2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -48,6 +76,42 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
08CBF86F2B18468E007D3797 /* MSCoordinator */ = {
isa = PBXGroup;
children = (
DD2856C32B187BAB002C994D /* Protocol */,
08CBF8712B18468E007D3797 /* AppCoordinator.swift */,
08CBF8732B18468E007D3797 /* HomeMapCoordinator.swift */,
08CBF8752B18468E007D3797 /* SpotCoordinator.swift */,
08CBF8762B18468E007D3797 /* SearchMusicCoordinator.swift */,
08CBF8702B18468E007D3797 /* SaveJourneyCoordinator.swift */,
08CBF8742B18468E007D3797 /* SettingCoordinator.swift */,
08CBF8722B18468E007D3797 /* RewindCoordinator.swift */,
);
path = MSCoordinator;
sourceTree = "<group>";
};
08CBF8802B1846A0007D3797 /* TempViewController */ = {
isa = PBXGroup;
children = (
08CBF8812B1846A0007D3797 /* SettingViewController.swift */,
08CBF8822B1846A0007D3797 /* HomeMapViewController.swift */,
08CBF8832B1846A0007D3797 /* SaveJourneyViewController.swift */,
08CBF8842B1846A0007D3797 /* SpotViewController.swift */,
08CBF8852B1846A0007D3797 /* RewindViewController.swift */,
08CBF8862B1846A0007D3797 /* SearchMusicViewController.swift */,
);
path = TempViewController;
sourceTree = "<group>";
};
DD2856C32B187BAB002C994D /* Protocol */ = {
isa = PBXGroup;
children = (
08CBF8772B18468E007D3797 /* Coordinator.swift */,
);
path = Protocol;
sourceTree = "<group>";
};
DD5EA23F2B16EC690080AEC1 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -75,6 +139,8 @@
DD73F8572B024C4900EE9BF2 /* MusicSpot */ = {
isa = PBXGroup;
children = (
08CBF8802B1846A0007D3797 /* TempViewController */,
08CBF86F2B18468E007D3797 /* MSCoordinator */,
DD73F8582B024C4900EE9BF2 /* AppDelegate.swift */,
DD73F85A2B024C4900EE9BF2 /* SceneDelegate.swift */,
DD73F8612B024C4B00EE9BF2 /* Assets.xcassets */,
Expand Down Expand Up @@ -171,7 +237,21 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
08CBF88C2B1846A0007D3797 /* SearchMusicViewController.swift in Sources */,
08CBF8882B1846A0007D3797 /* HomeMapViewController.swift in Sources */,
08CBF8792B18468E007D3797 /* AppCoordinator.swift in Sources */,
08CBF8872B1846A0007D3797 /* SettingViewController.swift in Sources */,
08CBF8782B18468E007D3797 /* SaveJourneyCoordinator.swift in Sources */,
08CBF87F2B18468E007D3797 /* Coordinator.swift in Sources */,
08CBF88B2B1846A0007D3797 /* RewindViewController.swift in Sources */,
08CBF8892B1846A0007D3797 /* SaveJourneyViewController.swift in Sources */,
08CBF88A2B1846A0007D3797 /* SpotViewController.swift in Sources */,
08CBF87D2B18468E007D3797 /* SpotCoordinator.swift in Sources */,
08CBF87E2B18468E007D3797 /* SearchMusicCoordinator.swift in Sources */,
08CBF87A2B18468E007D3797 /* RewindCoordinator.swift in Sources */,
08CBF87C2B18468E007D3797 /* SettingCoordinator.swift in Sources */,
DD73F8592B024C4900EE9BF2 /* AppDelegate.swift in Sources */,
08CBF87B2B18468E007D3797 /* HomeMapCoordinator.swift in Sources */,
DD73F85B2B024C4900EE9BF2 /* SceneDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
7 changes: 7 additions & 0 deletions iOS/MusicSpot/MusicSpot.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
39 changes: 39 additions & 0 deletions iOS/MusicSpot/MusicSpot/MSCoordinator/AppCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// AppCoordinator.swift
// MusicSpot
//
// Created by 윤동주 on 11/28/23.
//

import UIKit

protocol AppCoordinatorDelegate {

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

}

final class AppCoordinator: Coordinator {

// MARK: - Properties

let navigationController: UINavigationController

var childCoordinators: [Coordinator] = []

// MARK: - Initializer

init(navigationController: UINavigationController) {
self.navigationController = navigationController
}

// MARK: - From: HomeMap

func start() {
let homeMapCoordinator = HomeMapCoordinator(navigationController: self.navigationController)
self.childCoordinators.append(homeMapCoordinator)
homeMapCoordinator.start()
}

}
84 changes: 84 additions & 0 deletions iOS/MusicSpot/MusicSpot/MSCoordinator/HomeMapCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//
// HomeMapCoordinator.swift
// MusicSpot
//
// Created by 윤동주 on 11/28/23.
//

import UIKit

protocol HomeMapCoordinatorDelegate: AnyObject {

func popToHomeMap(from coordinator: Coordinator)

}

final class HomeMapCoordinator: Coordinator {

// MARK: - Properties

var navigationController: UINavigationController

var childCoordinators: [Coordinator] = []

var delegate: AppCoordinatorDelegate?

// MARK: - Initializer

init(navigationController: UINavigationController) {
self.navigationController = navigationController
}

// MARK: - Functions

func start() {
let homeMapViewController = HomeMapViewController()
homeMapViewController.delegate = self
self.navigationController.pushViewController(homeMapViewController, animated: true)
}

}

// MARK: - HomeMapViewController

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: - HomeMap Coordinator

extension HomeMapCoordinator: HomeMapCoordinatorDelegate {

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

}
15 changes: 15 additions & 0 deletions iOS/MusicSpot/MusicSpot/MSCoordinator/Protocol/Coordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Coordinator.swift
// MusicSpot
//
// Created by 윤동주 on 11/29/23.
//

import UIKit

protocol Coordinator: AnyObject {

var navigationController: UINavigationController { get }
var childCoordinators: [Coordinator] { get set }

}
56 changes: 56 additions & 0 deletions iOS/MusicSpot/MusicSpot/MSCoordinator/RewindCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// RewindCoordinator.swift
// MusicSpot
//
// Created by 윤동주 on 11/28/23.
//

import UIKit

final class RewindCoordinator: Coordinator {

// MARK: - Properties

var navigationController: UINavigationController

var childCoordinators: [Coordinator] = []

var delegate: HomeMapCoordinatorDelegate?

// MARK: - Initializer

init(navigationController: UINavigationController) {
self.navigationController = navigationController
}

// MARK: - Functions

func start() {
let rewindViewController = RewindViewController()
rewindViewController.delegate = self
self.navigationController.pushViewController(rewindViewController, animated: true)
}

}

// MARK: - RewindViewController

extension RewindCoordinator: RewindViewControllerDelegate {

func navigateToHomeMap() {
self.delegate?.popToHomeMap(from: self)
}

}

// MARK: - HomeMap Coordinator

extension RewindCoordinator: HomeMapCoordinatorDelegate {

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

}
48 changes: 48 additions & 0 deletions iOS/MusicSpot/MusicSpot/MSCoordinator/SaveJourneyCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// SearchMusicCoordinator.swift
// MusicSpot
//
// Created by 윤동주 on 11/29/23.
//

import UIKit

final class SaveJourneyCoordinator: Coordinator {

// MARK: - Properties

var navigationController: UINavigationController

var childCoordinators: [Coordinator] = []

var delegate: SearchMusicCoordinatorDelegate?

// MARK: - Initializer

init(navigationController: UINavigationController) {
self.navigationController = navigationController
}

// MARK: - Functions

func start() {
let saveJourneyViewController = SaveJourneyViewController()
saveJourneyViewController.delegate = self
self.navigationController.pushViewController(saveJourneyViewController, animated: true)
}

}

// MARK: - SaveJourneyViewController

extension SaveJourneyCoordinator: SaveJourneyViewControllerDelegate {

func navigateToHomeMap() {
self.delegate?.popToHomeMap(from: self)
}

func navigateToSearchMusic() {
self.delegate?.popToSearchMusic(from: self)
}

}
Loading