Skip to content

Commit 3486928

Browse files
committed
Bugs listed under Important in PR, including edge cases with cells and misc. TODO comments
1 parent 4ff484f commit 3486928

9 files changed

Lines changed: 34 additions & 24 deletions

TCAT/AppDelegate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3636
GMSServices.provideAPIKey(Keys.googleMaps.value)
3737
GMSPlacesClient.provideAPIKey(Keys.googlePlaces.value)
3838

39-
// v1.3 Data Migration
39+
// v1.2.2 Data Migration
4040

4141
print("Begin Data Migration")
4242
if VersionStore.shared.savedAppVersion <= WhatsNew.Version(major: 1, minor: 2, patch: 1) {
4343
migrationToNewPlacesModel { (success, errorDescription) in
44-
print("success: \(success), error: \(errorDescription)")
44+
print("Data Migration Complete - Success: \(success), Error: \(errorDescription ?? "n/a")")
4545
let payload = DataMigrationOnePointThreePayload(success: success, errorDescription: errorDescription)
4646
Analytics.shared.log(payload)
4747
}

TCAT/Cells/PlaceTableViewCell.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010

1111
class PlaceTableViewCell: UITableViewCell {
1212

13-
var place: Place?
13+
var iconColor: UIColor = Colors.metadataIcon
1414

1515
let labelWidthPadding: CGFloat = 45.0
1616
let labelXPosition: CGFloat = 40.0
@@ -41,8 +41,8 @@ class PlaceTableViewCell: UITableViewCell {
4141
imageView?.frame = CGRect(x: 10, y: 5, width: imageWidth, height: imageHeight)
4242
imageView?.contentMode = .scaleAspectFit
4343
imageView?.center.y = bounds.height / 2.0
44-
imageView?.image = reuseIdentifier == Constants.Cells.currentLocationIdentifier ? #imageLiteral(resourceName: "location") : #imageLiteral(resourceName: "pin")
45-
imageView?.tintColor = place?.type == .busStop ? Colors.tcatBlue : Colors.metadataIcon
44+
imageView?.image = #imageLiteral(resourceName: "pin")
45+
imageView?.tintColor = iconColor
4646

4747
textLabel?.frame.origin.x = labelXPosition
4848
textLabel?.frame.size.width = frame.width - labelWidthPadding

TCAT/Controllers/AllStopsTableViewController.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,12 @@ class AllStopsTableViewController: UITableViewController {
161161
}
162162

163163
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
164-
let cell = tableView.dequeueReusableCell(withIdentifier: Constants.Cells.placeIdentifier, for: indexPath) as! PlaceTableViewCell
164+
let cell = tableView.dequeueReusableCell(withIdentifier: Constants.Cells.placeIdentifier) as! PlaceTableViewCell
165165
let section = sectionIndexes[sortedKeys[indexPath.section]]
166-
cell.place = section?[indexPath.row]
167166
cell.textLabel?.text = section?[indexPath.row].name
168167
cell.detailTextLabel?.text = section?[indexPath.row].description
168+
cell.iconColor = Colors.tcatBlue
169+
cell.layoutSubviews()
169170
return cell
170171
}
171172

TCAT/Controllers/FavoritesTableViewController.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ class FavoritesTableViewController: UITableViewController {
115115
var cell: UITableViewCell!
116116
let place = resultsSection.items[indexPath.row]
117117
cell = tableView.dequeueReusableCell(withIdentifier: Constants.Cells.placeIdentifier, for: indexPath) as? PlaceTableViewCell
118-
(cell as? PlaceTableViewCell)?.place = place
119118
cell.textLabel?.text = place.name
120119
cell.detailTextLabel?.text = place.description
121120
cell.preservesSuperviewLayoutMargins = false
@@ -135,8 +134,13 @@ class FavoritesTableViewController: UITableViewController {
135134
// Fetch coordinates and store
136135
CoordinateVisitor.getCoordinates(for: place) { (latitude, longitude, error) in
137136
if error != nil {
138-
// TODO: Handle error properly
139137
print("Unable to get coordinates to save favorite.")
138+
let title = Constants.Alerts.GooglePlacesFailure.title
139+
let message = Constants.Alerts.GooglePlacesFailure.message
140+
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
141+
let done = UIAlertAction(title: Constants.Alerts.GooglePlacesFailure.action, style: .default)
142+
alertController.addAction(done)
143+
self.present(alertController, animated: true, completion: nil)
140144
} else {
141145
place.latitude = latitude
142146
place.longitude = longitude

TCAT/Controllers/HomeViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,9 @@ extension HomeViewController: UITableViewDataSource {
325325
} else {
326326
let place = sections[indexPath.section].items[indexPath.row]
327327
cell = tableView.dequeueReusableCell(withIdentifier: Constants.Cells.placeIdentifier) as? PlaceTableViewCell
328-
(cell as? PlaceTableViewCell)?.place = place
329328
cell.textLabel?.text = place.name
330329
cell.detailTextLabel?.text = place.description
330+
(cell as? PlaceTableViewCell)?.iconColor = place.type == .busStop ? Colors.tcatBlue : Colors.metadataIcon
331331
}
332332

333333
cell.textLabel?.font = .getFont(.regular, size: 14)

TCAT/Controllers/SearchResultsTableViewController.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ class SearchResultsTableViewController: UITableViewController {
6868
object: nil)
6969

7070
// Set Up TableView
71-
tableView.register(PlaceTableViewCell.self, forCellReuseIdentifier: Constants.Cells.placeIdentifier)
7271
tableView.register(UITableViewCell.self, forCellReuseIdentifier: Constants.Cells.seeAllStopsIdentifier)
72+
tableView.register(UITableViewCell.self, forCellReuseIdentifier: Constants.Cells.currentLocationIdentifier)
73+
tableView.register(PlaceTableViewCell.self, forCellReuseIdentifier: Constants.Cells.placeIdentifier)
7374
tableView.emptyDataSetSource = self
7475
tableView.tableFooterView = UIView()
7576
tableView.sectionIndexBackgroundColor = .clear
@@ -223,7 +224,13 @@ class SearchResultsTableViewController: UITableViewController {
223224

224225
var cell: UITableViewCell!
225226

226-
if sections[indexPath.section].type == .seeAllStops {
227+
if sections[indexPath.section].type == .currentLocation {
228+
cell = tableView.dequeueReusableCell(withIdentifier: Constants.Cells.currentLocationIdentifier)
229+
cell.textLabel?.text = Constants.General.currentLocation
230+
cell.imageView?.image = #imageLiteral(resourceName: "location")
231+
}
232+
233+
else if sections[indexPath.section].type == .seeAllStops {
227234
cell = tableView.dequeueReusableCell(withIdentifier: Constants.Cells.seeAllStopsIdentifier)
228235
cell.textLabel?.text = Constants.General.seeAllStops
229236
cell.imageView?.image = #imageLiteral(resourceName: "list")
@@ -233,14 +240,9 @@ class SearchResultsTableViewController: UITableViewController {
233240
else {
234241
let place = sections[indexPath.section].items[indexPath.row]
235242
cell = tableView.dequeueReusableCell(withIdentifier: Constants.Cells.placeIdentifier) as? PlaceTableViewCell
236-
(cell as? PlaceTableViewCell)?.place = place
237243
cell.textLabel?.text = place.name
238-
239-
if sections[indexPath.section].type == .currentLocation {
240-
cell.imageView?.image = UIImage(named: "location")
241-
} else {
242-
cell.detailTextLabel?.text = place.description
243-
}
244+
cell.detailTextLabel?.text = place.description
245+
(cell as? PlaceTableViewCell)?.iconColor = place.type == .busStop ? Colors.tcatBlue : Colors.metadataIcon
244246
}
245247

246248
cell.textLabel?.font = .getFont(.regular, size: 14)

TCAT/Supporting Files/Constants.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ struct Constants {
7171
static let message = "To add more favorites, please swipe left and delete one first."
7272
static let action = "Got It!"
7373
}
74+
75+
struct GooglePlacesFailure {
76+
static let title = "Couldn't Fetch Place Information"
77+
static let message = "We ran into an issue fetching the coordinates of the selected location. Please try again later."
78+
static let action = "OK"
79+
}
7480
}
7581

7682
struct App {
@@ -192,7 +198,7 @@ struct Constants {
192198

193199
static let seeAllStops = "See All Stops"
194200

195-
// What's New for v1.2
201+
// What's New Card for minor app updates
196202
static let whatsNewUpdateName = "Introducing Siri Shortcuts"
197203
static let whatsNewDescription = "Use Siri to access recent searches! Head to Siri & Search in Settings to get started."
198204
}

TCAT/Utilities/Analytics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ struct SiriShortcutUsedPayload: Payload {
191191
}
192192

193193
struct DataMigrationOnePointThreePayload: Payload {
194-
static let eventName: String = "v1.3 Data Migration"
194+
static let eventName: String = "v1.2.2 Data Migration"
195195
let deviceInfo = DeviceInfo()
196196

197197
let success: Bool

TCAT/Utilities/VersionStore.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ class VersionStore: WhatsNewVersionStore {
2828
func has(version: WhatsNew.Version) -> Bool {
2929
let isVersionPatch = version.patch > 0
3030
let isNotNewVersion = (currentAppVersion == savedAppVersion)
31-
32-
// TODO: Confirm this still works!
33-
// set(version: WhatsNew.Version.current())
3431
return isVersionPatch || isNotNewVersion
3532
}
3633

0 commit comments

Comments
 (0)