Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
L-j-h-c committed Sep 29, 2022
2 parents dc6cefd + 443fe4b commit 39b5b81
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ extension MainDetailVC {
self.restaurantName = data.restaurant.name
self.mainInfoTVC.isInitialReload = self.mainInfoInitialReload
self.mainInfoTVC.setData(data: data)
self.menuTabVC.setData(data: data.menu)
self.menuTabVC.setData(data: data.menu, restaurantMenuBoard: data.restaurant.menuBoard)
self.reviewTabVC.restaurantName = data.restaurant.name
self.restaurantName = data.restaurant.name
self.scrapButtonInstance.isSelected = data.restaurant.isScrap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class AllImageCVC: UICollectionViewCell, UICollectionViewRegisterable {
// MARK: - Properties

static var isFromNib = false
let imgURLList = ["123", "123", "123", "123"] // 테스트용
var imgURLList = [String]() {didSet {
menuImageCV.reloadData()
}}

// MARK: - UI Components
lazy var menuImageCV: UICollectionView = {
Expand Down Expand Up @@ -60,18 +62,22 @@ extension AllImageCVC {
make.edges.equalToSuperview()
}
}

func setData(menuBoardList: [String]) {
self.imgURLList = menuBoardList
}
}

extension AllImageCVC: UICollectionViewDataSource {

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 4 //임시로 넣어둔 값 (서버 붙일때 수정 예정)
return imgURLList.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let allImageCell = menuImageCV.dequeueReusableCell(withReuseIdentifier: ImageCVC.className, for: indexPath) as? ImageCVC
else { return UICollectionViewCell() }
// allImageCell.setData(menuData: MenuTabVC().menuData[indexPath.row])
allImageCell.setData(menuBoard: imgURLList[indexPath.row])
return allImageCell
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@ extension ImageCVC {
photoImageView.layer.cornerRadius = 8
photoImageView.layer.masksToBounds = true
}

func setData(menuBoard: String) {
photoImageView.setImage(with: menuBoard)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ final class MenuTabVC: UIViewController {
}
}
}
var menuBoard: [String] = [] {
didSet {
DispatchQueue.main.async {
self.menuCV.reloadData()
}
}
}

let panGesture = UIPanGestureRecognizer()
weak var delegate: ScrollDeliveryDelegate?
var swipeDismissDelegate: SwipeDismissDelegate?
Expand Down Expand Up @@ -121,7 +129,7 @@ extension MenuTabVC {
menuCV.isScrollEnabled = false
}

func setData(data: [Menu]) {
func setData(data: [Menu], restaurantMenuBoard: [String]) {
var models: [MenuDataModel] = []
data.forEach {
models.append($0.toDomain())
Expand All @@ -140,8 +148,10 @@ extension MenuTabVC {
pickModel += notPickModel

self.menuData = pickModel
self.menuBoard = restaurantMenuBoard
}


private func addObserver() {
addObserverAction(.menuPhotoClicked) { noti in
if let slideData = noti.object as? ImageSlideDataModel {
Expand Down Expand Up @@ -225,7 +235,8 @@ extension MenuTabVC: UICollectionViewDelegate {
extension MenuTabVC: UICollectionViewDataSource {

func numberOfSections(in collectionView: UICollectionView) -> Int {
return 2
let count: Int = self.menuBoard.count == 0 ? 1 : 2
return count
}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
Expand Down Expand Up @@ -254,6 +265,9 @@ extension MenuTabVC: UICollectionViewDataSource {
case .menuImage:
guard let imageCell = menuCV.dequeueReusableCell(withReuseIdentifier: AllImageCVC.className, for: indexPath) as? AllImageCVC
else { return UICollectionViewCell() }
DispatchQueue.main.async {
imageCell.setData(menuBoardList: self.menuBoard)
}
return imageCell
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@ struct MenuDataModel: Codable {
let fat: Int?
let per: String?
}

extension MenuDataModel {

}

0 comments on commit 39b5b81

Please sign in to comment.