parent
3bf0aa4eb4
commit
6e89912d22
@ -0,0 +1,17 @@ |
|||||||
|
// |
||||||
|
// StatCollectionViewCell.swift |
||||||
|
// TournamentStats |
||||||
|
// |
||||||
|
// Created by Laurent Morvillier on 27/08/2019. |
||||||
|
// Copyright © 2019 Stax River. All rights reserved. |
||||||
|
// |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import UIKit |
||||||
|
|
||||||
|
class StatCollectionViewCell: UICollectionViewCell { |
||||||
|
|
||||||
|
@IBOutlet weak var nameLabel: UILabel! |
||||||
|
@IBOutlet weak var valueLabel: UILabel! |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> |
||||||
|
<device id="retina6_1" orientation="portrait"> |
||||||
|
<adaptation id="fullscreen"/> |
||||||
|
</device> |
||||||
|
<dependencies> |
||||||
|
<deployment identifier="iOS"/> |
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/> |
||||||
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/> |
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> |
||||||
|
</dependencies> |
||||||
|
<objects> |
||||||
|
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> |
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> |
||||||
|
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="Stat" id="Ua3-L2-QPG" customClass="StatCollectionViewCell" customModule="TournamentStats" customModuleProvider="target"> |
||||||
|
<rect key="frame" x="0.0" y="0.0" width="344" height="100"/> |
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> |
||||||
|
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO"> |
||||||
|
<rect key="frame" x="0.0" y="0.0" width="344" height="100"/> |
||||||
|
<autoresizingMask key="autoresizingMask"/> |
||||||
|
<subviews> |
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="M1K-Qd-Z8y" userLabel="Name"> |
||||||
|
<rect key="frame" x="8" y="8" width="328" height="24"/> |
||||||
|
<constraints> |
||||||
|
<constraint firstAttribute="height" constant="24" id="zlH-fj-ZZH"/> |
||||||
|
</constraints> |
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/> |
||||||
|
<nil key="textColor"/> |
||||||
|
<nil key="highlightedColor"/> |
||||||
|
</label> |
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FkP-so-0B7" userLabel="Value"> |
||||||
|
<rect key="frame" x="8" y="36" width="328" height="56"/> |
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/> |
||||||
|
<nil key="textColor"/> |
||||||
|
<nil key="highlightedColor"/> |
||||||
|
</label> |
||||||
|
</subviews> |
||||||
|
</view> |
||||||
|
<constraints> |
||||||
|
<constraint firstItem="M1K-Qd-Z8y" firstAttribute="top" secondItem="Ua3-L2-QPG" secondAttribute="top" constant="8" id="5ba-YO-Iuh"/> |
||||||
|
<constraint firstItem="M1K-Qd-Z8y" firstAttribute="leading" secondItem="Ua3-L2-QPG" secondAttribute="leading" constant="8" id="DNu-yX-KiG"/> |
||||||
|
<constraint firstAttribute="trailing" secondItem="M1K-Qd-Z8y" secondAttribute="trailing" constant="8" id="Fib-tI-dzT"/> |
||||||
|
<constraint firstItem="FkP-so-0B7" firstAttribute="top" secondItem="M1K-Qd-Z8y" secondAttribute="bottom" constant="4" id="UOR-47-lzI"/> |
||||||
|
<constraint firstAttribute="trailing" secondItem="FkP-so-0B7" secondAttribute="trailing" constant="8" id="d3G-1w-NXT"/> |
||||||
|
<constraint firstItem="FkP-so-0B7" firstAttribute="leading" secondItem="Ua3-L2-QPG" secondAttribute="leading" constant="8" id="lXd-Fg-DzQ"/> |
||||||
|
<constraint firstAttribute="bottom" secondItem="FkP-so-0B7" secondAttribute="bottom" constant="8" id="oum-uT-owE"/> |
||||||
|
</constraints> |
||||||
|
<viewLayoutGuide key="safeArea" id="K6A-mR-pGE"/> |
||||||
|
<size key="customSize" width="344" height="100"/> |
||||||
|
<connections> |
||||||
|
<outlet property="nameLabel" destination="M1K-Qd-Z8y" id="ygh-W2-ZRS"/> |
||||||
|
<outlet property="valueLabel" destination="FkP-so-0B7" id="3Fx-XW-Iwg"/> |
||||||
|
</connections> |
||||||
|
<point key="canvasLocation" x="-133.33333333333334" y="66.294642857142861"/> |
||||||
|
</collectionViewCell> |
||||||
|
</objects> |
||||||
|
</document> |
||||||
@ -0,0 +1,64 @@ |
|||||||
|
// |
||||||
|
// 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 = 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) |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
Loading…
Reference in new issue