Skip to content

Commit

Permalink
Feature : Toaster 기능 수정 (#11)
Browse files Browse the repository at this point in the history
중복 toaster 제거 및 section 상품 수에 맞는 메세지 출력
  • Loading branch information
dahun-lee-daji committed Apr 22, 2021
1 parent 989e153 commit 3b1a3f8
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ViewController: UIViewController {
bind()
menuListViewModel.requestDishes()
dataSource = configureDataSource()

sleep(3)

var snapshot = NSDiffableDataSourceSnapshot<Dishes,Dish>()
Expand All @@ -49,7 +49,7 @@ class ViewController: UIViewController {
configuration.textProperties.font = .boldSystemFont(ofSize: 16)
configuration.textProperties.color = .systemBlue

let tap = UITapGestureRecognizer(target: self, action: #selector(handleTapGesture(recognizer:)))
let tap = CustomTapGestureRecognizer(target: self, action: #selector(handleTapGesture(recognizer:)), dishCount: headerItem.dishes.count)
headerView.addGestureRecognizer(tap)

// Apply the configuration to header view
Expand Down Expand Up @@ -157,15 +157,17 @@ class ViewController: UIViewController {
return label
}

@objc private func handleTapGesture(recognizer: UITapGestureRecognizer) {

self.view.makeToast("Toaster 출력 \(recognizer.view)")
@objc private func handleTapGesture(recognizer: CustomTapGestureRecognizer) {
self.view.hideAllToasts()
self.view.makeToast("상품 \(recognizer.dishCount)개 있어요!")
}

}

enum section : String, CaseIterable {
case main = "main"
case soup = "soup"
case side = "side"
class CustomTapGestureRecognizer: UITapGestureRecognizer {
var dishCount : Int

init(target: Any?, action: Selector?, dishCount: Int) {
self.dishCount = dishCount
super.init(target: target, action: action)
}
}

0 comments on commit 3b1a3f8

Please sign in to comment.