-
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.
* fix: tuist generate가 되지않는 현상 해결 Feature프로젝트에 Sources, Resources, Tests 폴더가 형성되지 않아 발생하는 버그를 수정하였습니다. * chore: APP단 Coordinator관련 파일 추가 및 폴더링 * feat: AppCoordinator 구성 * feat: TabBarCoordinator 구현 예제 * build: Coordinator 필수 구성요소 모듈화 * chrow: 리뷰 적용 앱코디네이터에서 탭바코디네이터 자식 추가, 탭바 코디네이터 selectedImage 작성
- Loading branch information
1 parent
1dda640
commit 58fa5d9
Showing
24 changed files
with
449 additions
and
1 deletion.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
iOS/Projects/App/Sources/AScene/Coordinator/ACoordinator.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,28 @@ | ||
// | ||
// ACoordinator.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Coordinator | ||
import UIKit | ||
|
||
final class ACoordinator: ACoordinating { | ||
var navigationController: UINavigationController | ||
var childCoordinators: [Coordinating] = [] | ||
weak var finishDelegate: CoordinatorFinishDelegate? | ||
var flow: CoordinatorFlow = .tabBar | ||
|
||
init( | ||
navigationController: UINavigationController | ||
) { | ||
self.navigationController = navigationController | ||
} | ||
|
||
func start() { | ||
let viewController = AViewController() | ||
navigationController.pushViewController(viewController, animated: false) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
iOS/Projects/App/Sources/AScene/Coordinator/Protocol/ACoordinating.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,12 @@ | ||
// | ||
// ACoordinating.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Coordinator | ||
import Foundation | ||
|
||
protocol ACoordinating: Coordinating {} |
17 changes: 17 additions & 0 deletions
17
iOS/Projects/App/Sources/AScene/ViewController/AViewController.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,17 @@ | ||
// | ||
// AViewController.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class AViewController: UITabBarController { | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
view.backgroundColor = .blue | ||
} | ||
} |
File renamed without changes.
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
28 changes: 28 additions & 0 deletions
28
iOS/Projects/App/Sources/BScene/Coordinator/BCoordinator.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,28 @@ | ||
// | ||
// BCoordinator.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Coordinator | ||
import UIKit | ||
|
||
final class BCoordinator: BCoordinating { | ||
var navigationController: UINavigationController | ||
var childCoordinators: [Coordinating] = [] | ||
weak var finishDelegate: CoordinatorFinishDelegate? | ||
var flow: CoordinatorFlow = .tabBar | ||
|
||
init( | ||
navigationController: UINavigationController | ||
) { | ||
self.navigationController = navigationController | ||
} | ||
|
||
func start() { | ||
let viewController = BViewController() | ||
navigationController.pushViewController(viewController, animated: false) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
iOS/Projects/App/Sources/BScene/Coordinator/Protocol/BCoordinating.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,12 @@ | ||
// | ||
// BCoordinating.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Coordinator | ||
import Foundation | ||
|
||
protocol BCoordinating: Coordinating {} |
17 changes: 17 additions & 0 deletions
17
iOS/Projects/App/Sources/BScene/ViewController/BViewController.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,17 @@ | ||
// | ||
// BViewController.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class BViewController: UITabBarController { | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
view.backgroundColor = .green | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
iOS/Projects/App/Sources/CScene/Coordinator/CCoordinator.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,28 @@ | ||
// | ||
// CCoordinator.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Coordinator | ||
import UIKit | ||
|
||
final class CCoordinator: CCoordinating { | ||
var navigationController: UINavigationController | ||
var childCoordinators: [Coordinating] = [] | ||
weak var finishDelegate: CoordinatorFinishDelegate? | ||
var flow: CoordinatorFlow = .tabBar | ||
|
||
init( | ||
navigationController: UINavigationController | ||
) { | ||
self.navigationController = navigationController | ||
} | ||
|
||
func start() { | ||
let viewController = CViewController() | ||
navigationController.pushViewController(viewController, animated: false) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
iOS/Projects/App/Sources/CScene/Coordinator/Protocol/CCoordinating.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,12 @@ | ||
// | ||
// CCoordinating.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Coordinator | ||
import Foundation | ||
|
||
protocol CCoordinating: Coordinating {} |
16 changes: 16 additions & 0 deletions
16
iOS/Projects/App/Sources/CScene/ViewController/CViewController.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,16 @@ | ||
// | ||
// CViewController.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class CViewController: UITabBarController { | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
view.backgroundColor = .red | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
iOS/Projects/App/Sources/CommonScene/Coordinator/AppCoordinator.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,38 @@ | ||
// | ||
// AppCoordinator.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Coordinator | ||
import UIKit | ||
|
||
final class AppCoordinator: AppCoordinating { | ||
var navigationController: UINavigationController | ||
var childCoordinators: [Coordinating] = [] | ||
weak var finishDelegate: CoordinatorFinishDelegate? | ||
var flow: CoordinatorFlow = .tabBar | ||
|
||
init( | ||
navigationController: UINavigationController | ||
) { | ||
self.navigationController = navigationController | ||
} | ||
|
||
func start() { | ||
// (LoginFlow와 TabBarFlow 분기 처리) (todo) | ||
let tabBarCoordinator = TabBarCoordinator(navigationController: navigationController) | ||
childCoordinators.append(tabBarCoordinator) | ||
tabBarCoordinator.start() | ||
} | ||
|
||
func startLoginFlow() { | ||
// (LoginViewController 추가되면 로직 추가) (todo) | ||
} | ||
|
||
func startTabBarFlow() { | ||
// (TabBarController 추가되면 로직 추가) (todo) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
iOS/Projects/App/Sources/CommonScene/Coordinator/Protocol/AppCoordinating.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,15 @@ | ||
// | ||
// AppCoordinating.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Coordinator | ||
import Foundation | ||
|
||
protocol AppCoordinating: Coordinating { | ||
func startLoginFlow() | ||
func startTabBarFlow() | ||
} |
14 changes: 14 additions & 0 deletions
14
iOS/Projects/App/Sources/TabBarScene/Coordinator/Protocol/TabBarCoordinating.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,14 @@ | ||
// | ||
// TabBarCoordinating.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Coordinator | ||
import UIKit | ||
|
||
protocol TabBarCoordinating: Coordinating { | ||
var tabBarController: UITabBarController { get } | ||
} |
124 changes: 124 additions & 0 deletions
124
iOS/Projects/App/Sources/TabBarScene/Coordinator/TabBarCoordinator.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,124 @@ | ||
// | ||
// TabBarCoordinator.swift | ||
// WeTri | ||
// | ||
// Created by 안종표 on 2023/11/15. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Coordinator | ||
import UIKit | ||
|
||
// MARK: - TabBarCoordinator | ||
|
||
final class TabBarCoordinator: TabBarCoordinating { | ||
var navigationController: UINavigationController | ||
var childCoordinators: [Coordinating] = [] | ||
weak var finishDelegate: CoordinatorFinishDelegate? | ||
var flow: CoordinatorFlow = .tabBar | ||
var tabBarController: UITabBarController | ||
|
||
init( | ||
navigationController: UINavigationController, | ||
tabBarController: UITabBarController = UITabBarController() | ||
) { | ||
self.navigationController = navigationController | ||
self.tabBarController = tabBarController | ||
} | ||
|
||
func start() { | ||
let tabBarViewControllers = TabBarPage.allCases.map { | ||
return makePageNavigationController(page: $0) | ||
} | ||
let tabBarController = makeTabBarController(tabBarViewControllers: tabBarViewControllers) | ||
navigationController.pushViewController(tabBarController, animated: false) | ||
} | ||
|
||
private func startTabBarCoordinator(page: TabBarPage, pageNavigationViewController: UINavigationController) { | ||
switch page { | ||
case .home: | ||
let homeCoordinator = ACoordinator(navigationController: pageNavigationViewController) | ||
childCoordinators.append(homeCoordinator) | ||
homeCoordinator.finishDelegate = self | ||
homeCoordinator.start() | ||
case .record: | ||
let recordCoordinator = BCoordinator(navigationController: pageNavigationViewController) | ||
childCoordinators.append(recordCoordinator) | ||
recordCoordinator.finishDelegate = self | ||
recordCoordinator.start() | ||
case .profile: | ||
let profileCoordinator = CCoordinator(navigationController: pageNavigationViewController) | ||
childCoordinators.append(profileCoordinator) | ||
profileCoordinator.finishDelegate = self | ||
profileCoordinator.start() | ||
} | ||
} | ||
|
||
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 { | ||
tabBarController.setViewControllers(tabBarViewControllers, animated: false) | ||
return tabBarController | ||
} | ||
} | ||
|
||
// MARK: CoordinatorFinishDelegate | ||
|
||
extension TabBarCoordinator: CoordinatorFinishDelegate { | ||
func flowDidFinished(childCoordinator: Coordinating) { | ||
childCoordinators = childCoordinators.filter { | ||
return $0.flow != childCoordinator.flow | ||
} | ||
} | ||
} | ||
|
||
// MARK: - TabBarPage | ||
|
||
private enum TabBarPage: CaseIterable { | ||
case home | ||
case record | ||
case profile | ||
} | ||
|
||
private extension TabBarPage { | ||
var title: String { | ||
switch self { | ||
case .home: | ||
return "홈" | ||
case .record: | ||
return "기록" | ||
case .profile: | ||
return "프로필" | ||
} | ||
} | ||
|
||
var image: UIImage? { | ||
switch self { | ||
case .home: | ||
return UIImage(systemName: "house") | ||
case .record: | ||
return UIImage(systemName: "star") | ||
case .profile: | ||
return UIImage(systemName: "person") | ||
} | ||
} | ||
|
||
var selectedImage: UIImage? { | ||
switch self { | ||
case .home: | ||
return UIImage(systemName: "house.fill") | ||
case .record: | ||
return UIImage(systemName: "star.fill") | ||
case .profile: | ||
return UIImage(systemName: "person.fill") | ||
} | ||
} | ||
} |
Oops, something went wrong.