diff --git a/TournamentStats/UI/components/TableView.swift b/TournamentStats/UI/components/TableView.swift
index eaf7ee9..63f5347 100644
--- a/TournamentStats/UI/components/TableView.swift
+++ b/TournamentStats/UI/components/TableView.swift
@@ -22,6 +22,26 @@ class TableView : UITableView {
self.reference = wrapper
}
+ private func label(height: CGFloat, text: String) -> UILabel {
+ let label = UILabel(frame: CGRect(x: 0, y: 0, width: self.frame.width, height: height))
+ label.text = text
+ label.textColor = UIColor.white
+ label.backgroundColor = UIColor.clear
+ label.textAlignment = .center
+ return label
+ }
+
+ func setHeader(header: String) {
+ let label = self.label(height: 60.0, text: header)
+ label.font = Fonts.subTitle
+ self.tableHeaderView = label
+ }
+
+ func setFooter(footer: String) {
+ let label = self.label(height: 22.0, text: footer)
+ self.tableFooterView = label
+ }
+
override init(frame: CGRect, style: UITableView.Style) {
super.init(frame: frame, style: style)
self._initialize()
diff --git a/TournamentStats/UI/reports/InfographyView.swift b/TournamentStats/UI/reports/InfographyView.swift
index 50ab845..4ea53af 100644
--- a/TournamentStats/UI/reports/InfographyView.swift
+++ b/TournamentStats/UI/reports/InfographyView.swift
@@ -63,8 +63,7 @@ class InfographyView: UIView {
@IBOutlet weak var label51: UILabel!
@IBOutlet weak var hStack5b: UIStackView!
- @IBOutlet weak var tableView51: TableView!
-
+ @IBOutlet weak var collectionView51: UICollectionView!
override func awakeFromNib() {
super.awakeFromNib()
@@ -105,13 +104,15 @@ class InfographyView: UIView {
/////
- self.label11.text = "Biggest Winners".uppercased()
+// self.label11.text = "Biggest Winners".uppercased()
self.label12.text = "Most Cashes".uppercased()
self.label13.text = "Best average cash (7+)".uppercased()
self.tableView11.setData(data: generator.biggestWinners)
- self.tableView12.setData(data: generator.mostCashes)
- self.tableView13.setData(data: generator.averageCash)
+ self.tableView11.setHeader(header: "Biggest Winners")
+ self.tableView11.setFooter(footer: "* denotes a Main Event finalist")
+ self.tableView12.setData(data: generator.mostCashes, maxRows: 5)
+ self.tableView13.setData(data: generator.averageCash, maxRows: 5)
/////
@@ -134,10 +135,12 @@ class InfographyView: UIView {
/////
- self.label31.text = "Events by prizepool".uppercased()
- self.label32.text = "Events by entries".uppercased()
+// self.label31.text = "Events by prizepool".uppercased()
+// self.label32.text = "Events by entries".uppercased()
+ self.tableView31.setHeader(header: "Events by prizepool".uppercased())
self.tableView31.setData(data: generator.tourniesByPrizepool, maxRows: 5)
+ self.tableView32.setHeader(header: "Events by entries".uppercased())
self.tableView32.setData(data: generator.tourniesByEntries, maxRows: 5)
/////
@@ -155,8 +158,9 @@ class InfographyView: UIView {
self.label51.text = "Average Event".uppercased()
let ds = generator.averageEvent.first
- self.tableView51.dataSource = ds
- self.tableView51.delegate = ds
+ self.collectionView51.register(UINib(nibName: "StatCollectionViewCell", bundle: Bundle.main), forCellWithReuseIdentifier: "Stat")
+ self.collectionView51.dataSource = ds
+ self.collectionView51.delegate = ds
}
diff --git a/TournamentStats/UI/reports/InfographyView.xib b/TournamentStats/UI/reports/InfographyView.xib
index 23cf802..73e3477 100644
--- a/TournamentStats/UI/reports/InfographyView.xib
+++ b/TournamentStats/UI/reports/InfographyView.xib
@@ -13,14 +13,14 @@
-
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
+
+
-
+
-
+
-
+
-
+
-
+
@@ -114,18 +130,18 @@
-
+
-
+
-
+
-
+
@@ -133,53 +149,41 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
+
-
-
+
+
-
-
-
-
-
-
+
+
-
+
-
+
-
+
-
+
@@ -190,14 +194,14 @@
-
+
-
+
-
+
@@ -206,16 +210,16 @@
-
+
-
+
-
+
@@ -226,19 +230,29 @@
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
@@ -246,47 +260,42 @@
-
-
+
+
-
+
+
-
-
-
-
-
+
+
-
-
-
-
+
+
-
-
+
diff --git a/TournamentStats/report/structures/CountryCounter.swift b/TournamentStats/report/structures/CountryCounter.swift
index 1af3820..b97fe7a 100644
--- a/TournamentStats/report/structures/CountryCounter.swift
+++ b/TournamentStats/report/structures/CountryCounter.swift
@@ -18,7 +18,7 @@ final class CountryCounter : HTMLRepresentable, Aggregeable {
var copy = table
copy.remove(at: indexOfParam)
let count = copy.reduce(0) { $0 + $1.counter }
- return [paramCounter, CountryCounter(country: "Others", counter: count)]
+ return [paramCounter, CountryCounter(country: "not \(param)", counter: count)]
}
let count = table.reduce(0) { $0 + $1.counter }
@@ -60,28 +60,4 @@ final class CountryCounter : HTMLRepresentable, Aggregeable {
return PieChartDataEntry(value: Double(self.counter), label: self.country)
}
-// static func htmlHeaders() -> String {
-// var strings: [String] = []
-// strings.append("Country")
-// strings.append("Cashes")
-// let all = strings.joined(separator: "| ")
-// return " | "
-// }
-//
-// func html() -> String {
-//
-// let formattedCountry: String
-// if let flagoji = Locale.current.flagoji(from: self.country) {
-// formattedCountry = "\(flagoji) \(self.country)"
-// } else {
-// formattedCountry = self.country
-// }
-//
-// var strings: [String] = []
-// strings.append(formattedCountry)
-// strings.append("\(counter)")
-// let all = strings.joined(separator: "")
-// return " | | \(all) |
"
-// }
-
}
diff --git a/TournamentStats/report/structures/FestivalStats.swift b/TournamentStats/report/structures/FestivalStats.swift
index 1033ae8..319ed51 100644
--- a/TournamentStats/report/structures/FestivalStats.swift
+++ b/TournamentStats/report/structures/FestivalStats.swift
@@ -56,7 +56,6 @@ class FestivalStats : NSObject, UICollectionViewDataSource, UICollectionViewDele
return cell
}
-
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: 360.0, height: 100.0)
}
diff --git a/TournamentStats/report/structures/TournamentStats.swift b/TournamentStats/report/structures/TournamentStats.swift
index 8eec804..ce0a948 100644
--- a/TournamentStats/report/structures/TournamentStats.swift
+++ b/TournamentStats/report/structures/TournamentStats.swift
@@ -9,7 +9,7 @@
import Foundation
import UIKit
-class TournamentStats : NSObject, HTMLRepresentable, UITableViewDelegate, UITableViewDataSource {
+class TournamentStats : NSObject, HTMLRepresentable, UITableViewDelegate, UITableViewDataSource, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
var entries: Double
var buyin: Double
@@ -122,4 +122,48 @@ class TournamentStats : NSObject, HTMLRepresentable, UITableViewDelegate, UITabl
}
+ // 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 = "Entries"
+ value = NumberFormatter().string(from: NSNumber(value: self.entries))!
+ case 1:
+ name = "Buy-in".uppercased()
+ value = Formatter.currency.string(from: NSNumber(value: self.buyin))!
+ case 2:
+ name = "Prizepool".uppercased()
+ value = Formatter.currency.string(from: NSNumber(value: self.prizepool))!
+ case 3:
+ name = "Earnings".uppercased()
+ value = Formatter.currency.string(from: NSNumber(value: self.itmValue))!
+ 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 = UIFont.systemFont(ofSize: 20.0)
+ cell.valueLabel.font = UIFont.systemFont(ofSize: 56.0, weight: .thin)
+
+ return cell
+ }
+
+ func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
+ return CGSize(width: 360.0, height: 100.0)
+ }
+
}