Skip to content

Commit

Permalink
v1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
ronan18 committed Feb 19, 2020
1 parent fb1e947 commit 2aa853d
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 26 deletions.
8 changes: 6 additions & 2 deletions Arrival-iOS2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
3475759823FCCCE3008CF063 /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3475759723FCCCE2008CF063 /* Helpers.swift */; };
34AF24A823DFD00400E66C34 /* Train.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AF24A723DFD00400E66C34 /* Train.swift */; };
34CD87F723EA8A24004F8024 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34CD87F623EA8A24004F8024 /* SettingsView.swift */; };
34EF38AF23CC23D4000DE4AF /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34EF38AE23CC23D4000DE4AF /* Colors.swift */; };
Expand Down Expand Up @@ -42,6 +43,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
3475759723FCCCE2008CF063 /* Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Helpers.swift; path = "/Users/ronan/Desktop/Dev/IOS/Arrival-IOS/Arrival-iOS2/Helpers.swift"; sourceTree = "<absolute>"; };
34AF24A723DFD00400E66C34 /* Train.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Train.swift; sourceTree = "<group>"; };
34CD87F623EA8A24004F8024 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
34EF38AE23CC23D4000DE4AF /* Colors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Colors.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -180,6 +182,7 @@
C5B5A53523FA62B00046CCF5 /* TripComponentView.swift */,
C5B5A53623FA62B00046CCF5 /* TripDetailView.swift */,
C5B5A53923FA642D0046CCF5 /* TripWaitTimeView.swift */,
3475759723FCCCE2008CF063 /* Helpers.swift */,
);
path = "Arrival-iOS2";
sourceTree = "<group>";
Expand Down Expand Up @@ -353,6 +356,7 @@
C5166C3923F610AC001F0254 /* TermsOfSeriviceView.swift in Sources */,
C58F248423CC1438003882F3 /* SceneDelegate.swift in Sources */,
C55640F723CF8439003BCB91 /* AppData.swift in Sources */,
3475759823FCCCE3008CF063 /* Helpers.swift in Sources */,
34CD87F723EA8A24004F8024 /* SettingsView.swift in Sources */,
C5B5A53723FA62B00046CCF5 /* TripComponentView.swift in Sources */,
);
Expand Down Expand Up @@ -502,7 +506,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.21;
MARKETING_VERSION = 1.22;
PRODUCT_BUNDLE_IDENTIFIER = com.ronanfuruta.arrival;
PRODUCT_NAME = Arrival;
SWIFT_VERSION = 5.0;
Expand All @@ -525,7 +529,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.21;
MARKETING_VERSION = 1.22;
PRODUCT_BUNDLE_IDENTIFIER = com.ronanfuruta.arrival;
PRODUCT_NAME = Arrival;
SWIFT_VERSION = 5.0;
Expand Down
13 changes: 8 additions & 5 deletions Arrival-iOS2/AppData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import FirebaseCrashlytics
let dateFormate = "hh:mm A"
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let context = appDelegate.persistentContainer.viewContext
let baseURL = "https://api.arrival.city"
var jsContext: JSContext!
class AppData: NSObject, ObservableObject,CLLocationManagerDelegate {
@Published var screen: String = "home"
Expand Down Expand Up @@ -83,6 +82,10 @@ class AppData: NSObject, ObservableObject,CLLocationManagerDelegate {
remoteConfig.setDefaults(fromPlist: "RemoteConfigDefaults")
self.apiUrl = self.remoteConfig["apiurl"].stringValue!
self.cycleTimer = Double(self.remoteConfig["cycleTimer"].stringValue!)!
self.aboutText = self.remoteConfig["aboutText"].stringValue!
self.realtimeTripNotice = self.remoteConfig["realtimeTripsNotice"].stringValue!
self.privacyPolicy = self.remoteConfig["privacyPolicyUrl"].stringValue!
self.termsOfService = self.remoteConfig["termsOfServiceUrl"].stringValue!
let preferencesEntity = NSEntityDescription.entity(forEntityName: "Preferences", in: context)!
let newTestPref = NSManagedObject(entity: preferencesEntity, insertInto: context)
newTestPref.setValue(false, forKey: "prioritizeTrain")
Expand Down Expand Up @@ -562,13 +565,13 @@ class AppData: NSObject, ObservableObject,CLLocationManagerDelegate {
if (i != 0) {
let lastTrainString = thisTrain["leg"][i - 1]["@destTimeMin"].stringValue
let originTimeString = leg["@origTimeMin"].stringValue
let lastTrainTime = moment(lastTrainString, "hh:mm")
let originTime = moment(originTimeString, "hh:mm")
let lastTrainTime = moment(lastTrainString, dateFormate)
let originTime = moment(originTimeString, dateFormate)
let difference = originTime.diff(lastTrainTime, "minutes")
transferWait = difference.stringValue + " min"
print(lastTrainTime.format(), originTime.format(), difference, transferWait, "transfer wait")
}
let enrouteTime = moment(leg["@destTimeMin"].stringValue, "hh:mm A").diff(moment(leg["@origTimeMin"].stringValue, "hh:mm"), "minutes")
let enrouteTime = moment(leg["@destTimeMin"].stringValue, dateFormate).diff(moment(leg["@origTimeMin"].stringValue, dateFormate), "minutes")
let enrouteTimeString = enrouteTime.stringValue + "min"

// print(routeJSON.dictionaryObject, "route for route", routeNum, "color", routeJSON["color"].stringValue)
Expand All @@ -583,7 +586,7 @@ class AppData: NSObject, ObservableObject,CLLocationManagerDelegate {
//let color = thisTrain["color"].stringValue
let color = "none"
print(eta)
let originTime = moment(thisTrain["@origTimeMin"].stringValue, "hh:mm")
let originTime = moment(thisTrain["@origTimeMin"].stringValue, dateFormate)
let now = moment()
let difference = originTime.diff(now, "minutes").intValue
results.append(Train(id: UUID(), direction: direction, time: etd, unit: "", color: "none", cars: 0, hex: "0", eta: eta))
Expand Down
26 changes: 26 additions & 0 deletions Arrival-iOS2/Helpers.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Helpers.swift
//
//
// Created by Ronan Furuta on 2/18/20.
//

import Foundation

func timeDisplay(time: String) -> String {
return moment(time, dateFormate).format("h:mm a")
}
func stationDisplay(_ station: String) -> String {
switch station.lowercased() {
case "san francisco international airport" :
return "SF Airport"
case "Civic Center/UN Plaza".lowercased() :
return "Civic Center"
case "Oakland International Airport".lowercased() :
return "Oakland Airport"
case "Pleasant Hill/Contra Costa Centre".lowercased() :
return "Pleasant Hill/Contra Costa"
default:
return station
}
}
4 changes: 2 additions & 2 deletions Arrival-iOS2/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct HomeView: View {
if (self.appData.fromStation.id != "loading") {
VStack(alignment: .leading) {
Text("from").font(.caption)
Text(self.appData.fromStation.name).font(.headline)
Text(stationDisplay(self.appData.fromStation.name)).font(.headline)
}.lineLimit(1)
} else {
VStack(alignment: .leading) {
Expand Down Expand Up @@ -116,7 +116,7 @@ struct HomeView: View {
}) {
VStack(alignment: .trailing) {
Text("to").font(.caption)
Text(self.appData.toStation.name).font(.headline)
Text(stationDisplay(self.appData.toStation.name)).font(.headline)
}.lineLimit(1)
}.sheet(isPresented: self.$toModalDisplayed) {
VStack(alignment: .leading) {
Expand Down
4 changes: 2 additions & 2 deletions Arrival-iOS2/TrainComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct TrainComponent: View {
if (type != "skeleton") {
if (type == "train") { Text("direction").font(.caption)
}
Text(name).font(.headline)
Text(stationDisplay(name)).font(.headline)
} else {
Rectangle()
.fill(Color.skeleton)
Expand Down Expand Up @@ -72,7 +72,7 @@ struct TrainComponent: View {
if (!eta.isEmpty) {
VStack(alignment: .trailing) {
Text("arrives").font(.caption)
Text(String(eta)).font(.headline)
Text(timeDisplay(time: String(eta))).font(.headline)
}
}

Expand Down
10 changes: 5 additions & 5 deletions Arrival-iOS2/TripComponentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ struct TripComponentView: View {
VStack {
HStack {
VStack(alignment: .leading, spacing: 0) {
Text(fromStationName)
Text(stationDisplay(fromStationName))
.fontWeight(.semibold)
HStack(spacing: 0) {
Image(systemName: "arrow.right.circle.fill").font(.subheadline)
Spacer()
.frame(width: 3.0)
Text(trainName).font(.subheadline)
Text(stationDisplay(trainName)).font(.subheadline)

}



}
Spacer()
Text(fromStationTime)
Text(timeDisplay(time: fromStationTime))
.font(.subheadline)
}
HStack {
Expand All @@ -60,14 +60,14 @@ struct TripComponentView: View {
}
HStack {
VStack(alignment: .leading, spacing: 0) {
Text(destinationStationName) .fontWeight(.semibold)
Text(stationDisplay(destinationStationName)).fontWeight(.semibold)




}
Spacer()
Text(toStationTime)
Text(timeDisplay(time:toStationTime))
.font(.subheadline)
}
}.padding([.top, .bottom, .trailing]).padding(.leading, 5.0)
Expand Down
19 changes: 9 additions & 10 deletions Arrival-iOS2/TripDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct TripDetailView: View {
VStack(alignment: .leading) {
Text("Departs")
.font(.caption)
Text(self.tripToShow.originTime)
Text(timeDisplay(time: self.tripToShow.originTime))
.font(.headline)
}
Spacer()
Expand All @@ -45,13 +45,13 @@ struct TripDetailView: View {
VStack(alignment: .trailing) {
Text("Arrives")
.font(.caption)
Text(self.tripToShow.destinatonTime)
Text(timeDisplay(time: self.tripToShow.destinatonTime))
.font(.headline)
}
}.padding([.top, .bottom])
Divider()
List {
VStack {


ForEach(self.tripToShow.legs) {leg in
VStack {
Expand All @@ -64,21 +64,20 @@ struct TripDetailView: View {

TripComponentView(fromStationName: leg.origin, trainName: leg.trainDestination, stops: leg.stops, type: leg.type, destinationStationName: leg.destination, fromStationTime: leg.originTime, toStationTime: leg.destinationTime, enrouteTime: leg.enrouteTime, color: self.appData.convertColor(color: leg.color)).listRowInsets(.init(top: 0, leading: 0, bottom: 0, trailing: 0))
if (leg.order == self.tripToShow.legs.count) {
TripWaitTimeView(type: "arrive", time: self.tripToShow.destinatonTime)
TripWaitTimeView(type: "arrive", time: timeDisplay(time:self.tripToShow.destinatonTime))
}
}
}

}.edgesIgnoringSafeArea(.bottom).listRowInsets(.init(top: 10, leading: 0, bottom: 0, trailing: 0))

}.edgesIgnoringSafeArea(.bottom)

Spacer()


}.edgesIgnoringSafeArea(.bottom).padding().onAppear {
let originTIme = moment(self.tripToShow.originTime, "hh:mm")
let destinationTIme = moment(self.tripToShow.destinatonTime, "hh:mm")
let originTIme = moment(self.tripToShow.originTime, dateFormate)
let destinationTIme = moment(self.tripToShow.destinatonTime, dateFormate)
let routeTime = destinationTIme.diff(originTIme, "minutes")
let boardTime = moment(self.tripToShow.legs[0].originTime, "hh:mm")
let boardTime = moment(self.tripToShow.legs[0].originTime, dateFormate)
self.boardWait = boardTime.fromNow(true)
print(routeTime, destinationTIme.format(), originTIme.format(), "route time", wait)
self.routeTime = routeTime.stringValue + "min"
Expand Down

0 comments on commit 2aa853d

Please sign in to comment.