Skip to content

Commit

Permalink
Feedback changes. Moved StudentLocations Data into a singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
daansari committed Aug 23, 2017
1 parent c141c75 commit 654c81c
Show file tree
Hide file tree
Showing 77 changed files with 7,097 additions and 1,388 deletions.
4 changes: 4 additions & 0 deletions OnTheMap.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
D01F13A01F4734F00086954C /* OnTheMapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D01F139F1F4734F00086954C /* OnTheMapTests.swift */; };
D01F13AB1F4734F00086954C /* OnTheMapUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D01F13AA1F4734F00086954C /* OnTheMapUITests.swift */; };
D049F5B21F4B1C430069778C /* OTM_AddPinForStudentLocationGeocodeExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D049F5B11F4B1C430069778C /* OTM_AddPinForStudentLocationGeocodeExtension.swift */; };
D05421F61F4D779900F275FF /* StudentLocationSingleton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D05421F51F4D779900F275FF /* StudentLocationSingleton.swift */; };
D062CE951F47353400A8554A /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = D062CE941F47353400A8554A /* Constants.swift */; };
D0B48E751F47496F0082B00B /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0B48E741F47496F0082B00B /* MapKit.framework */; };
D0B48E7B1F474DB10082B00B /* OTM_StudentsMapAuthorizationExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0B48E7A1F474DB10082B00B /* OTM_StudentsMapAuthorizationExtension.swift */; };
Expand Down Expand Up @@ -81,6 +82,7 @@
D01F13AA1F4734F00086954C /* OnTheMapUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnTheMapUITests.swift; sourceTree = "<group>"; };
D01F13AC1F4734F00086954C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D049F5B11F4B1C430069778C /* OTM_AddPinForStudentLocationGeocodeExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OTM_AddPinForStudentLocationGeocodeExtension.swift; sourceTree = "<group>"; };
D05421F51F4D779900F275FF /* StudentLocationSingleton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentLocationSingleton.swift; sourceTree = "<group>"; };
D062CE941F47353400A8554A /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
D062CE971F4736CC00A8554A /* Roboto-Thin.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Thin.ttf"; sourceTree = "<group>"; };
D062CE981F4736CC00A8554A /* Roboto-Medium.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Medium.ttf"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -142,6 +144,7 @@
isa = PBXGroup;
children = (
D01C74B51F48BE310080F003 /* StudentLocation.swift */,
D05421F51F4D779900F275FF /* StudentLocationSingleton.swift */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -576,6 +579,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D05421F61F4D779900F275FF /* StudentLocationSingleton.swift in Sources */,
D0CC537B1F49E6B2007520D1 /* NSDate+Extension.swift in Sources */,
D049F5B21F4B1C430069778C /* OTM_AddPinForStudentLocationGeocodeExtension.swift in Sources */,
D01C74C01F48D36E0080F003 /* OTM_StudentLocationTableViewCell.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array/>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OnTheMap/Network/ParseDataSingleton.swift"
timestampString = "525023639.838839"
timestampString = "525171074.570002"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "27"
endingLineNumber = "27"
landmarkName = "unknown"
landmarkType = "0">
landmarkName = "getStudentLocationData(methodParameters:onCompletion:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand All @@ -26,13 +26,13 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OnTheMap/Network/ParseDataSingleton.swift"
timestampString = "525023639.839334"
timestampString = "525171074.570121"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "269"
endingLineNumber = "269"
landmarkName = "unknown"
landmarkType = "0">
landmarkName = "searchStudentLocationsForExisting(student:)"
landmarkType = "7">
<Locations>
<Location
shouldBeEnabled = "No"
Expand Down Expand Up @@ -74,7 +74,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OnTheMap/Controller/OTM_StudentsMapViewController.swift"
timestampString = "525017401.262194"
timestampString = "525171074.570187"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "43"
Expand All @@ -83,30 +83,14 @@
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OnTheMap/Extension/StudentMapVC/OTM_StudentsMapUserInterfaceExtension.swift"
timestampString = "525023639.839799"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "50"
endingLineNumber = "50"
landmarkName = "setupUIForTheMapViewWithStudentLocationData()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OnTheMap/Extension/StudentTableVC/OTM_StudentsTableDelegateExtension.swift"
timestampString = "525023639.839888"
timestampString = "525171074.570245"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "43"
Expand All @@ -122,7 +106,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OnTheMap/Network/UdacitySingleton.swift"
timestampString = "525021574.790018"
timestampString = "525171074.570297"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "32"
Expand Down Expand Up @@ -170,7 +154,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OnTheMap/Network/UdacitySingleton.swift"
timestampString = "525021574.790117"
timestampString = "525171074.570345"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "52"
Expand All @@ -186,7 +170,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OnTheMap/Network/UdacitySingleton.swift"
timestampString = "525021574.790201"
timestampString = "525171074.570409"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "214"
Expand All @@ -202,13 +186,13 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OnTheMap/Network/ParseDataSingleton.swift"
timestampString = "525023639.840034"
timestampString = "525171074.570482"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "157"
endingLineNumber = "157"
landmarkName = "unknown"
landmarkType = "0">
landmarkName = "postStudentLocationData(methodParameters:onCompletion:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand All @@ -218,7 +202,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OnTheMap/Network/UdacitySingleton.swift"
timestampString = "525021574.790385"
timestampString = "525171074.570529"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "148"
Expand All @@ -234,7 +218,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OnTheMap/Network/UdacitySingleton.swift"
timestampString = "525021574.790458"
timestampString = "525171074.570571"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "227"
Expand All @@ -259,5 +243,19 @@
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OnTheMap/Extension/StudentMapVC/OTM_StudentsMapUserInterfaceExtension.swift"
timestampString = "525171074.570647"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "77"
endingLineNumber = "77">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
9 changes: 9 additions & 0 deletions OnTheMap/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
import Foundation

struct Constants {
struct ModeKey {
static let Environment = "development"
}

struct ModeValue {
static let Development = "development"
static let Production = "production"
}

// MARK: Udacity
struct Udacity {
static let APIScheme = "https"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,6 @@ class OTM_AddPinForStudentLocationViewController: UIViewController {
super.viewDidAppear(animated)
checkLocationAuthorizationStatus()
}

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


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/

// MARK: IBAction

Expand All @@ -86,7 +70,9 @@ class OTM_AddPinForStudentLocationViewController: UIViewController {
hud?.show(animated: true)
lookupCoordinatesFor(address: enterYourLocationTextField.text!, onCompletion: { (error) in
if error == nil {
print("map items: \(self.mapItems)")
if Constants.ModeKey.Environment == Constants.ModeValue.Development {
print("map items: \(self.mapItems)")
}
DispatchQueue.main.async {
self.hud?.hide(animated: true)
if self.mapItems.count > 0 {
Expand Down
24 changes: 13 additions & 11 deletions OnTheMap/Controller/OTM_LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ class OTM_LoginViewController: UIViewController {
self.view.addSubview(hud!)
}

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

// MARK: IBAction

// MARK: IBAction
@IBAction func didTapLoginBtn(_ sender: Any) {
if (emailTextField.text?.trimmingCharacters(in: .whitespaces).isEmpty)! {
TSMessage.showNotification(in: self, title: "Email address cannot be empty!", subtitle: nil, type: .error)
Expand Down Expand Up @@ -82,7 +76,9 @@ class OTM_LoginViewController: UIViewController {
TSMessage.showNotification(in: self, title: "Error", subtitle: error, type: .error)
self.hud?.hide(animated: true)
}
print("Log in error while fetching student data - \(error!)")
if Constants.ModeKey.Environment == Constants.ModeValue.Development {
print("Log in error while fetching student data - \(error!)")
}
}
})
}
Expand All @@ -91,7 +87,9 @@ class OTM_LoginViewController: UIViewController {
TSMessage.showNotification(in: self, title: "Error", subtitle: error, type: .error)
self.hud?.hide(animated: true)
}
print("Log in error while logging in - \(error!)")
if Constants.ModeKey.Environment == Constants.ModeValue.Development {
print("Log in error while logging in - \(error!)")
}
}
})
}
Expand All @@ -108,11 +106,15 @@ class OTM_LoginViewController: UIViewController {
extension OTM_LoginViewController: SwiftWebVCDelegate {

func didStartLoading() {
print("Started loading.")
if Constants.ModeKey.Environment == Constants.ModeValue.Development {
print("Started loading.")
}
}

func didFinishLoading(success: Bool) {
print("Finished loading. Success: \(success).")
if Constants.ModeKey.Environment == Constants.ModeValue.Development {
print("Finished loading. Success: \(success).")
}
}
}

Expand Down
23 changes: 3 additions & 20 deletions OnTheMap/Controller/OTM_StudentsMapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class OTM_StudentsMapViewController: UIViewController {
var locationManager = CLLocationManager()
var parseSingleton: ParseDataSingleton!
var udacitySingleton: UdacitySingleton!
var studentLocations: [StudentLocation]! = []
var studentLocationSingleton: StudentLocationSingleton = StudentLocationSingleton.sharedInstance

var hud: MBProgressHUD?

Expand All @@ -41,37 +41,20 @@ class OTM_StudentsMapViewController: UIViewController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.studentLocations = parseSingleton.studentLocations
getStudentLocations()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
checkLocationAuthorizationStatus()
}

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


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}

// MARK: IBAction
@IBAction func didTapPinBtn(_ sender: Any) {
}

@IBAction func didTapRefreshBtn(_ sender: Any) {
self.studentLocations = []
self.studentLocationSingleton.studentLocations = []
getStudentLocations()
}

Expand Down
21 changes: 2 additions & 19 deletions OnTheMap/Controller/OTM_StudentsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class OTM_StudentsTableViewController: UIViewController {

var parseSingleton: ParseDataSingleton!
var udacitySingleton: UdacitySingleton!
var studentLocations: [StudentLocation]! = []
var studentLocationSingleton: StudentLocationSingleton = StudentLocationSingleton.sharedInstance

var hud: MBProgressHUD?

Expand All @@ -40,32 +40,15 @@ class OTM_StudentsTableViewController: UIViewController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.studentLocations = parseSingleton.studentLocations
getStudentLocations()
}

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


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/

// MARK: IBAction
@IBAction func didTapPinBtn(_ sender: Any) {
}

@IBAction func didTapRefreshBtn(_ sender: Any) {
self.studentLocations = []
self.studentLocationSingleton.studentLocations = []
getStudentLocations()
}

Expand Down
Loading

0 comments on commit 654c81c

Please sign in to comment.