<commit_before>//
//  CitySelectionTVC.swift
//  ParkenDD
//
//  Created by <NAME> on 30/06/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit

class CitySelectionTVC: UITableViewController {

	override func viewDidLoad() {
		super.viewDidLoad()
	}

	// MARK: - Table view data source

	override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
		return 1
	}

	override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
		if let citiesCount = (UIApplication.sharedApplication().delegate as? AppDelegate)?.supportedCities?.count {
			return citiesCount
		}
		return 0
	}

	override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
		let cell = tableView.dequeueReusableCellWithIdentifier("citySelectionCell", forIndexPath: indexPath)
		let supportedCities = (UIApplication.sharedApplication().delegate as? AppDelegate)?.supportedCities
		let citiesList = (UIApplication.sharedApplication().delegate as? AppDelegate)?.citiesList
		
		if let city = citiesList![supportedCities![indexPath.row]] { // FIXME: For the love of god, fix this!
			if city.activeSupport! {
				cell.textLabel?.text = city.name
				cell.textLabel?.font = UIFont.systemFontOfSize(16)
			} else {
				cell.textLabel?.text = city.name
				cell.textLabel?.font = UIFont.italicSystemFontOfSize(16)
			}
		}

		let selectedCity = NSUserDefaults.standardUserDefaults().stringForKey(Defaults.selectedCity)!
		cell.accessoryType = supportedCities![indexPath.row] == selectedCity ? UITableViewCellAccessoryType.Checkmark : UITableViewCellAccessoryType.None

		return cell
	}

	// MARK: - Table view delegate

	override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
		for row in 0..<tableView.numberOfRowsInSection(0) {
			tableView.cellForRowAtIndexPath(NSIndexPath(forRow: row, inSection: 0))?.accessoryType = UITableViewCellAccessoryType.None
		}
		tableView.cellForRowAtIndexPath(indexPath)?.accessoryType = UITableViewCellAccessoryType.Checkmark
		tableView.deselectRowAtIndexPath(indexPath, animated: true)

		let selectedCityID = (UIApplication.sharedApplication().delegate as? AppDelegate)?.supportedCities![indexPath.row] // FIXME: For the love of god, fix this!
		let selectedCityName = (UIApplication.sharedApplication().delegate as? AppDelegate)?.citiesList[selectedCityID!]?.name
		NSUserDefaults.standardUserDefaults().setObject(selectedCityID, forKey: Defaults.selectedCity)<commit_msg>Gray text instead of italic<commit_after>//
//  CitySelectionTVC.swift
//  ParkenDD
//
//  Created by <NAME> on 30/06/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit

class CitySelectionTVC: UITableViewController {

	override func viewDidLoad() {
		super.viewDidLoad()
	}

	// MARK: - Table view data source

	override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
		return 1
	}

	override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
		if let citiesCount = (UIApplication.sharedApplication().delegate as? AppDelegate)?.supportedCities?.count {
			return citiesCount
		}
		return 0
	}

	override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
		let cell = tableView.dequeueReusableCellWithIdentifier("citySelectionCell", forIndexPath: indexPath)
		let supportedCities = (UIApplication.sharedApplication().delegate as? AppDelegate)?.supportedCities
		let citiesList = (UIApplication.sharedApplication().delegate as? AppDelegate)?.citiesList
		
		if let city = citiesList![supportedCities![indexPath.row]] { // FIXME: For the love of god, fix this!
			if city.activeSupport! {
				cell.textLabel?.text = city.name
				cell.textLabel?.textColor = UIColor.blackColor()
			} else {
				cell.textLabel?.text = city.name
				cell.textLabel?.textColor = UIColor.lightGrayColor()
			}
		}

		let selectedCity = NSUserDefaults.standardUserDefaults().stringForKey(Defaults.selectedCity)!
		cell.accessoryType = supportedCities![indexPath.row] == selectedCity ? UITableViewCellAccessoryType.Checkmark : UITableViewCellAccessoryType.None

		return cell
	}

	// MARK: - Table view delegate

	override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
		for row in 0..<tableView.numberOfRowsInSection(0) {
			tableView.cellForRowAtIndexPath(NSIndexPath(forRow: row, inSection: 0))?.accessoryType = UITableViewCellAccessoryType.None
		}
		tableView.cellForRowAtIndexPath(indexPath)?.accessoryType = UITableViewCellAccessoryType.Checkmark
		tableView.deselectRowAtIndexPath(indexPath, animated: true)

		let selectedCityID = (UIApplication.sharedApplication().delegate as? AppDelegate)?.supportedCities![indexPath.row] // FIXME: For the love of god, fix this!
		let selectedCityName = (UIApplication.sharedApplication().delegate as? AppDelegate)?.citiesList[selectedCityID!]?.name
		NSUserDefaults.standardUserDefaults().setObject(selectedCityID, forKey: Defaults.selectedCity)
{'fraction_non_alphanumeric': 0.1024428684003152, 'fraction_numerical': 0.006698187549251379, 'mean_word_length': 5.370138017565872, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '403355', 'n_tokens_mistral': 1669, 'n_tokens_neox': 1465, 'n_words': 315}