You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.9 KiB
68 lines
1.9 KiB
//
|
|
// MasterViewController.swift
|
|
// TournamentStats
|
|
//
|
|
// Created by Laurent Morvillier on 02/06/2019.
|
|
// Copyright © 2019 Stax River. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class MasterViewController: UITableViewController {
|
|
|
|
var detailViewController: DetailViewController? = nil
|
|
var ccManager: ChipCountManager = ChipCountManager(chipCounts: [], totalChips: 0.0)
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
self.ccManager = ChipCountParser.start()
|
|
|
|
// Do any additional setup after loading the view.
|
|
navigationItem.leftBarButtonItem = editButtonItem
|
|
|
|
if let split = splitViewController {
|
|
let controllers = split.viewControllers
|
|
detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController as? DetailViewController
|
|
}
|
|
}
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
clearsSelectionOnViewWillAppear = splitViewController!.isCollapsed
|
|
super.viewWillAppear(animated)
|
|
}
|
|
|
|
@objc
|
|
func generate(_ sender: Any) {
|
|
|
|
ReportGenerator.go()
|
|
|
|
}
|
|
|
|
|
|
// MARK: - Segues
|
|
|
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
|
}
|
|
|
|
// MARK: - Table View
|
|
|
|
override func numberOfSections(in tableView: UITableView) -> Int {
|
|
return 1
|
|
}
|
|
|
|
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
return self.ccManager.chipCounts.count
|
|
}
|
|
|
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
|
|
|
|
let chipCount = self.ccManager.chipCounts[indexPath.row]
|
|
cell.textLabel!.text = chipCount.player
|
|
cell.detailTextLabel?.text = chipCount.percentage(totalChips: self.ccManager.totalChips)
|
|
return cell
|
|
}
|
|
|
|
}
|
|
|
|
|