Skip to content

Commit

Permalink
refactor : fix order of catagories
Browse files Browse the repository at this point in the history
  • Loading branch information
1song2 committed Apr 23, 2021
1 parent 61b3575 commit d36f63d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Binary file modified iOS/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@ class CollectionViewDataSource: NSObject, UICollectionViewDataSource {
super.init()
}

convenience init(mainDishes: [Dish], soupDishes: [Dish], sideDishes: [Dish]) {
self.init(allDishes: [DishList(category: .main, dishes: mainDishes),
DishList(category: .soup, dishes: soupDishes),
DishList(category: .side, dishes: sideDishes)])
}

func load(dishes: DishList) {
allDishes.append(dishes)
allDishes.enumerated().forEach { (index, dishList) in
if dishList.category == dishes.category {
allDishes[index].dishes = dishes.dishes
}
}
}

func numberOfSections(in collectionView: UICollectionView) -> Int {
Expand Down
4 changes: 2 additions & 2 deletions iOS/BanchanCode/BanchanCode/Domain/Entities/Dish.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ struct DishList {
}
}
}
let category: Category
let dishes: [Dish]
var category: Category
var dishes: [Dish]
}
5 changes: 4 additions & 1 deletion iOS/BanchanCode/BanchanCode/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ class MainViewController: UIViewController {
@IBOutlet weak var dishCollectionView: UICollectionView!
var mainDelegate: CollectionViewDelegate?
var mainDataSource: CollectionViewDataSource?
var mainDishes: [Dish]?
var soupDishes: [Dish]?
var sideDishes: [Dish]?

override func viewDidLoad() {
super.viewDidLoad()
mainDelegate = CollectionViewDelegate()
mainDataSource = CollectionViewDataSource(allDishes: [])
mainDataSource = CollectionViewDataSource(mainDishes: [], soupDishes: [], sideDishes: [])

dishCollectionView.delegate = mainDelegate
dishCollectionView.dataSource = mainDataSource
Expand Down

0 comments on commit d36f63d

Please sign in to comment.