diff --git a/iOS/SideDish/SideDish.xcworkspace/xcuserdata/shim.xcuserdatad/UserInterfaceState.xcuserstate b/iOS/SideDish/SideDish.xcworkspace/xcuserdata/shim.xcuserdatad/UserInterfaceState.xcuserstate index 3cac05eda..f2ff49d80 100644 Binary files a/iOS/SideDish/SideDish.xcworkspace/xcuserdata/shim.xcuserdatad/UserInterfaceState.xcuserstate and b/iOS/SideDish/SideDish.xcworkspace/xcuserdata/shim.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanCustomCell.swift b/iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanCustomCell.swift index 9b46362d5..06576d0d7 100644 --- a/iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanCustomCell.swift +++ b/iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanCustomCell.swift @@ -28,6 +28,7 @@ class BanchanCustomCell: UICollectionViewCell { var banchan: Banchan? { didSet{ + loadImages(imgURL: banchan?.image ?? "") titleLabel.text = banchan?.title descriptionLabel.text = banchan?.description netPriceLabel.text = "1000" @@ -35,4 +36,18 @@ class BanchanCustomCell: UICollectionViewCell { priceTypeLabel.text = "3000" } } + + private func loadImages(imgURL: String) { + DispatchQueue.global().async { + FetchImageUseCase.fetch(network: NetworkSerivce.shared, + imgURL: self.banchan?.image ?? "") { (data) in + guard let data = data else { + return + } + DispatchQueue.main.async { + self.imageView.image = UIImage(data: data) + } + } + } + } } diff --git a/iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanCustomCellHeader.swift b/iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanCustomCellHeader.swift index 6813ce301..e5c796456 100644 --- a/iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanCustomCellHeader.swift +++ b/iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanCustomCellHeader.swift @@ -24,6 +24,11 @@ class BanchanCustomCellHeader: UICollectionReusableView { return UINib(nibName: identifier, bundle: nil) } + func configure(title: String, count: Int) { + titleLabel.text = title + cellCount = count + } + @objc func headerTouched(_ sender: UITapGestureRecognizer) { Toast(text: "\(cellCount)개 상품이 등록되어 있습니다.").show() } diff --git a/iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanListViewController.swift b/iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanListViewController.swift index ce9b28992..05f330b14 100644 --- a/iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanListViewController.swift +++ b/iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanListViewController.swift @@ -52,12 +52,6 @@ extension BanchanListViewController { let dataSource = DataSource(collectionView: banchanCollectionView) { (collectionView, indexPath, banchan) -> UICollectionViewCell? in guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: BanchanCustomCell.identifer, for: indexPath) as? BanchanCustomCell else { return nil } - FetchImageUseCase.fetch(network: NetworkSerivce.shared, imgURL: banchan.image) { (data) in - guard let data = data else { - return - } - cell.imageView.image = UIImage(data: data) - } cell.banchan = banchan return cell } @@ -69,8 +63,7 @@ extension BanchanListViewController { guard let view = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: BanchanCustomCellHeader.identifier, for: indexPath) as? BanchanCustomCellHeader else { return nil } - view.titleLabel.text = section.rawValue - view.cellCount = self.viewModel.count(section: section) + view.configure(title: section.rawValue, count: self.viewModel.count(section: section)) return view } @@ -91,7 +84,6 @@ extension BanchanListViewController { } } - // MARK: - Delegate extension BanchanListViewController: UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {