123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- //
- // RedemptionAreaSpecialTwoTableViewCell.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/7/17.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- class RedemptionAreaSpecialTwoTableViewCell: UITableViewCell {
- class func cellWith(tableView:UITableView,indexPath:IndexPath) -> RedemptionAreaSpecialTwoTableViewCell {
- let ID = "RedemptionAreaSpecialTwoTableViewCell"
- tableView.register(RedemptionAreaSpecialTwoTableViewCell.self, forCellReuseIdentifier: ID)
- let cell : RedemptionAreaSpecialTwoTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! RedemptionAreaSpecialTwoTableViewCell
- 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 {
-
- }
- }
- //MRAK: - 设置View
- private func setupViews() {
- self.selectionStyle = .none
- backgroundColor = UIColor.white
- addSubview(collectionView)
- }
-
- private func setupLayouts() {
- collectionView.snp.remakeConstraints {(make) in
- make.top.left.right.equalToSuperview()
- make.height.equalTo(275*kScaleWidth)
- }
- }
-
- private lazy var collectionView: UICollectionView = {
- let collectionView = UICollectionView.init(frame: CGRect.zero,collectionViewLayout: collectionViewLayout)
- collectionView.backgroundColor = UIColor.white
- collectionView.delegate = self;
- collectionView.dataSource = self;
- collectionView.showsVerticalScrollIndicator = false
- collectionView.showsHorizontalScrollIndicator = false
- collectionView.isScrollEnabled = false
- return collectionView
- }()
-
- private lazy var collectionViewLayout: SepcialTwoTypeLayout = {
- let collectionViewLayout = SepcialTwoTypeLayout()
- return collectionViewLayout
- }()
-
-
- var cmsRedemptionAreaContent: CMSRedemptionAreaContent? {
- didSet{
- collectionView.reloadData()
- }
- }
-
- }
- extension RedemptionAreaSpecialTwoTableViewCell: 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 = SpecialTwoTypeCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
- cell.cmsRedemptionAreaRule = cmsRedemptionAreaRule
- return cell
-
- }
-
- func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
- let cmsRedemptionAreaRule = cmsRedemptionAreaContent?.rule?[indexPath.row]
- RedemptionAreaViewModel.shared.pushVC(cmsRedemptionAreaRule: cmsRedemptionAreaRule)
-
- }
-
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
- return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
-
- }
- }
|