Skip to content

Commit

Permalink
Merge pull request #49 from Capstone-Projects-2022-Fall/ride-tracking
Browse files Browse the repository at this point in the history
Ride tracking
  • Loading branch information
calin-pescaru authored Dec 5, 2022
2 parents add168a + 4d25475 commit 5a45760
Show file tree
Hide file tree
Showing 10 changed files with 505 additions and 132 deletions.
70 changes: 46 additions & 24 deletions Rear Rider/Rear Rider.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
20B1A1BF291C04FC0023B920 /* MetricsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20B1A1BE291C04FC0023B920 /* MetricsView.swift */; };
20B1A1C1291C060F0023B920 /* RideHistoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20B1A1C0291C060E0023B920 /* RideHistoryView.swift */; };
20CEE3372922BE4A00D43613 /* FirebaseFirestore in Frameworks */ = {isa = PBXBuildFile; productRef = 20CEE3362922BE4A00D43613 /* FirebaseFirestore */; };
20CEE33A2922BE7D00D43613 /* FirestoreModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20CEE3392922BE7D00D43613 /* FirestoreModel.swift */; };
20CEE33C2922BF8D00D43613 /* ViewRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20CEE33B2922BF8D00D43613 /* ViewRouter.swift */; };
Expand All @@ -18,7 +16,14 @@
20CEE3472922C03000D43613 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20CEE3462922C03000D43613 /* ViewController.swift */; };
20CEE3492922C37E00D43613 /* FirebaseFirestoreSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 20CEE3482922C37E00D43613 /* FirebaseFirestoreSwift */; };
20CEE34B2923090A00D43613 /* AuthModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20CEE34A2923090A00D43613 /* AuthModel.swift */; };
20CEE34D29245C4700D43613 /* MetricsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20CEE34C29245C4700D43613 /* MetricsModel.swift */; };
20E49B9D293A72BE008EE278 /* ActiveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20E49B97293A72BE008EE278 /* ActiveView.swift */; };
20E49B9E293A72BE008EE278 /* MetricsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20E49B98293A72BE008EE278 /* MetricsView.swift */; };
20E49B9F293A72BE008EE278 /* RideHistoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20E49B99293A72BE008EE278 /* RideHistoryView.swift */; };
20E49BA1293A72BE008EE278 /* MetricsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20E49B9B293A72BE008EE278 /* MetricsModel.swift */; };
20E49BA2293A72BE008EE278 /* TrackingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20E49B9C293A72BE008EE278 /* TrackingView.swift */; };
20E49BA4293A72DE008EE278 /* TrackingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20E49BA3293A72DE008EE278 /* TrackingManager.swift */; };
20E49BA6293A76E4008EE278 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20E49BA5293A76E4008EE278 /* HomeView.swift */; };
20E49BA9293DA354008EE278 /* Dates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20E49BA8293DA353008EE278 /* Dates.swift */; };
483E42B4291BE71800B9A3C3 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 483E42B3291BE71800B9A3C3 /* GoogleService-Info.plist */; };
483E42B7291BE82200B9A3C3 /* FirebaseAnalyticsSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 483E42B6291BE82200B9A3C3 /* FirebaseAnalyticsSwift */; };
483E42B9291BE82200B9A3C3 /* FirebaseAnalyticsWithoutAdIdSupport in Frameworks */ = {isa = PBXBuildFile; productRef = 483E42B8291BE82200B9A3C3 /* FirebaseAnalyticsWithoutAdIdSupport */; };
Expand All @@ -33,7 +38,6 @@
4851CE0D28E49485003B5B76 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4851CE0C28E49485003B5B76 /* Assets.xcassets */; };
4851CE1028E49485003B5B76 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4851CE0F28E49485003B5B76 /* Preview Assets.xcassets */; };
4851CE1F28E4C3A2003B5B76 /* UIImage+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4851CE1E28E4C3A2003B5B76 /* UIImage+Extension.swift */; };
487C63AE28E4F8700022F0A7 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 487C63AD28E4F8700022F0A7 /* HomeView.swift */; };
48CB852D2902E60700283DBD /* RearRiderAlerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48CB852C2902E60700283DBD /* RearRiderAlerts.swift */; };
48CB852F2902EF5200283DBD /* vehicleAlert.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 48CB852E2902EF5200283DBD /* vehicleAlert.mp3 */; };
48F4414228F6258C00F7C9AA /* ImageIdentification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48F4414128F6258C00F7C9AA /* ImageIdentification.swift */; };
Expand Down Expand Up @@ -64,16 +68,22 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
20B1A1BE291C04FC0023B920 /* MetricsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetricsView.swift; sourceTree = "<group>"; };
20B1A1C0291C060E0023B920 /* RideHistoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RideHistoryView.swift; sourceTree = "<group>"; };
20CEE3392922BE7D00D43613 /* FirestoreModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirestoreModel.swift; sourceTree = "<group>"; };
20CEE33B2922BF8D00D43613 /* ViewRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewRouter.swift; sourceTree = "<group>"; };
20CEE33F2922BFAF00D43613 /* SignInView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignInView.swift; sourceTree = "<group>"; };
20CEE3402922BFAF00D43613 /* ForgotPasswordView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForgotPasswordView.swift; sourceTree = "<group>"; };
20CEE3412922BFAF00D43613 /* SignUpView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignUpView.swift; sourceTree = "<group>"; };
20CEE3462922C03000D43613 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
20CEE34A2923090A00D43613 /* AuthModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthModel.swift; sourceTree = "<group>"; };
20CEE34C29245C4700D43613 /* MetricsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetricsModel.swift; sourceTree = "<group>"; };
20E49B97293A72BE008EE278 /* ActiveView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActiveView.swift; sourceTree = "<group>"; };
20E49B98293A72BE008EE278 /* MetricsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MetricsView.swift; sourceTree = "<group>"; };
20E49B99293A72BE008EE278 /* RideHistoryView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RideHistoryView.swift; sourceTree = "<group>"; };
20E49B9B293A72BE008EE278 /* MetricsModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MetricsModel.swift; sourceTree = "<group>"; };
20E49B9C293A72BE008EE278 /* TrackingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackingView.swift; sourceTree = "<group>"; };
20E49BA3293A72DE008EE278 /* TrackingManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackingManager.swift; sourceTree = "<group>"; };
20E49BA5293A76E4008EE278 /* HomeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
20E49BA7293A77B1008EE278 /* Rear-Rider-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "Rear-Rider-Info.plist"; sourceTree = SOURCE_ROOT; };
20E49BA8293DA353008EE278 /* Dates.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dates.swift; sourceTree = "<group>"; };
483E42B3291BE71800B9A3C3 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
484558402908941B002D81FC /* OptionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptionsView.swift; sourceTree = "<group>"; };
4845584829089EAA002D81FC /* UserConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserConfig.swift; sourceTree = "<group>"; };
Expand All @@ -83,7 +93,6 @@
4851CE0C28E49485003B5B76 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4851CE0F28E49485003B5B76 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
4851CE1E28E4C3A2003B5B76 /* UIImage+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Extension.swift"; sourceTree = "<group>"; };
487C63AD28E4F8700022F0A7 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
48CB852C2902E60700283DBD /* RearRiderAlerts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RearRiderAlerts.swift; sourceTree = "<group>"; };
48CB852E2902EF5200283DBD /* vehicleAlert.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = vehicleAlert.mp3; sourceTree = "<group>"; };
48F4414128F6258C00F7C9AA /* ImageIdentification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageIdentification.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -131,16 +140,6 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
20B1A1BD291C04E40023B920 /* Metrics */ = {
isa = PBXGroup;
children = (
20B1A1BE291C04FC0023B920 /* MetricsView.swift */,
20B1A1C0291C060E0023B920 /* RideHistoryView.swift */,
20CEE34C29245C4700D43613 /* MetricsModel.swift */,
);
path = Metrics;
sourceTree = "<group>";
};
20CEE3352922BE4A00D43613 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand All @@ -167,6 +166,20 @@
path = Auth;
sourceTree = "<group>";
};
20E49B96293A72BE008EE278 /* Metrics */ = {
isa = PBXGroup;
children = (
20E49BA3293A72DE008EE278 /* TrackingManager.swift */,
20E49B97293A72BE008EE278 /* ActiveView.swift */,
20E49B98293A72BE008EE278 /* MetricsView.swift */,
20E49B99293A72BE008EE278 /* RideHistoryView.swift */,
20E49BA8293DA353008EE278 /* Dates.swift */,
20E49B9B293A72BE008EE278 /* MetricsModel.swift */,
20E49B9C293A72BE008EE278 /* TrackingView.swift */,
);
path = Metrics;
sourceTree = "<group>";
};
484558422908942F002D81FC /* StreamingAndRecording */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -240,20 +253,21 @@
4851CE0728E49485003B5B76 /* Rear Rider */ = {
isa = PBXGroup;
children = (
20E49BA7293A77B1008EE278 /* Rear-Rider-Info.plist */,
20E49B96293A72BE008EE278 /* Metrics */,
20CEE33B2922BF8D00D43613 /* ViewRouter.swift */,
20CEE3462922C03000D43613 /* ViewController.swift */,
20CEE33D2922BFAF00D43613 /* Auth */,
20CEE3382922BE6800D43613 /* Firebase */,
483E42B3291BE71800B9A3C3 /* GoogleService-Info.plist */,
20B1A1BD291C04E40023B920 /* Metrics */,
C364D8BD290DAB5900F9EE7C /* Logging */,
4845584729089E87002D81FC /* ConfigurationOptions */,
4845584629089503002D81FC /* ObjectIdentification */,
48455845290894A7002D81FC /* BlueTooth */,
4845584329089489002D81FC /* Alerts */,
484558422908942F002D81FC /* StreamingAndRecording */,
4851CE0828E49485003B5B76 /* Rear_RiderApp.swift */,
487C63AD28E4F8700022F0A7 /* HomeView.swift */,
20E49BA5293A76E4008EE278 /* HomeView.swift */,
C36AA2EB28FC8278001F24A3 /* RiderView.swift */,
C3FC5C65290C64B800929D1D /* yolov5m.mlmodel */,
4851CE0C28E49485003B5B76 /* Assets.xcassets */,
Expand Down Expand Up @@ -404,33 +418,37 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
20E49B9F293A72BE008EE278 /* RideHistoryView.swift in Sources */,
48CB852D2902E60700283DBD /* RearRiderAlerts.swift in Sources */,
4845584B2909768E002D81FC /* ColorExtension.swift in Sources */,
20CEE33C2922BF8D00D43613 /* ViewRouter.swift in Sources */,
20CEE34D29245C4700D43613 /* MetricsModel.swift in Sources */,
484558412908941B002D81FC /* OptionsView.swift in Sources */,
C3BD658328E8DB3B0042CEB4 /* BLEManager.swift in Sources */,
48F4414228F6258C00F7C9AA /* ImageIdentification.swift in Sources */,
C307D28C28F2734B001D7F1D /* MJpegStreamingKit.swift in Sources */,
20CEE3442922BFAF00D43613 /* ForgotPasswordView.swift in Sources */,
20B1A1BF291C04FC0023B920 /* MetricsView.swift in Sources */,
20CEE34B2923090A00D43613 /* AuthModel.swift in Sources */,
20CEE3432922BFAF00D43613 /* SignInView.swift in Sources */,
C307D28928F2731F001D7F1D /* CameraTestView.swift in Sources */,
C36AA2EC28FC8278001F24A3 /* RiderView.swift in Sources */,
20E49B9D293A72BE008EE278 /* ActiveView.swift in Sources */,
20E49BA4293A72DE008EE278 /* TrackingManager.swift in Sources */,
C36AA2E728FC80B2001F24A3 /* ShareSheet.swift in Sources */,
C3FC5C66290C64B800929D1D /* yolov5m.mlmodel in Sources */,
C36AA2E628FC80B2001F24A3 /* RecordingView.swift in Sources */,
20CEE3452922BFAF00D43613 /* SignUpView.swift in Sources */,
20B1A1C1291C060F0023B920 /* RideHistoryView.swift in Sources */,
4851CE0928E49485003B5B76 /* Rear_RiderApp.swift in Sources */,
487C63AE28E4F8700022F0A7 /* HomeView.swift in Sources */,
20CEE33A2922BE7D00D43613 /* FirestoreModel.swift in Sources */,
C36AA2E828FC80B2001F24A3 /* RecordingExtension.swift in Sources */,
20CEE3472922C03000D43613 /* ViewController.swift in Sources */,
20E49B9E293A72BE008EE278 /* MetricsView.swift in Sources */,
20E49BA9293DA354008EE278 /* Dates.swift in Sources */,
4851CE1F28E4C3A2003B5B76 /* UIImage+Extension.swift in Sources */,
4845584929089EAA002D81FC /* UserConfig.swift in Sources */,
20E49BA6293A76E4008EE278 /* HomeView.swift in Sources */,
20E49BA2293A72BE008EE278 /* TrackingView.swift in Sources */,
C338B28E290F5E94009638F9 /* WifiManager.swift in Sources */,
20E49BA1293A72BE008EE278 /* MetricsModel.swift in Sources */,
C364D8C1290DAFDD00F9EE7C /* RearRiderLogView.swift in Sources */,
C364D8BF290DAB9A00F9EE7C /* RearRiderLog.swift in Sources */,
);
Expand Down Expand Up @@ -581,7 +599,9 @@
DEVELOPMENT_TEAM = T53AYVVL5N;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "Rear-Rider-Info.plist";
INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "This app requires Bluetooth for connecting to RaspberryPi";
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Rear Rider requires location to track riding metrics";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand Down Expand Up @@ -611,7 +631,9 @@
DEVELOPMENT_TEAM = T53AYVVL5N;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "Rear-Rider-Info.plist";
INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "This app requires Bluetooth for connecting to RaspberryPi";
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Rear Rider requires location to track riding metrics";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand Down
28 changes: 27 additions & 1 deletion Rear Rider/Rear Rider/Firebase/FirestoreModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import FirebaseFirestoreSwift
class FirestoreModel: ObservableObject {

var db = Firestore.firestore()
var userId = Auth.auth().currentUser?.uid
private var userId = Auth.auth().currentUser?.uid

@Published var appError: AppError? = nil
@Published var firestoreLoading = false
@Published var rides = [Ride]()

struct AppError: Identifiable {
let id = UUID().uuidString
Expand All @@ -33,6 +34,7 @@ class FirestoreModel: ObservableObject {
var id = UUID()
var res: Result
var message: String?
var content: Any?
}

func writeRide(ride: Ride) -> FirestoreResult {
Expand All @@ -46,5 +48,29 @@ class FirestoreModel: ObservableObject {
return FirestoreResult(res: .failure, message: error.localizedDescription)
}
}

func getRides() {
if (rides.isEmpty) {
firestoreLoading = true
}
db.collection("users").document(userId!).collection("rides").order(by: "createdTime", descending: true).addSnapshotListener() { (querySnapshot, err) in
if let err = err {
self.firestoreLoading = false
print("Error getting documents: \(err)")
} else {
self.rides.removeAll()
for document in querySnapshot!.documents {
do {
let docData = try document.data(as: Ride.self)
self.rides.append(docData)
} catch {
print(error)
self.firestoreLoading = false
}
}
}
self.firestoreLoading = false
}
}

}
11 changes: 8 additions & 3 deletions Rear Rider/Rear Rider/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ struct HomeView: View {
.tabItem {
Image(systemName: "bicycle")
}
OptionsView()
ActiveView()
.tabItem {
Image(systemName: "gear")
}
Image(systemName: "location")
}

RideHistoryView()
.tabItem {
Image(systemName: "chart.bar.xaxis")
}
OptionsView()
.tabItem {
Image(systemName: "gear")
}
}
}
}
Expand Down
Loading

0 comments on commit 5a45760

Please sign in to comment.