-
Notifications
You must be signed in to change notification settings - Fork 50
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][Team10][Dumba, Min] MVVM 패턴적용, DetailView, CoreData #60
base: team10
Are you sure you want to change the base?
Changes from 13 commits
323413b
7a969e8
9563786
927b33a
243c3af
24297cd
c1d4269
011fb6c
c2017e5
8f7f313
0adfedc
7b004ad
7839dec
7d2c39d
62f6611
d483f9c
03d7f70
70fb973
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Bucket | ||
uuid = "91552472-1CBE-4250-A5F4-58ED954FE0CE" | ||
type = "0" | ||
version = "2.0"> | ||
</Bucket> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
import UIKit | ||
|
||
|
||
@main | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// AppFlowCoordinator.swift | ||
// SideDish | ||
// | ||
// Created by 심영민 on 2021/04/27. | ||
// | ||
|
||
import UIKit | ||
|
||
class AppFlowCoordinator { | ||
private var navigationController: UINavigationController | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
private let appDIContainer: AppDIContainer | ||
|
||
init(navigationController: UINavigationController, appDIContainer: AppDIContainer) { | ||
self.navigationController = navigationController | ||
self.appDIContainer = appDIContainer | ||
} | ||
|
||
func start() { | ||
let banchanSceneDIContainer = appDIContainer.makeBanchanSceneDIContainer() | ||
let flow = banchanSceneDIContainer.makeBanchanSceneFlowCoordinator(navigationController: navigationController) | ||
flow.start() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// AppDIContainer.swift | ||
// SideDish | ||
// | ||
// Created by 심영민 on 2021/04/27. | ||
// | ||
|
||
import Foundation | ||
|
||
class AppDIContainer { | ||
lazy var apiNetworkService = DefaultNetworkSerivce() | ||
|
||
func makeBanchanSceneDIContainer() -> BanchanSceneDIContainer { | ||
let dependencies = BanchanSceneDIContainer.Dependencies.init(apiNetworkService: apiNetworkService) | ||
return BanchanSceneDIContainer(dependencies: dependencies) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// BanchanSceneDIContainer.swift | ||
// SideDish | ||
// | ||
// Created by 심영민 on 2021/04/27. | ||
// | ||
|
||
import UIKit | ||
|
||
class BanchanSceneDIContainer: BanchanSceneFlowCoordinatorDependencies { | ||
|
||
struct Dependencies { | ||
let apiNetworkService: NetworkService | ||
} | ||
|
||
private let dependencies: Dependencies | ||
|
||
init(dependencies: Dependencies) { | ||
self.dependencies = dependencies | ||
} | ||
|
||
// MARK: - Persistent Storages | ||
private func makeBanchanListStroage() -> CoreDataBanchanListStorage { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stroage -> storage 오타가 있는 것 같네요 :) |
||
return CoreDataBanchanListStorage() | ||
} | ||
|
||
// MARK: - Repositories | ||
private func makeBanchanListRepository() -> BanchanListRepository { | ||
return DefaultBanchanListRepository(network: dependencies.apiNetworkService, storage: makeBanchanListStroage()) | ||
} | ||
|
||
// MARK: - Use Cases | ||
private func makeFetchBanchanListUseCase() -> FetchBanchanListUseCase{ | ||
return DefaultFetchBanchanListUseCase(banchanListRepository: makeBanchanListRepository()) | ||
} | ||
|
||
// MARK: - ViewModel | ||
private func makeBanchanListViewModel(action: BanchanListViewModelAction) -> BanchanListViewModel { | ||
return BanchanListViewModel(fetchBanchanListUseCase: makeFetchBanchanListUseCase(), action: action) | ||
} | ||
|
||
// MARK: - ViewController | ||
internal func makeBanchanListViewController(action: BanchanListViewModelAction) -> BanchanListViewController { | ||
return BanchanListViewController.create(with: makeBanchanListViewModel(action: action)) | ||
} | ||
|
||
// MARK: - Flow Coordinator | ||
func makeBanchanSceneFlowCoordinator(navigationController: UINavigationController) -> BanchanSceneFlowCoordinator { | ||
return BanchanSceneFlowCoordinator(navigationController: navigationController, dependencies: self) | ||
} | ||
} | ||
|
||
extension BanchanSceneDIContainer { | ||
private func makeBanchanDetailRepository() -> BanchanDetailRepository { | ||
return DefaultBanchanDetailRepository(network: dependencies.apiNetworkService) | ||
} | ||
|
||
// MARK: - Use Cases | ||
private func makeFetchBanchanDetailUseCase() -> FetchBanchanDetailUseCase{ | ||
return DefaultFetchBanchanDetailUseCase(banchanDetailRepository: makeBanchanDetailRepository()) | ||
} | ||
|
||
// MARK: - ViewModel | ||
private func makeBanchanDetailViewModel(hash: Int, action: BanchanDetailViewModelAction) -> BanchanDetailViewModel { | ||
return BanchanDetailViewModel(hash: hash, fetchBanchanDetailUseCase: makeFetchBanchanDetailUseCase(), action: action) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hash 라는 이름이 처음 보는 저에겐 크게 와닿진 않네요. |
||
} | ||
|
||
// MARK: - ViewController | ||
internal func makeBanchanDetailViewController(hash: Int, action: BanchanDetailViewModelAction) -> BanchanDetailViewController { | ||
return BanchanDetailViewController.create(with: makeBanchanDetailViewModel(hash: hash, action: action)) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// SceneDelegate.swift | ||
// SideDish | ||
// | ||
// Created by 심영민 on 2021/04/20. | ||
// | ||
|
||
import UIKit | ||
|
||
class SceneDelegate: UIResponder, UIWindowSceneDelegate { | ||
|
||
var window: UIWindow? | ||
private let appDIContainer = AppDIContainer() | ||
private var flowCoordinator: AppFlowCoordinator? | ||
|
||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | ||
guard let windowScene = (scene as? UIWindowScene) else { return } | ||
window = UIWindow(windowScene: windowScene) | ||
let navigationController = UINavigationController() | ||
window?.rootViewController = navigationController | ||
flowCoordinator = AppFlowCoordinator(navigationController: navigationController, appDIContainer: appDIContainer) | ||
flowCoordinator?.start() | ||
window?.makeKeyAndVisible() | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coordinator
를 도입하셨군요 :) 좋습니다.혹시 그럼 Coordinator 는 왜 필요할까요?