<commit_before>//
//  SendViewController.swift
//  BadParking
//
//  Created by <NAME> on 10/18/16.
//  Copyright © 2016 BadParking. All rights reserved.
//

import UIKit
import FBSDKCoreKit
import FBSDKLoginKit

class SendViewController: BasePageViewController, UITableViewDelegate, UITableViewDataSource {
    
    @IBOutlet weak var tableView: UITableView!
    @IBOutlet weak var facebookVIew: UIView!
    var claim:Claim?

    override func viewDidLoad() {
        super.viewDidLoad()

        self.claim = (self.parent?.parent as! MainViewController).claim
        self.index = 3
        self.tableView.estimatedRowHeight = 50
        self.tableView.rowHeight = UITableViewAutomaticDimension
        self.tableView.tableFooterView = UIView.init(frame: CGRect.zero)
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        // check if user logged in with FB and has phone number associated
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let accountVC = storyboard.instantiateViewController(withIdentifier: "AccountTableViewController") as! AccountTableViewController
        //        self.present(accountVC, animated: true, completion: nil)

        let loginButton = FBSDKLoginButton()
        loginButton.readPermissions = ["public_profile", "email"]
        loginButton.delegate = accountVC
        facebookVIew.addSubview(loginButton)
        loginButton.center = CGPoint(x: facebookVIew.bounds.width/2, y: facebookVIew.bounds.height/2)
        tableView.reloadData()
    }

    // MARK: - Table view data source
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning can be 4 if we have additional info
        return 3
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        print("cell for row at index path")
        let cell = tableView.dequeueReusableCell(withIdentifier: indexPath.row == 0 ? "photosCell" : "cell", for: indexPath)

        if indexPath.row == 0 {  // photos
            let icon = cell.viewWithTag(1) as! UIImageView
            icon.image = #imageLiteral(resourceName: "photosIcon")

            let stackView = cell.viewWithTag(2) as! UIStackView
            let firstImage = stackView.viewWithTag(3) as! UIImageView
            let secondImage = stackView.viewWithTag(4) as! UIImageView

            firstImage.image = claim?.photos[0].image
            secondImage.image = claim?.photos[1].image
        } else if indexPath.row == 1 {  // location
            (cell.viewWithTag(1) as! UIImageView).image = #imageLiteral(resourceName: "locationIcon")<commit_msg>show login with facebook if not logged in<commit_after>//
//  SendViewController.swift
//  BadParking
//
//  Created by <NAME> on 10/18/16.
//  Copyright © 2016 BadParking. All rights reserved.
//

import UIKit
import FBSDKCoreKit
import FBSDKLoginKit

class SendViewController: BasePageViewController, UITableViewDelegate, UITableViewDataSource {
    
    @IBOutlet weak var tableView: UITableView!
    @IBOutlet weak var facebookVIew: UIView!
    var claim:Claim?

    override func viewDidLoad() {
        super.viewDidLoad()

        self.claim = (self.parent?.parent as! MainViewController).claim
        self.index = 3
        self.tableView.estimatedRowHeight = 50
        self.tableView.rowHeight = UITableViewAutomaticDimension
        self.tableView.tableFooterView = UIView.init(frame: CGRect.zero)
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        // check if user logged in with FB and has phone number associated
        guard FBSDKAccessToken.current() == nil else {
            facebookVIew.isHidden = true
            return
        }
        facebookVIew.isHidden = false
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let accountVC = storyboard.instantiateViewController(withIdentifier: "AccountTableViewController") as! AccountTableViewController
        //        self.present(accountVC, animated: true, completion: nil)

        let loginButton = FBSDKLoginButton()
        loginButton.readPermissions = ["public_profile", "email"]
        loginButton.delegate = accountVC
        facebookVIew.addSubview(loginButton)
        loginButton.center = CGPoint(x: facebookVIew.bounds.width/2, y: facebookVIew.bounds.height/2)
        tableView.reloadData()
    }

    // MARK: - Table view data source
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning can be 4 if we have additional info
        return 3
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: indexPath.row == 0 ? "photosCell" : "cell", for: indexPath)

        if indexPath.row == 0 {  // photos
            let icon = cell.viewWithTag(1) as! UIImageView
            icon.image = #imageLiteral(resourceName: "photosIcon")

            let stackView = cell.viewWithTag(2) as! UIStackView
            let firstImage = stackView.viewWithTag(3) as! UIImageView
            let secondImage = stackView.viewWithTag(4) as! UIImageView

            firstImage.image = claim?.photos[0].image
            secondImage.image = claim?.photos[1].image
        } else if indexPath.row == 1 {  // location
            (cell.viewWithTag(1) as! UIImageView).image = #imageLiteral(resourceName: "locationIcon")
{'fraction_non_alphanumeric': 0.09154559775949589, 'fraction_numerical': 0.009802205496236654, 'mean_word_length': 2.8530006743088334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2552376', 'n_tokens_mistral': 1712, 'n_tokens_neox': 1564, 'n_words': 409}