From 3705fdeb08cf7b01a34fa60c60d0d815bf658a40 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 28 Aug 2019 13:09:28 +0200 Subject: [PATCH] Layout improvements --- TournamentStats/AppDelegate.swift | 9 ++ TournamentStats/UI/Fonts.swift | 13 +- TournamentStats/UI/StackTableCell.swift | 2 +- .../UI/components/DataSourceWrapper.swift | 7 +- TournamentStats/UI/components/PieChart.swift | 7 +- TournamentStats/UI/components/TableView.swift | 2 + .../UI/reports/InfographyView.swift | 40 +++---- TournamentStats/UI/reports/InfographyView.xib | 112 +++++++++--------- .../UI/reports/StatCollectionViewCell.swift | 7 ++ .../UI/reports/StatCollectionViewCell.xib | 4 +- TournamentStats/report/Queries.swift | 8 +- .../report/structures/FestivalStats.swift | 8 +- .../structures/TournamentRepresentable.swift | 4 +- .../report/structures/TournamentStats.swift | 8 +- 14 files changed, 125 insertions(+), 106 deletions(-) diff --git a/TournamentStats/AppDelegate.swift b/TournamentStats/AppDelegate.swift index 9a7dbca..794cb13 100644 --- a/TournamentStats/AppDelegate.swift +++ b/TournamentStats/AppDelegate.swift @@ -18,6 +18,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + for fontFamilyName in UIFont.familyNames { + print("family: \(fontFamilyName)\n") + + for fontName in UIFont.fontNames(forFamilyName: fontFamilyName) { + print("font: \(fontName)") + } + } + + // UI stuff let splitViewController = window!.rootViewController as! UISplitViewController let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController diff --git a/TournamentStats/UI/Fonts.swift b/TournamentStats/UI/Fonts.swift index 3a05447..1caa8e1 100644 --- a/TournamentStats/UI/Fonts.swift +++ b/TournamentStats/UI/Fonts.swift @@ -10,10 +10,15 @@ import Foundation import UIKit class Fonts { + + static let monospaced: UIFont = UIFont(name: "Menlo-Regular", size: 18.0)! // UIFont.systemFont(ofSize: 18.0) + static let bigNumbers: UIFont = UIFont(name: "Menlo-Regular", size: 48.0)! - static let mainTitle: UIFont = UIFont.systemFont(ofSize: 64.0) - static let subTitle: UIFont = UIFont.systemFont(ofSize: 24.0) - static let pieChartEntries: UIFont = UIFont.boldSystemFont(ofSize: 28) - static let chartLegend: UIFont = UIFont.systemFont(ofSize: 18.0) + static let regular: UIFont = UIFont(name: "Menlo-Regular", size: 18.0)! // UIFont.systemFont(ofSize: 18.0) + static let bold: UIFont = UIFont(name: "Menlo-Bold", size: 18.0)! // UIFont.systemFont(ofSize: 18.0) + static let mainTitle: UIFont = UIFont(name: "Menlo-Regular", size: 72.0)! //UIFont.systemFont(ofSize: 72.0) + static let subTitle: UIFont = UIFont(name: "Menlo-Regular", size: 28.0)! //UIFont.systemFont(ofSize: 24.0) + static let pieChartEntries: UIFont = UIFont(name: "Menlo-Bold", size: 28.0)! //UIFont.boldSystemFont(ofSize: 28) + static let chartLegend: UIFont = UIFont(name: "Menlo-Regular", size: 18.0)! // UIFont.systemFont(ofSize: 18.0) } diff --git a/TournamentStats/UI/StackTableCell.swift b/TournamentStats/UI/StackTableCell.swift index b375bad..836f0a0 100644 --- a/TournamentStats/UI/StackTableCell.swift +++ b/TournamentStats/UI/StackTableCell.swift @@ -9,7 +9,7 @@ import Foundation import UIKit -class StackTableCell: UITableViewCell { +class StackTableCell : UITableViewCell { @IBOutlet weak var stackView: UIStackView! diff --git a/TournamentStats/UI/components/DataSourceWrapper.swift b/TournamentStats/UI/components/DataSourceWrapper.swift index 60ff446..26c3243 100644 --- a/TournamentStats/UI/components/DataSourceWrapper.swift +++ b/TournamentStats/UI/components/DataSourceWrapper.swift @@ -51,13 +51,13 @@ class DataSourceWrapper : NSObject, UITableViewDataSour cells = cr.cellValues() } - var font: UIFont = UIFont.boldSystemFont(ofSize: FONTSIZE) + var font: UIFont = Fonts.bold var leftAnchor = cell.contentView.leftAnchor for (index, value) in cells.enumerated() { if (indexPath.row > 0) { - font = self.columnDescriptors[index].number ? UIFont.monospacedDigitSystemFont(ofSize: FONTSIZE, weight: UIFont.Weight.regular) : UIFont.systemFont(ofSize: FONTSIZE) + font = self.columnDescriptors[index].number ? Fonts.monospaced : Fonts.regular } let labelContainer: UIView = UIView() @@ -69,7 +69,8 @@ class DataSourceWrapper : NSObject, UITableViewDataSour labelContainer.leftAnchor.constraint(equalTo: leftAnchor, constant: leftPadding).isActive = true leftAnchor = labelContainer.rightAnchor - labelContainer.backgroundColor = index.isMultiple(of: 2) ? UIColor.clear : UIColor(white: 0.9, alpha: 0.1) +// labelContainer.backgroundColor = index.isMultiple(of: 2) ? UIColor.clear : UIColor(white: 0.9, alpha: 0.1) + labelContainer.backgroundColor = UIColor.clear let multiplier: CGFloat = self.columnDescriptors[index].widthWeight / self.totalWidthWeigth labelContainer.widthAnchor.constraint(equalTo: cell.contentView.widthAnchor, multiplier: multiplier).isActive = true diff --git a/TournamentStats/UI/components/PieChart.swift b/TournamentStats/UI/components/PieChart.swift index bded110..9cc2ee5 100644 --- a/TournamentStats/UI/components/PieChart.swift +++ b/TournamentStats/UI/components/PieChart.swift @@ -14,11 +14,14 @@ class PieChart : PieChartView { override init(frame: CGRect) { super.init(frame: frame) + self.backgroundColor = UIColor.gray + self.holeColor = UIColor.clear self.usePercentValuesEnabled = true self.minOffset = 16.0 self.holeRadiusPercent = 0 self.drawEntryLabelsEnabled = false + self.transparentCircleRadiusPercent = 0 self.legend.textColor = UIColor.white self.legend.font = Fonts.chartLegend @@ -27,8 +30,8 @@ class PieChart : PieChartView { // self.legend.neededHeight = 203.0 // self.legend.neededWidth = 300.0 // self.legend.maxSizePercent = 30 -// self.legend.horizontalAlignment = .left - self.legend.verticalAlignment = .bottom + self.legend.horizontalAlignment = .left + self.legend.verticalAlignment = .top self.legend.drawInside = false // self.legend.yOffset = -30.0 // self.legend.xOffset = 10.0 diff --git a/TournamentStats/UI/components/TableView.swift b/TournamentStats/UI/components/TableView.swift index 63f5347..3d32d22 100644 --- a/TournamentStats/UI/components/TableView.swift +++ b/TournamentStats/UI/components/TableView.swift @@ -28,11 +28,13 @@ class TableView : UITableView { label.textColor = UIColor.white label.backgroundColor = UIColor.clear label.textAlignment = .center + label.font = Fonts.regular return label } func setHeader(header: String) { let label = self.label(height: 60.0, text: header) + label.textAlignment = .left label.font = Fonts.subTitle self.tableHeaderView = label } diff --git a/TournamentStats/UI/reports/InfographyView.swift b/TournamentStats/UI/reports/InfographyView.swift index 4ea53af..9d68f0c 100644 --- a/TournamentStats/UI/reports/InfographyView.swift +++ b/TournamentStats/UI/reports/InfographyView.swift @@ -104,23 +104,22 @@ class InfographyView: UIView { ///// -// 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.tableView11.setHeader(header: "Biggest Winners") self.tableView11.setFooter(footer: "* denotes a Main Event finalist") + self.tableView12.setData(data: generator.mostCashes, maxRows: 5) + self.tableView12.setHeader(header: "Most Cashes") self.tableView13.setData(data: generator.averageCash, maxRows: 5) - + self.tableView13.setHeader(header: "Best average cash (7+)") + ///// - self.label21.text = "Buy-in distribution".uppercased() - self.label22.text = "First prizes distribution".uppercased() - self.label23.text = "Prizepool distribution".uppercased() + self.label21.text = "Buy-in distribution" + self.label22.text = "First prizes distribution" +// self.label23.text = "Prizepool distribution".uppercased() - let pieChartFrame = CGRect(x: 0, y: 0, width: 500, height: 500) + let pieChartFrame = CGRect(x: 0, y: 0, width: 650, height: 500) let buyinDistribPie = PieChart(frame: pieChartFrame) buyinDistribPie.data = generator.tournamentBuyinDistribution.pieChartData self.container21.addSubview(buyinDistribPie) @@ -129,34 +128,33 @@ class InfographyView: UIView { firstPrizeDistributionPie.data = generator.firstPrizeDistribution.pieChartData self.container22.addSubview(firstPrizeDistributionPie) - let prizepoolDistribPie = PieChart(frame: pieChartFrame) - prizepoolDistribPie.data = generator.tournamentPrizepoolDistribution.pieChartData - self.container23.addSubview(prizepoolDistribPie) +// let prizepoolDistribPie = PieChart(frame: pieChartFrame) +// prizepoolDistribPie.data = generator.tournamentPrizepoolDistribution.pieChartData +// self.container23.addSubview(prizepoolDistribPie) ///// -// self.label31.text = "Events by prizepool".uppercased() -// self.label32.text = "Events by entries".uppercased() - - self.tableView31.setHeader(header: "Events by prizepool".uppercased()) + self.tableView31.setHeader(header: "Events by prizepool") self.tableView31.setData(data: generator.tourniesByPrizepool, maxRows: 5) - self.tableView32.setHeader(header: "Events by entries".uppercased()) + self.tableView32.setHeader(header: "Events by entries") self.tableView32.setData(data: generator.tourniesByEntries, maxRows: 5) ///// - self.label41.text = "USA vs World bracelets".uppercased() - self.label42.text = "Hold'em vs not hold'em".uppercased() + self.label41.text = "USA vs World bracelets" + self.label42.text = "Hold'em vs not Hold'em" let USABraceletsDistribPie = PieChart(frame: pieChartFrame) USABraceletsDistribPie.data = generator.USAvsWorldWins.pieChartData self.container41.addSubview(USABraceletsDistribPie) + self.container41.addMaxConstraints(view: USABraceletsDistribPie) let holdemDistributionPie = PieChart(frame: pieChartFrame) holdemDistributionPie.data = generator.holdemTournamentsDistribution.pieChartData self.container42.addSubview(holdemDistributionPie) - - self.label51.text = "Average Event".uppercased() + self.container42.addMaxConstraints(view: holdemDistributionPie) + + self.label51.text = "Average WSOP 2019 Event".uppercased() let ds = generator.averageEvent.first self.collectionView51.register(UINib(nibName: "StatCollectionViewCell", bundle: Bundle.main), forCellWithReuseIdentifier: "Stat") self.collectionView51.dataSource = ds diff --git a/TournamentStats/UI/reports/InfographyView.xib b/TournamentStats/UI/reports/InfographyView.xib index 73e3477..1cda17d 100644 --- a/TournamentStats/UI/reports/InfographyView.xib +++ b/TournamentStats/UI/reports/InfographyView.xib @@ -17,7 +17,7 @@ - +