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

쥬스메이커 [STEP 2] 제이티, Ari #119

Merged
merged 17 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
68927c4
feat: 쥬스 주문버튼 터치 시 Alret 표시되는 기능 구현
leeari95 Oct 25, 2021
c8f2ac6
feat: 주문 버튼 터치시 재고가 있는 경우와 없는 경우에 대한 기능 구현
HoneyCoding Oct 25, 2021
e083fff
feat: 과일의 재고가 바뀔 때 마다 화면에 반영되도록 기능 구현
leeari95 Oct 25, 2021
293f811
refactor: HIG 지침에 따라 Alert의 선택지 문구 수정
HoneyCoding Oct 26, 2021
a560ab2
refactor: Fruit타입을 FruitStore 내부에서 외부로 이동
leeari95 Oct 26, 2021
57031d7
refactor: JuiceMakerViewController의 UILabel 프로퍼티 이름 수정
HoneyCoding Oct 26, 2021
eb48bef
refactor: JuiceMakerViewController 내부 메서드명 수정
leeari95 Oct 26, 2021
0331594
refactor: JuiceMakerViewController 내부 메소드 순서 변경
HoneyCoding Oct 26, 2021
8edd150
refactor: orderJuiceButtonTapped 메서드 분리 및 리팩토링
leeari95 Oct 26, 2021
b28fab2
chore: 불필요한 주석 제거
HoneyCoding Oct 26, 2021
5d1c1da
chore: mixFruit 메서드 내부에 에러 문구를 수정
leeari95 Oct 26, 2021
f7bb20f
docs: README.md 파일 내용 추가
HoneyCoding Oct 26, 2021
8bfece8
refactor: 문자열을 모아놓은 enum Text 추가 및 숫자를 문자열로 형변환 하는 코드 수정
HoneyCoding Oct 28, 2021
5f09d5c
refactor: Juice 타입 리팩토링 및 Text 타입 이름 수정
leeari95 Oct 28, 2021
d252b60
refactor: Alert 버튼의 타이틀을 따로 Text 타입으로 구현
HoneyCoding Oct 28, 2021
0484cd1
refactor: FruitStore 내부에 전역변수를 enum Const 타입으로 리팩토링
leeari95 Oct 28, 2021
494468c
refactor: JuiceMakerViewController 내부의 showOutOfStockAlert 메소드의 코드 일부…
HoneyCoding Oct 28, 2021
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
Prev Previous commit
Next Next commit
refactor: Juice 타입 리팩토링 및 Text 타입 이름 수정
- Juice 타입에 채택되어있는CustomStringConvertible 프로토콜 제거
- Juice 타입 내부 프로퍼티명 description에서 name으로 수정
- Text 타입 이름을 Message로 변
  • Loading branch information
leeari95 committed Oct 28, 2021
commit 5f09d5c38f38e8fd42a759e3b91f06e3d9913d29
20 changes: 10 additions & 10 deletions JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class JuiceMakerViewController: UIViewController {
case orderMangoJuiceButton:
juice = .mango
default:
showNotificationAlert(message: Text.unknownError.description)
showNotificationAlert(message: Message.unknownError.description)
return
}

Expand All @@ -60,19 +60,19 @@ class JuiceMakerViewController: UIViewController {
func mixFruit(juice: Juice) {
do {
try juiceMaker.mixFruit(juice: juice)
showNotificationAlert(message: Text.juiceFinish(juice: juice).description)
showNotificationAlert(message: Message.juiceFinish(juice: juice).description)
} catch RequestError.fruitStockOut {
showOutOfStockAlert()
} catch let error as RequestError {
showNotificationAlert(message: error.errorDescription)
} catch {
showNotificationAlert(message: Text.unknownError.description)
showNotificationAlert(message: Message.unknownError.description)
}
}

@objc func fruitLabelChanged(notification: Notification) {
guard let fruit = notification.object as? Fruit else {
showNotificationAlert(message: Text.unknownError.description)
showNotificationAlert(message: Message.unknownError.description)
return
}
currentStockLabelUpdate(fruit: fruit, label: fruitlabel(of: fruit))
Expand All @@ -89,11 +89,11 @@ class JuiceMakerViewController: UIViewController {
func currentStockLabelUpdate(fruit: Fruit, label: UILabel) {
do {
let stock = try FruitStore.shared.stock(fruit: fruit)
label.text = stock.description
label.Message = stock.description
} catch let error as RequestError {
showNotificationAlert(message: error.errorDescription)
} catch {
showNotificationAlert(message: Text.unknownError.description)
showNotificationAlert(message: Message.unknownError.description)
}
}

Expand All @@ -112,17 +112,17 @@ class JuiceMakerViewController: UIViewController {
}
}

func showNotificationAlert(message: String, title: String = Text.ok.description) {
func showNotificationAlert(message: String, title: String = Message.ok.description) {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
let cancel = UIAlertAction(title: title, style: .cancel, handler: nil)
alert.addAction(cancel)
present(alert, animated: true, completion: nil)
}

func showOutOfStockAlert() {
let alert = UIAlertController(title: nil, message: Text.outOfStock.description, preferredStyle: .alert)
let cancelAction = UIAlertAction(title: Text.cancel.description, style: .cancel, handler: nil)
let okAction = UIAlertAction(title: Text.ok.description, style: .default) { _ in
let alert = UIAlertController(title: nil, message: Message.outOfStock.description, preferredStyle: .alert)
let cancelAction = UIAlertAction(title: Message.cancel.description, style: .cancel, handler: nil)
let okAction = UIAlertAction(title: Message.ok.description, style: .default) { _ in
guard let viewController = self.storyboard?.instantiateViewController(withIdentifier: "FruitStoreView") else { return }

Choose a reason for hiding this comment

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

  • 재고 화면 view controller 는 왜 이름이 FruitStoreview 인가요?
  • 해당 함수를 따로 빼면 어떤가요?

Copy link
Member Author

Choose a reason for hiding this comment

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

해당 부분도 피드백 반영하여 개선해보았습니다 😄
오늘 시간내서 코드리뷰 해주셔서 정말 감사합니다! 많은 도움이 되었어요!!!!! 😊🙏🏻

self.present(viewController, animated: true, completion: nil)
}
Expand Down
4 changes: 2 additions & 2 deletions JuiceMaker/JuiceMaker/Model/JuiceMaker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foundation

fileprivate typealias Recipe = [Fruit: Int]

enum Juice: String, CustomStringConvertible {
enum Juice: String {
case strawberry = "딸기"
case banana = "바나나"
case kiwi = "키위"
Expand All @@ -17,7 +17,7 @@ enum Juice: String, CustomStringConvertible {
case mango = "망고"
case mangoKiwi = "망키"

var description: String {
var name: String {
return rawValue
}

Expand Down
4 changes: 2 additions & 2 deletions JuiceMaker/JuiceMaker/Model/Text.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

enum Text: CustomStringConvertible {
enum Message: CustomStringConvertible {
case juiceFinish(juice: Juice)
case unknownError
case outOfStock
Expand All @@ -17,7 +17,7 @@ enum Text: CustomStringConvertible {
var description: String {
switch self {
case .juiceFinish(let juice):
return "\(juice) 쥬스 나왔습니다! 맛있게 드세요!"
return "\(juice.name) 쥬스 나왔습니다! 맛있게 드세요!"
case .unknownError:
return "알 수 없는 에러가 발생했습니다."
case .outOfStock:
Expand Down