<commit_before>//
//  UserCoordinateViewController.swift
//  OnTheMap
//
//  Created by <NAME> on 05/04/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit
import MapKit

class UserCoordinateViewController: UIViewController {
    
    
    @IBOutlet weak var mapView: MKMapView!
    
    //Current User Details
    static var objectId : String = ""
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.tabBarController?.tabBar.isHidden = true
        
        Alert().activityView(true, self.view)
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        self.navigationController?.navigationBar.isHidden = false
        self.tabBarController?.tabBar.isHidden = false
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let currentAnnotation = MKPointAnnotation.init()
        currentAnnotation.coordinate = AddLocationViewController.studentLocation
        self.mapView.addAnnotation(currentAnnotation)
        let region = MKCoordinateRegionMakeWithDistance(AddLocationViewController.studentLocation, 100, 100)
        let adjustedRegion = self.mapView.regionThatFits(region)
        self.mapView.setRegion(adjustedRegion, animated: true)
        self.mapView.delegate = self
    }
    
    @IBAction func finishButtonPressed(_ sender: Any) {
        
        //Current Student Data
        var currentStudentData = [String:AnyObject]()
        currentStudentData["firstName"] = LoginViewController.firstName as AnyObject?
        currentStudentData["lastName"] = LoginViewController.lastName as AnyObject?
        currentStudentData["userId"] = LoginViewController.userId as AnyObject?
        currentStudentData["webURL"] = AddLocationViewController.webURL as AnyObject?
        currentStudentData["mapString"] = AddLocationViewController.mapString as AnyObject?
        currentStudentData["studentLocation"] = AddLocationViewController.studentLocation as AnyObject?
        currentStudentData["objectId"] = UserCoordinateViewController.objectId as AnyObject?
        
        //Creating StudentDetails Object
        let currentStudent = StudentDetails(currentStudentData)
        
        if !StudentDetails.studentDetail
        {
            //setting flag to true
            StudentDetails.studentDetail = true
            
            ParseStudent().postingStudentDetails(currentStudent) { (result, errorString) in
                if errorString == nil
                {
                    do
                    {
                        let dataDict = try JSONSerialization.jsonObject(with: result!, options: .allowFragments) as! NSDictionary
                        print(dataDict)
                        let objectId = dataDict["objectId"] as! String
                        UserCoordinateViewController.objectId = objectId
                        
                    }
                    catch{}
                }
                else
                {
                    Alert().showAlert(errorString!,self)
                }
            }
        }
        else
        {
            ParseStudent().puttingStudentDetails(currentStudent) { (result, errorString) in
                if errorString == nil
                {
                    do
                    {
                        let dataDict = try JSONSerialization.jsonObject(with: result!, options: .allowFragments) as! NSDictionary
                        print(dataDict)
                    }
                    catch{}
                }
                else
                {
                    Alert().showAlert(errorString!,self)
                }
            }
        }
        //presenting Tab View Controller
        let controller = self.storyboard?.instantiateViewController(withIdentifier: "tabController")
        self.present(controller!, animated: true, completion: nil)
    }
    
    @IBAction func cancelButtonPressed(_ sender: Any) {
        let _ = self.navigationController?.popViewController(animated: true)
    }
    
}
//MARK: MKMapViewDelegate
extension UserCoordinateViewController : MKMapViewDelegate
{
    func mapViewDidFinishRenderingMap(_ mapView: MKMapView, fullyRendered: Bool) {
        Alert().activityView(false, self.view)
    }
}<commit_msg>fixed tabView Controller bug<commit_after>//
//  UserCoordinateViewController.swift
//  OnTheMap
//
//  Created by <NAME> on 05/04/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit
import MapKit

class UserCoordinateViewController: UIViewController {
    
    
    @IBOutlet weak var mapView: MKMapView!
    
    //Current User Details
    static var objectId : String = ""
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.tabBarController?.tabBar.isHidden = true
        
        Alert().activityView(true, self.view)
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        self.navigationController?.navigationBar.isHidden = false
        self.tabBarController?.tabBar.isHidden = false
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let currentAnnotation = MKPointAnnotation.init()
        currentAnnotation.coordinate = AddLocationViewController.studentLocation
        self.mapView.addAnnotation(currentAnnotation)
        let region = MKCoordinateRegionMakeWithDistance(AddLocationViewController.studentLocation, 100, 100)
        let adjustedRegion = self.mapView.regionThatFits(region)
        self.mapView.setRegion(adjustedRegion, animated: true)
        self.mapView.delegate = self
    }
    
    @IBAction func finishButtonPressed(_ sender: Any) {
        
        //Current Student Data
        var currentStudentData = [String:AnyObject]()
        currentStudentData["firstName"] = LoginViewController.firstName as AnyObject?
        currentStudentData["lastName"] = LoginViewController.lastName as AnyObject?
        currentStudentData["userId"] = LoginViewController.userId as AnyObject?
        currentStudentData["webURL"] = AddLocationViewController.webURL as AnyObject?
        currentStudentData["mapString"] = AddLocationViewController.mapString as AnyObject?
        currentStudentData["studentLocation"] = AddLocationViewController.studentLocation as AnyObject?
        currentStudentData["objectId"] = UserCoordinateViewController.objectId as AnyObject?
        
        //Creating StudentDetails Object
        let currentStudent = StudentDetails(currentStudentData)
        
        if !StudentDetails.studentDetail
        {
            //setting flag to true
            StudentDetails.studentDetail = true
            
            ParseStudent().postingStudentDetails(currentStudent) { (result, errorString) in
                if errorString == nil
                {
                    do
                    {
                        let dataDict = try JSONSerialization.jsonObject(with: result!, options: .allowFragments) as! NSDictionary
                        print(dataDict)
                        let objectId = dataDict["objectId"] as! String
                        UserCoordinateViewController.objectId = objectId
                        
                    }
                    catch{}
                }
                else
                {
                    Alert().showAlert(errorString!,self)
                }
            }
        }
        else
        {
            ParseStudent().puttingStudentDetails(currentStudent) { (result, errorString) in
                if errorString == nil
                {
                    do
                    {
                        let dataDict = try JSONSerialization.jsonObject(with: result!, options: .allowFragments) as! NSDictionary
                        print(dataDict)
                    }
                    catch{}
                }
                else
                {
                    Alert().showAlert(errorString!,self)
                }
            }
        }
        //presenting Tab View Controller
        self.dismiss(animated: true, completion: nil)
    }
    
    @IBAction func cancelButtonPressed(_ sender: Any) {
        let _ = self.navigationController?.popViewController(animated: true)
    }
    
}
//MARK: MKMapViewDelegate
extension UserCoordinateViewController : MKMapViewDelegate
{
    func mapViewDidFinishRenderingMap(_ mapView: MKMapView, fullyRendered: Bool) {
        Alert().activityView(false, self.view)
    }
}
{'fraction_non_alphanumeric': 0.07625832068200397, 'fraction_numerical': 0.003737008057923625, 'mean_word_length': 1.9653739612188366, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '402154', 'n_tokens_mistral': 2159, 'n_tokens_neox': 2003, 'n_words': 426}