// // FestivalStats.swift // TournamentStats // // Created by Laurent Morvillier on 27/08/2019. // Copyright © 2019 Stax River. All rights reserved. // import Foundation import UIKit class FestivalStats : NSObject, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { var eventsCount: Int = 0 var totalPrizePool: Double = 0.0 var totalEntries: Double = 0.0 var cumulatedBuyins: Double = 0.0 // MARK: - UICollectionViewDataSource func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return 4 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Stat", for: indexPath) as! StatCollectionViewCell let name: String let value: String switch indexPath.row { case 0: name = "Total Events" value = "\(eventsCount)" case 1: name = "Total Prizepool".uppercased() value = self.totalPrizePool.currencyFormatted case 2: name = "Total Entries".uppercased() value = self.totalEntries.formatted case 3: name = "Cumulated Buy-ins".uppercased() value = self.cumulatedBuyins.currencyFormatted default: name = "" value = "" } cell.nameLabel.text = name.uppercased() cell.valueLabel.text = value cell.nameLabel.textColor = UIColor.white cell.valueLabel.textColor = UIColor.white cell.nameLabel.font = Fonts.regular cell.valueLabel.font = Fonts.bigNumbers return cell } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: 380.0, height: 90.0) } }