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][Team10][Dumba, Min] MVVM 패턴적용, DetailView, CoreData #60

Open
wants to merge 18 commits into
base: team10
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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.

120 changes: 113 additions & 7 deletions iOS/SideDish/SideDish.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
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>
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit


@main
class AppDelegate: UIResponder, UIApplicationDelegate {

Expand Down
24 changes: 24 additions & 0 deletions iOS/SideDish/SideDish/Application/AppFlowCoordinator.swift
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 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator 를 도입하셨군요 :) 좋습니다.
혹시 그럼 Coordinator 는 왜 필요할까요?

private var navigationController: UINavigationController

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

navigationController도 let으로 해도 될 것 같습니다.

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()
}
}
17 changes: 17 additions & 0 deletions iOS/SideDish/SideDish/Application/DIContainer/AppDIContainer.swift
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 {

Choose a reason for hiding this comment

The 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hash 라는 이름이 처음 보는 저에겐 크게 와닿진 않네요.
로직을 파악하고난뒤에 hash가 어떨때 필요한 인자인지 알게 되었습니다.
읽기 좋은 코드는 다른곳을 찾아보지 않고 바로 봤을때 인지 할 수 있는 코드입니다.
매개변수명을 바꿔보는건 어떨까요? 🤔

}

// MARK: - ViewController
internal func makeBanchanDetailViewController(hash: Int, action: BanchanDetailViewModelAction) -> BanchanDetailViewController {
return BanchanDetailViewController.create(with: makeBanchanDetailViewModel(hash: hash, action: action))
}
}

26 changes: 26 additions & 0 deletions iOS/SideDish/SideDish/Application/SceneDelegate.swift
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()
}
}

Loading