123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- //
- // RedemptionAreaFloorTableViewCell.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/7/16.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- import SwiftyMediator
- class RedemptionAreaFloorTableViewCell: UITableViewCell {
-
- class func cellWith(tableView:UITableView,indexPath:IndexPath) -> RedemptionAreaFloorTableViewCell {
- let ID = "RedemptionAreaFloorTableViewCell"
- tableView.register(RedemptionAreaFloorTableViewCell.self, forCellReuseIdentifier: ID)
- let cell : RedemptionAreaFloorTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! RedemptionAreaFloorTableViewCell
- cell.indexPath = indexPath
- return cell
- }
-
- override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
- super.init(style: style, reuseIdentifier: reuseIdentifier)
- setupViews()
- setupLayouts()
- }
-
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- var indexPath: IndexPath? {
- didSet {
-
- }
- }
- //MARK: - 设置view
- private func setupViews() {
- self.selectionStyle = .none
- addSubview(collectionView)
- }
-
- private func setupLayouts() {
- collectionView.snp.makeConstraints { (make) in
- make.edges.equalToSuperview()
- }
- }
-
- private lazy var collectionView: UICollectionView = {
- let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
- collectionView.delegate = self;
- collectionView.dataSource = self;
- collectionView.showsVerticalScrollIndicator = false
- collectionView.showsHorizontalScrollIndicator = false
- collectionView.backgroundColor = UIColor.white
- collectionView.contentInset = UIEdgeInsets(top: 0, left: 5, bottom: 5, right: 5)
- return collectionView
- }()
-
- private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
- let collectionViewLayout = UICollectionViewFlowLayout.init()
- collectionViewLayout.minimumLineSpacing = 5
- collectionViewLayout.minimumInteritemSpacing = 5
- return collectionViewLayout
- }()
-
- var cmsRedemptionAreaContent: CMSRedemptionAreaContent? {
- didSet{
- collectionView.reloadData()
- }
- }
- }
- extension RedemptionAreaFloorTableViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
- func numberOfSections(in collectionView: UICollectionView) -> Int {
- if !(cmsRedemptionAreaContent?.rule?.isEmpty ?? true) {
- return 1
- }else {
- return 0
- }
- }
-
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
- if !(cmsRedemptionAreaContent?.rule?.isEmpty ?? true) {
- return cmsRedemptionAreaContent?.rule?.count ?? 0
- }else {
- return 0
- }
- }
-
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
- let cmsRedemptionAreaRule = cmsRedemptionAreaContent?.rule?[indexPath.row]
- let cell = RedemptionAreaProductCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
- cell.cmsRedemptionAreaRule = cmsRedemptionAreaRule
- return cell
-
- }
-
- func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
- let cmsRedemptionAreaRule = cmsRedemptionAreaContent?.rule?[indexPath.row]
- Mediator.push(H5RouterModuleType.pushDetail(id: "\(cmsRedemptionAreaRule?.id ?? 0)"))
- }
-
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
- return CGSize(width:(kScreenWidth-15)/2, height: (kScreenWidth-15)/2 + 116)
- }
-
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
- return UIEdgeInsets(top:0, left: 0, bottom: 0, right: 0)
- }
-
- }
|