-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from 29th-WE-SOPT-iOS-Part/feat/week2
Feat/week2 - 2차 과제 완료
- Loading branch information
Showing
43 changed files
with
1,464 additions
and
85 deletions.
There are no files selected for viewing
162 changes: 145 additions & 17 deletions
162
sopt_29th_Assignment/sopt_29th_Assignment.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+96.3 KB
(150%)
....xcodeproj/project.xcworkspace/xcuserdata/kone.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
sopt_29th_Assignment/sopt_29th_Assignment/Coordinator/Application/HomeCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// HomeCoordinator.swift | ||
// sopt_29th_Assignment | ||
// | ||
// Created by 송지훈 on 2021/10/18. | ||
// | ||
|
||
import UIKit | ||
|
||
class HomeCoordinator: BaseCoordinator, CoordinatorFinishOutput { | ||
|
||
// MARK: - Coodinator finish output | ||
var finishScene: (() -> Void)? | ||
|
||
// MARK: - Vars & Lets | ||
private let router: RouterProtocol | ||
private let coordinatorFactory: CoordinatorFactoryProtocol | ||
private let moduleFactory: ModuleFactoryProtocol | ||
|
||
// MARK: - Init | ||
init( | ||
router: RouterProtocol, | ||
coordinatorFactory: CoordinatorFactoryProtocol, | ||
moduleFactory: ModuleFactoryProtocol | ||
) { | ||
self.router = router | ||
self.coordinatorFactory = coordinatorFactory | ||
self.moduleFactory = moduleFactory | ||
} | ||
|
||
override func start() { | ||
self.showHomeVC() | ||
} | ||
|
||
} | ||
|
||
// MARK: - Show a view scene | ||
extension HomeCoordinator { | ||
private func showHomeVC() { | ||
let vc = moduleFactory.instantiateHomeVC() | ||
self.router.setRootModule(vc) | ||
} | ||
} | ||
|
43 changes: 43 additions & 0 deletions
43
sopt_29th_Assignment/sopt_29th_Assignment/Coordinator/Application/LibraryCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// LibraryCoordinator.swift | ||
// sopt_29th_Assignment | ||
// | ||
// Created by 송지훈 on 2021/10/18. | ||
// | ||
|
||
import UIKit | ||
|
||
class LibraryCoordinator: BaseCoordinator, CoordinatorFinishOutput { | ||
|
||
// MARK: - Coodinator finish output | ||
var finishScene: (() -> Void)? | ||
|
||
// MARK: - Vars & Lets | ||
private let router: RouterProtocol | ||
private let coordinatorFactory: CoordinatorFactoryProtocol | ||
private let moduleFactory: ModuleFactoryProtocol | ||
|
||
// MARK: - Init | ||
init( | ||
router: RouterProtocol, | ||
coordinatorFactory: CoordinatorFactoryProtocol, | ||
moduleFactory: ModuleFactoryProtocol | ||
) { | ||
self.router = router | ||
self.coordinatorFactory = coordinatorFactory | ||
self.moduleFactory = moduleFactory | ||
} | ||
|
||
override func start() { | ||
self.showLibraryVC() | ||
} | ||
|
||
} | ||
|
||
// MARK: - Show a view scene | ||
extension LibraryCoordinator { | ||
private func showLibraryVC() { | ||
let vc = moduleFactory.instantitateLibraryVC() | ||
self.router.setRootModule(vc) | ||
} | ||
} |
139 changes: 139 additions & 0 deletions
139
sopt_29th_Assignment/sopt_29th_Assignment/Coordinator/Application/MainTabCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
// | ||
// MainTabCoordinator.swift | ||
// sopt_29th_Assignment | ||
// | ||
// Created by 송지훈 on 2021/10/18. | ||
// | ||
|
||
import UIKit | ||
|
||
typealias Scene = ((UINavigationController) -> Void) | ||
|
||
class MainTabCoordinator : BaseCoordinator, CoordinatorFinishOutput{ | ||
|
||
// MARK: - Coodinator finish output | ||
var finishScene: (() -> Void)? | ||
|
||
// MARK: - Vars & Lets | ||
private let router: RouterProtocol | ||
private let coordinatorFactory: CoordinatorFactoryProtocol | ||
private let moduleFactory: ModuleFactoryProtocol | ||
private var mainTabController: MainTabBarControllable? | ||
|
||
// MARK: - Init | ||
init( | ||
router: RouterProtocol, | ||
coordinatorFactory: CoordinatorFactoryProtocol, | ||
moduleFactory: ModuleFactoryProtocol | ||
) { | ||
self.router = router | ||
self.coordinatorFactory = coordinatorFactory | ||
self.moduleFactory = moduleFactory | ||
} | ||
|
||
// MARK: - Coordinator | ||
override func start() { | ||
if self.mainTabController == nil { | ||
self.showMainTabBarController() | ||
} | ||
guard let mainTab = self.mainTabController else { return } | ||
mainTab.selectTab(0) | ||
self.startCoordinator() | ||
} | ||
|
||
private func startCoordinator() { | ||
self.childCoordinators.forEach { | ||
$0.start() | ||
} | ||
} | ||
} | ||
|
||
extension MainTabCoordinator { | ||
private func showMainTabBarController() { | ||
self.mainTabController = self.moduleFactory.instantiateMainTabBarController() | ||
self.mainTabController?.onHomeScene = runHomeScene() | ||
self.mainTabController?.onShortScene = runShortScene() | ||
self.mainTabController?.onWritingScene = runWritingScene() | ||
self.mainTabController?.onSubscribeScene = runSubscribeScene() | ||
self.mainTabController?.onLibraryScene = runLibraryScene() | ||
self.router.dismissModule(animated: false) { | ||
self.router.push(self.mainTabController) | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Run Scenes | ||
extension MainTabCoordinator { | ||
private func runHomeScene() -> Scene { | ||
return { [weak self] navController in | ||
guard let `self` = self else { | ||
return } | ||
if navController.viewControllers.isEmpty == true { | ||
let coordinator = self.coordinatorFactory.makeHomeCoordinator( | ||
coordinatorFactory: self.coordinatorFactory, | ||
moduleFactory: self.moduleFactory, | ||
navController: navController) | ||
self.addDependency(coordinator) | ||
coordinator.start() | ||
} | ||
} | ||
} | ||
|
||
|
||
private func runShortScene() -> Scene { | ||
return { [weak self] navController in | ||
guard let `self` = self else { return } | ||
if navController.viewControllers.isEmpty == true { | ||
let coordinator = self.coordinatorFactory.makeShortCoordinator( | ||
coordinatorFactory: self.coordinatorFactory, | ||
moduleFactory: self.moduleFactory, | ||
navController: navController) | ||
self.addDependency(coordinator) | ||
coordinator.start() | ||
} | ||
} | ||
} | ||
|
||
private func runWritingScene() -> Scene { | ||
return { [weak self] navController in | ||
guard let `self` = self else { return } | ||
if navController.viewControllers.isEmpty == true { | ||
let coordinator = self.coordinatorFactory.makeWritingCoordinator( | ||
coordinatorFactory: self.coordinatorFactory, | ||
moduleFactory: self.moduleFactory, | ||
navController: navController) | ||
self.addDependency(coordinator) | ||
coordinator.start() | ||
} | ||
} | ||
} | ||
|
||
private func runSubscribeScene() -> Scene { | ||
return { [weak self] navController in | ||
guard let `self` = self else { return } | ||
if navController.viewControllers.isEmpty == true { | ||
let coordinator = self.coordinatorFactory.makeSubscribeCoordinator( | ||
coordinatorFactory: self.coordinatorFactory, | ||
moduleFactory: self.moduleFactory, | ||
navController: navController) | ||
self.addDependency(coordinator) | ||
coordinator.start() | ||
} | ||
} | ||
} | ||
|
||
private func runLibraryScene() -> Scene { | ||
return { [weak self] navController in | ||
guard let `self` = self else { return } | ||
if navController.viewControllers.isEmpty == true { | ||
let coordinator = self.coordinatorFactory.makeLibraryCoordinator( | ||
coordinatorFactory: self.coordinatorFactory, | ||
moduleFactory: self.moduleFactory, | ||
navController: navController) | ||
self.addDependency(coordinator) | ||
coordinator.start() | ||
} | ||
} | ||
} | ||
} | ||
|
43 changes: 43 additions & 0 deletions
43
sopt_29th_Assignment/sopt_29th_Assignment/Coordinator/Application/ShortsCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// ShortsCoordinator.swift | ||
// sopt_29th_Assignment | ||
// | ||
// Created by 송지훈 on 2021/10/18. | ||
// | ||
|
||
import UIKit | ||
|
||
class ShortsCoordinator: BaseCoordinator, CoordinatorFinishOutput { | ||
|
||
// MARK: - Coodinator finish output | ||
var finishScene: (() -> Void)? | ||
|
||
// MARK: - Vars & Lets | ||
private let router: RouterProtocol | ||
private let coordinatorFactory: CoordinatorFactoryProtocol | ||
private let moduleFactory: ModuleFactoryProtocol | ||
|
||
// MARK: - Init | ||
init( | ||
router: RouterProtocol, | ||
coordinatorFactory: CoordinatorFactoryProtocol, | ||
moduleFactory: ModuleFactoryProtocol | ||
) { | ||
self.router = router | ||
self.coordinatorFactory = coordinatorFactory | ||
self.moduleFactory = moduleFactory | ||
} | ||
|
||
override func start() { | ||
self.showShortsVC() | ||
} | ||
|
||
} | ||
|
||
// MARK: - Show a view scene | ||
extension ShortsCoordinator { | ||
private func showShortsVC() { | ||
let vc = moduleFactory.instantiateShortVC() | ||
self.router.setRootModule(vc) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.