diff --git a/iOS/Projects/App/Sources/CommonScene/Coordinator/AppCoordinator.swift b/iOS/Projects/App/Sources/CommonScene/Coordinator/AppCoordinator.swift index 868eff8b..104def73 100644 --- a/iOS/Projects/App/Sources/CommonScene/Coordinator/AppCoordinator.swift +++ b/iOS/Projects/App/Sources/CommonScene/Coordinator/AppCoordinator.swift @@ -9,6 +9,8 @@ import Coordinator import UIKit +// MARK: - AppCoordinator + final class AppCoordinator: AppCoordinating { var navigationController: UINavigationController var childCoordinators: [Coordinating] = [] @@ -28,11 +30,19 @@ final class AppCoordinator: AppCoordinating { tabBarCoordinator.start() } - func startLoginFlow() { + func showLoginFlow() { // (LoginViewController 추가되면 로직 추가) (todo) } - func startTabBarFlow() { + func showTabBarFlow() { // (TabBarController 추가되면 로직 추가) (todo) } } + +// MARK: CoordinatorFinishDelegate + +extension AppCoordinator: CoordinatorFinishDelegate { + func flowDidFinished(childCoordinator: Coordinating) { + // TODO: 로그아웃 Flow, 로그인 Flow (앱 실행 도중 발생되는 분기처리) + } +} diff --git a/iOS/Projects/App/Sources/CommonScene/Coordinator/Protocol/AppCoordinating.swift b/iOS/Projects/App/Sources/CommonScene/Coordinator/Protocol/AppCoordinating.swift index 03ddbfa9..f2489b8c 100644 --- a/iOS/Projects/App/Sources/CommonScene/Coordinator/Protocol/AppCoordinating.swift +++ b/iOS/Projects/App/Sources/CommonScene/Coordinator/Protocol/AppCoordinating.swift @@ -10,6 +10,6 @@ import Coordinator import Foundation protocol AppCoordinating: Coordinating { - func startLoginFlow() - func startTabBarFlow() + func showLoginFlow() + func showTabBarFlow() } diff --git a/iOS/Projects/App/Sources/TabBarScene/Coordinator/TabBarCoordinator.swift b/iOS/Projects/App/Sources/TabBarScene/Coordinator/TabBarCoordinator.swift index c82379d1..4e8ed94d 100644 --- a/iOS/Projects/App/Sources/TabBarScene/Coordinator/TabBarCoordinator.swift +++ b/iOS/Projects/App/Sources/TabBarScene/Coordinator/TabBarCoordinator.swift @@ -34,6 +34,14 @@ final class TabBarCoordinator: TabBarCoordinating { navigationController.pushViewController(tabBarController, animated: false) } + private func makePageNavigationController(page: TabBarPage) -> UINavigationController { + let navigationController = UINavigationController() + let tabBarItem = UITabBarItem(title: page.title, image: page.image, selectedImage: page.selectedImage) + navigationController.tabBarItem = tabBarItem + startTabBarCoordinator(page: page, pageNavigationViewController: navigationController) + return navigationController + } + private func startTabBarCoordinator(page: TabBarPage, pageNavigationViewController: UINavigationController) { switch page { case .home: @@ -54,14 +62,6 @@ final class TabBarCoordinator: TabBarCoordinating { } } - private func makePageNavigationController(page: TabBarPage) -> UINavigationController { - let navigationController = UINavigationController() - let tabBarItem = UITabBarItem(title: page.title, image: page.image, selectedImage: page.selectedImage) - navigationController.tabBarItem = tabBarItem - startTabBarCoordinator(page: page, pageNavigationViewController: navigationController) - return navigationController - } - private func makeTabBarController( tabBarViewControllers: [UIViewController] ) -> UITabBarController { diff --git a/iOS/Projects/Core/Coordinator/Sources/CoordinatorFlow.swift b/iOS/Projects/Core/Coordinator/Sources/CoordinatorFlow.swift index ab09463f..3afc3d69 100644 --- a/iOS/Projects/Core/Coordinator/Sources/CoordinatorFlow.swift +++ b/iOS/Projects/Core/Coordinator/Sources/CoordinatorFlow.swift @@ -13,4 +13,6 @@ import Foundation public enum CoordinatorFlow { case login case tabBar + case workoutSetting + case workout } diff --git a/iOS/Projects/Features/Record/Sources/Common/Coordinator/Delegate/WorkoutSettingCoordinatorFinishDelegate.swift b/iOS/Projects/Features/Record/Sources/Common/Coordinator/Delegate/WorkoutSettingCoordinatorFinishDelegate.swift new file mode 100644 index 00000000..9fbaa228 --- /dev/null +++ b/iOS/Projects/Features/Record/Sources/Common/Coordinator/Delegate/WorkoutSettingCoordinatorFinishDelegate.swift @@ -0,0 +1,13 @@ +// +// WorkoutSettingCoordinatorFinishDelegate.swift +// RecordFeature +// +// Created by 안종표 on 2023/11/20. +// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. +// + +import Foundation + +protocol WorkoutSettingCoordinatorFinishDelegate: AnyObject { + func workoutSettingCoordinatorDidFinished(workoutSetting: WorkoutSetting) +} diff --git a/iOS/Projects/Features/Record/Sources/Common/Coordinator/Protocol/RecordFeatureCoordinating.swift b/iOS/Projects/Features/Record/Sources/Common/Coordinator/Protocol/RecordFeatureCoordinating.swift new file mode 100644 index 00000000..98d4119c --- /dev/null +++ b/iOS/Projects/Features/Record/Sources/Common/Coordinator/Protocol/RecordFeatureCoordinating.swift @@ -0,0 +1,15 @@ +// +// RecordFeatureCoordinating.swift +// RecordFeature +// +// Created by 안종표 on 2023/11/20. +// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. +// + +import Coordinator +import Foundation + +protocol RecordFeatureCoordinating: Coordinating { + func showSettingFlow() + func showWorkoutFlow(workoutSetting: WorkoutSetting) +} diff --git a/iOS/Projects/Features/Record/Sources/Common/Coordinator/Protocol/WorkoutCoordinating.swift b/iOS/Projects/Features/Record/Sources/Common/Coordinator/Protocol/WorkoutCoordinating.swift new file mode 100644 index 00000000..6a69e029 --- /dev/null +++ b/iOS/Projects/Features/Record/Sources/Common/Coordinator/Protocol/WorkoutCoordinating.swift @@ -0,0 +1,16 @@ +// +// WorkoutCoordinating.swift +// RecordFeature +// +// Created by 안종표 on 2023/11/20. +// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. +// + +import Coordinator +import Foundation + +protocol WorkoutCoordinating: Coordinating { + func pushWorkoutSummaryViewController() + func pushWorkoutMapViewController() + func pushWorkoutResultViewController() +} diff --git a/iOS/Projects/Features/Record/Sources/Common/Coordinator/Protocol/WorkoutSettingCoordinating.swift b/iOS/Projects/Features/Record/Sources/Common/Coordinator/Protocol/WorkoutSettingCoordinating.swift new file mode 100644 index 00000000..e5b7bfe7 --- /dev/null +++ b/iOS/Projects/Features/Record/Sources/Common/Coordinator/Protocol/WorkoutSettingCoordinating.swift @@ -0,0 +1,18 @@ +// +// WorkoutSettingCoordinating.swift +// RecordFeature +// +// Created by 안종표 on 2023/11/20. +// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. +// + +import Coordinator +import Foundation + +protocol WorkoutSettingCoordinating: Coordinating { + func pushWorkoutSelectViewController() + func pushWorkoutEnvironmentSetupViewController(workoutSetting: WorkoutSetting) + func pushOpponentSearchViewController(workoutSetting: WorkoutSetting) + func pushCountdownViewController(workoutSetting: WorkoutSetting) + func finish(workoutSetting: WorkoutSetting) +} diff --git a/iOS/Projects/Features/Record/Sources/Common/Coordinator/RecordFeatureCoordinator.swift b/iOS/Projects/Features/Record/Sources/Common/Coordinator/RecordFeatureCoordinator.swift new file mode 100644 index 00000000..49237a47 --- /dev/null +++ b/iOS/Projects/Features/Record/Sources/Common/Coordinator/RecordFeatureCoordinator.swift @@ -0,0 +1,65 @@ +// +// RecordFeatureCoordinator.swift +// RecordFeature +// +// Created by 안종표 on 2023/11/20. +// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. +// + +import Coordinator +import UIKit + +// MARK: - RecordFeatureCoordinator + +public final class RecordFeatureCoordinator: RecordFeatureCoordinating { + public var navigationController: UINavigationController + public var childCoordinators: [Coordinating] = [] + public weak var finishDelegate: CoordinatorFinishDelegate? + public var flow: CoordinatorFlow = .workoutSetting + public var recordContainerViewController: RecordContainerViewController + + public init( + navigationController: UINavigationController + ) { + self.navigationController = navigationController + recordContainerViewController = RecordContainerViewController() + } + + public func start() { + navigationController.pushViewController(recordContainerViewController, animated: false) + } + + func showSettingFlow() { + let workoutSettingCoordinator = WorkoutSettingCoordinator(navigationController: navigationController) + childCoordinators.append(workoutSettingCoordinator) + workoutSettingCoordinator.finishDelegate = self + workoutSettingCoordinator.settingDidFinishedDelegate = self + workoutSettingCoordinator.start() + } + + func showWorkoutFlow(workoutSetting _: WorkoutSetting) { + let workoutCoordinator = WorkoutCoordinator(navigationController: navigationController) + childCoordinators.append(workoutCoordinator) + workoutCoordinator.finishDelegate = self + workoutCoordinator.start() + } +} + +// MARK: CoordinatorFinishDelegate + +extension RecordFeatureCoordinator: CoordinatorFinishDelegate { + public func flowDidFinished(childCoordinator: Coordinating) { + childCoordinators = childCoordinators.filter { + $0.flow != childCoordinator.flow + } + navigationController.popToRootViewController(animated: false) + } +} + +// MARK: WorkoutSettingCoordinatorFinishDelegate + +extension RecordFeatureCoordinator: WorkoutSettingCoordinatorFinishDelegate { + func workoutSettingCoordinatorDidFinished(workoutSetting: WorkoutSetting) { + showWorkoutFlow(workoutSetting: workoutSetting) + } +} diff --git a/iOS/Projects/Features/Record/Sources/Common/Coordinator/WorkoutCoordinator.swift b/iOS/Projects/Features/Record/Sources/Common/Coordinator/WorkoutCoordinator.swift new file mode 100644 index 00000000..345c94aa --- /dev/null +++ b/iOS/Projects/Features/Record/Sources/Common/Coordinator/WorkoutCoordinator.swift @@ -0,0 +1,40 @@ +// +// WorkoutCoordinator.swift +// RecordFeature +// +// Created by 안종표 on 2023/11/20. +// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. +// + +import Coordinator +import UIKit + +final class WorkoutCoordinator: WorkoutCoordinating { + var navigationController: UINavigationController + var childCoordinators: [Coordinating] = [] + weak var finishDelegate: CoordinatorFinishDelegate? + var flow: CoordinatorFlow = .workout + + init(navigationController: UINavigationController) { + self.navigationController = navigationController + } + + func start() { + pushWorkoutSummaryViewController() + } + + func pushWorkoutSummaryViewController() { + let workoutSummaryViewController = WorkoutSummaryViewController( + viewModel: WorkoutSummaryViewModel() + ) + navigationController.pushViewController(workoutSummaryViewController, animated: false) + } + + func pushWorkoutMapViewController() { + // TODO: 뷰 컨트롤러 시작 로직 작성 + } + + func pushWorkoutResultViewController() { + // TODO: 뷰 컨트롤러 시작 로직 작성 + } +} diff --git a/iOS/Projects/Features/Record/Sources/Common/Coordinator/WorkoutSettingCoordinator.swift b/iOS/Projects/Features/Record/Sources/Common/Coordinator/WorkoutSettingCoordinator.swift new file mode 100644 index 00000000..760ce8be --- /dev/null +++ b/iOS/Projects/Features/Record/Sources/Common/Coordinator/WorkoutSettingCoordinator.swift @@ -0,0 +1,49 @@ +// +// WorkoutSettingCoordinator.swift +// RecordFeature +// +// Created by 안종표 on 2023/11/20. +// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. +// + +import Coordinator +import UIKit + +final class WorkoutSettingCoordinator: WorkoutSettingCoordinating { + var navigationController: UINavigationController + var childCoordinators: [Coordinating] = [] + weak var finishDelegate: CoordinatorFinishDelegate? + var flow: CoordinatorFlow = .workoutSetting + weak var settingDidFinishedDelegate: WorkoutSettingCoordinatorFinishDelegate? + + init(navigationController: UINavigationController) { + self.navigationController = navigationController + } + + func start() { + pushWorkoutSelectViewController() + } + + func pushWorkoutSelectViewController() { + let workoutSelectViewController = WorkoutSelectViewController() + navigationController.pushViewController(workoutSelectViewController, animated: false) + } + + func pushWorkoutEnvironmentSetupViewController(workoutSetting _: WorkoutSetting) { + // TODO: WorkoutEnvironmentSetupViewController의 Usecase에 workoutSetting 객체를 전달해줘야한다. + let workoutEnvironmentViewController = WorkoutEnvironmentSetupViewController() + navigationController.pushViewController(workoutEnvironmentViewController, animated: false) + } + + func pushOpponentSearchViewController(workoutSetting _: WorkoutSetting) { + // TODO: 뷰 컨트롤러 시작 로직 작성 + } + + func pushCountdownViewController(workoutSetting _: WorkoutSetting) { + // TODO: 뷰 컨트롤러 시작 로직 작성 + } + + func finish(workoutSetting: WorkoutSetting) { + settingDidFinishedDelegate?.workoutSettingCoordinatorDidFinished(workoutSetting: workoutSetting) + } +} diff --git a/iOS/Projects/Features/Record/Sources/Domain/Entity/WorkoutSetting.swift b/iOS/Projects/Features/Record/Sources/Domain/Entity/WorkoutSetting.swift new file mode 100644 index 00000000..5a716349 --- /dev/null +++ b/iOS/Projects/Features/Record/Sources/Domain/Entity/WorkoutSetting.swift @@ -0,0 +1,39 @@ +// +// WorkoutSetting.swift +// RecordFeature +// +// Created by 안종표 on 2023/11/20. +// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. +// + +import Foundation + +// MARK: - WorkoutSetting + +struct WorkoutSetting { + let mode: WorkoutMode + let environment: WorkoutEnvironment + let opponents: [Opponent] +} + +// MARK: - WorkoutMode + +enum WorkoutMode { + case run + case swim + case cycle +} + +// MARK: - WorkoutEnvironment + +enum WorkoutEnvironment { + case single + case multi +} + +// MARK: - Opponent + +struct Opponent { + let name: String + let distance: Int +} diff --git a/iOS/Projects/Features/Record/Sources/RecordScene/RecordViewController.swift b/iOS/Projects/Features/Record/Sources/RecordScene/RecordViewController.swift deleted file mode 100644 index 1db0832c..00000000 --- a/iOS/Projects/Features/Record/Sources/RecordScene/RecordViewController.swift +++ /dev/null @@ -1,10 +0,0 @@ -// -// RecordViewController.swift -// ProjectDescriptionHelpers -// -// Created by 안종표 on 2023/11/15. -// - -import UIKit - -class RecordViewController: UIViewController {}