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 all 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
Binary file added Docs/Detail&SoldOut.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/MainView.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Order.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Toast.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,46 @@ Team 10
- Bongf
- K

## 실행 화면

### Main View

<img src = "https://github.com/ghis22130/sidedish/blob/dev/iOS/Docs/MainView.gif?raw=true" width = "40%">

💁‍♂️ 메인 화면에서 **메인요리**, **국물요리**, **밑반찬** 으로 분류 된 음식들을 상, 하로 스크롤 하여 탐색 하실 수 있습니다.

💁‍♂️ 각 반찬들의 이름과 용량, 간단한 설명, 정가, 할인 가격, 할인 정보를 확인하실 수 있습니다.



### Detail View & Sold Out

<p align = "center"><img src = "https://github.com/ghis22130/sidedish/blob/dev/iOS/Docs/Detail&SoldOut.gif?raw=true" width = "40%"></p>

💁‍♂️ 메인 화면에서 원하는 반찬을 클릭하시면 해당 반찬에 대한 상세한 정보를 얻으실 수 있습니다.

💁‍♂️ 해당 반찬의 재고가 없으면 아쉽지만 `주문 하기` 버튼은 `일시 품절`로 바뀌며 버튼이 비활성화 되어 주문하실 수 없습니다.



### Order

<p align = "center"><img src = "https://github.com/ghis22130/sidedish/blob/dev/iOS/Docs/Order.gif?raw=true" width = "40%"></p>

💁‍♂️ 원하시는 반찬에 대한 재고가 있으면 `주문하기` 버튼이 활성화 되어있으며 주문 진행이 가능합니다.

💁‍♂️ 하지만 현재 재고보다 많은 수량을 주문하려 할시에는 `Alert` 로 재고가 부족함을 알립니다.

💁‍♂️ 재고 안에서 주문을 하실 경우에는 성공적으로 주문 접수가 완료되며 `주문이 완료되었습니다` 라는 알림과 함께 Main 화면으로 이동하게 됩니다.



### Toast

<p align = "center"><img src = "https://github.com/ghis22130/sidedish/blob/dev/iOS/Docs/Toast.gif?raw=true" width = "40%"></p>

💁‍♂️ 메인 화면에서 **메인요리**, **국물요리**, **밑반찬** 코너의 헤더를 탭하게 되면 화면 중앙 하단에 Toast로 해당 코너의 등록된 반찬 종류의 개수를 알 수 있습니다.

## 브랜치 전략

폴더를 iOS와 BE 두개로 나누어서 관리합니다.
Expand Down

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.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>SideDish.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>5</integer>
<integer>6</integer>
</dict>
</dict>
</dict>
Expand Down
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