diff --git a/Sources/View/Product/ProductListViewController.swift b/Sources/View/Product/ProductListViewController.swift index 0319b60..1c3e410 100644 --- a/Sources/View/Product/ProductListViewController.swift +++ b/Sources/View/Product/ProductListViewController.swift @@ -80,7 +80,7 @@ class ProductListViewController: TabmanViewController { bar.buttons.customize { (button) in button.font = .systemFont(ofSize: 12) } - + addBar(bar, dataSource: self, at: .top) } } @@ -104,27 +104,21 @@ extension ProductListViewController: PageboyViewControllerDataSource, TMBarDataS switch index { case 0: let item = TMBarItem(title: "전체") - item.image = R.image.cU() return item case 1: let item = TMBarItem(title: "GS25") - item.image = R.image.gs25() return item case 2: let item = TMBarItem(title: "CU") - item.image = R.image.cU() return item case 3: let item = TMBarItem(title: "MINI\nSTOP") - item.image = R.image.ministoP() return item case 4: let item = TMBarItem(title: "SEVEN\nELEVEN") - item.image = R.image.seveneleveN() return item case 5: let item = TMBarItem(title: "EMART") - item.image = R.image.emart24() return item default: let item = TMBarItem(title: "") diff --git a/Sources/View/Product/StoreMainViewController.swift b/Sources/View/Product/StoreMainViewController.swift index 0258d4d..3898bab 100644 --- a/Sources/View/Product/StoreMainViewController.swift +++ b/Sources/View/Product/StoreMainViewController.swift @@ -9,23 +9,27 @@ import UIKit import SnapKit import Then +import RxSwift + +class StoreMainViewController: UIViewController, UIScrollViewDelegate { + + let disposeBag = DisposeBag() -class StoreMainViewController: UIViewController { - let productModel = [ProductList]() let tableView = UITableView().then { $0.register(ProductTableViewCell.self, forCellReuseIdentifier: "productCell") $0.backgroundColor = R.color.background() } - + override func viewDidLoad() { super.viewDidLoad() setUpSubViews() - tableView.delegate = self - tableView.dataSource = self + tableView.rx + .setDelegate(self) + .disposed(by: disposeBag) } - + private func setUpSubViews() { view.addSubview(tableView) tableView.snp.makeConstraints { @@ -37,23 +41,10 @@ class StoreMainViewController: UIViewController { init(index: Int) { super.init(nibName: nil, bundle: nil) - tableView.tag = index + } - + required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } } - -extension StoreMainViewController: UITableViewDelegate, UITableViewDataSource { - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return productModel.count - } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - guard let cell = tableView.dequeueReusableCell(withIdentifier: "productCell", for: indexPath) - as? ProductTableViewCell else { return UITableViewCell() } - - return cell - } -} diff --git a/Sources/View/Reuseable/ProductTableViewCell.swift b/Sources/View/Reuseable/ProductTableViewCell.swift index c1f5da0..9666583 100644 --- a/Sources/View/Reuseable/ProductTableViewCell.swift +++ b/Sources/View/Reuseable/ProductTableViewCell.swift @@ -72,13 +72,11 @@ class ProductTableViewCell: UITableViewCell { // MARK: - public method - public func bind(title: String, price: String, store: [String]) { - // 후에 파라미터로 데이터 받아서 바인딩 - - // demo data - self.titleLabel.text = "돼지바" - self.priceLabel.text = "₩2500" - self.likeCounterLabel.text = "13" + public func bind(title: String, price: String, likeCount: String, store: [String]) { + + self.titleLabel.text = title + self.priceLabel.text = "₩\(price)" + self.likeCounterLabel.text = likeCount self.setStoreList([.cu, .gs25, .emart24]) self.fireButton.rx.tap