<commit_before>//
//  EditViewController.swift
//  Passengr
//
//  Created by <NAME> on 11/28/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit

class EditViewController: UITableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 0
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 0
    }

    /*
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath)

        // Configure the cell...

        return cell
    }
    */

    /*
    // Override to support conditional editing of the table view.
    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        // Return false if you do not want the specified item to be editable.
        return true
    }
    */

    /*
    // Override to support editing the table view.
    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {
            // Delete the row from the data source
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
        } else if editingStyle == .Insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }    
    }
    */

    /*
    // Override to support rearranging the table view.
    override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {

    }
    */

    /*
    // Override to support conditional rearranging of the table view.
    override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        // Return false if you do not want the item to be re-orderable.
        return true
    }
    */

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */
    @IBAction func handleDoneButton(sender: AnyObject) {
        self.dismissViewControllerAnimated(true, completion: nil)
    }

}<commit_msg>Add edit view controller<commit_after>//
//  EditViewController.swift
//  Passengr
//
//  Created by <NAME> on 11/28/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit

private let reuseIdentifier = "PassEditCell"

class EditViewController: UITableViewController {
    
    private var passes: [String] {
        return ["Blewett", "Cayuse", "Chinook", "Disautel", "Manastash", "Sherman", "Snoqualmie", "Stevens", "Wauconda", "White"]
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        self.tableView.editing = true
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

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

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.passes.count
    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier)
        
        if cell == nil {
            cell = newCellForIndexPath(indexPath)
        }
        
        guard let _ = cell else { fatalError() }
        
        configureCell(cell!, forIndexPath: indexPath)
        
        return cell!
    }
    
    override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return true
    }
    
    override func tableView(tableView: UITableView, moveRowAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath) {
        // TODO: reorder passes
    }
    
    override func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle {
        return .None
    }
    
    override func tableView(tableView: UITableView, shouldIndentWhileEditingRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return false
    }
    
    // MARK: - Actions

    @IBAction func handleDoneButton(sender: AnyObject) {
        self.dismissViewControllerAnimated(true, completion: nil)
    }

    @IBAction func handleEnableSwitchChange(sender: AnyObject) {
        guard let enableSwitch = sender as? UISwitch else { return }
        let index = enableSwitch.tag - 1
        let _ = self.passes[index]
        
//        pass.enabled = enableSwitch.on
    }
    
    // MARK: - Private
    
    private func newCellForIndexPath(indexPath: NSIndexPath) -> UITableViewCell {
        let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: reuseIdentifier)
        
        let enableSwitch = UISwitch()
        let switchSize = enableSwitch.sizeThatFits(CGSizeZero)
        enableSwitch.frame = CGRectMake(cell.contentView.bounds.width - switchSize.width - 15.0,
            (cell.contentView.bounds.height - switchSize.height) / 2.0,
            switchSize.width, switchSize.height)
        
        enableSwitch.tag = indexPath.row + 1
        enableSwitch.autoresizingMask = UIViewAutoresizing.FlexibleLeftMargin
        enableSwitch.addTarget(self, action: "handleEnableSwitchChange:", forControlEvents: .ValueChanged)
        
        cell.contentView.addSubview(enableSwitch)
        
        return cell
    }
    
    private func configureCell(cell: UITableViewCell, forIndexPath indexPath: NSIndexPath) {
        let pass = passes[indexPath.row]
        
        cell.textLabel?.text = pass
        
        if let _ = cell.contentView.viewWithTag(indexPath.row + 1) as? UISwitch {
//                        enableSwitch.on = pass.enabled.boolValue
        }
    }
}
{'fraction_non_alphanumeric': 0.08038585209003216, 'fraction_numerical': 0.004333845938766951, 'mean_word_length': 2.651863195507912, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '5275073', 'n_tokens_mistral': 2035, 'n_tokens_neox': 1880, 'n_words': 544}