diff --git a/app/newHere1/.DS_Store b/app/newHere1/.DS_Store index 6297406..71d761b 100644 Binary files a/app/newHere1/.DS_Store and b/app/newHere1/.DS_Store differ diff --git a/app/newHere1/newHere.xcodeproj/project.pbxproj b/app/newHere1/newHere.xcodeproj/project.pbxproj index 6f84b9b..7195e57 100644 --- a/app/newHere1/newHere.xcodeproj/project.pbxproj +++ b/app/newHere1/newHere.xcodeproj/project.pbxproj @@ -569,7 +569,7 @@ "BUNDLE_LOADER[arch=*]" = "$(BUILT_PRODUCTS_DIR)/newHere.app/newHere"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ACLZN9M2VC; + DEVELOPMENT_TEAM = A7X36A78B2; GCC_GENERATE_TEST_COVERAGE_FILES = YES; GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES; GENERATE_INFOPLIST_FILE = YES; @@ -620,7 +620,7 @@ "BUNDLE_LOADER[arch=*]" = "$(BUILT_PRODUCTS_DIR)/newHere.app/newHere"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ACLZN9M2VC; + DEVELOPMENT_TEAM = A7X36A78B2; GENERATE_INFOPLIST_FILE = YES; IPHONEOS_DEPLOYMENT_TARGET = 17.0; MACOSX_DEPLOYMENT_TARGET = 14.0; diff --git a/app/newHere1/newHere/ContentView.swift b/app/newHere1/newHere/ContentView.swift index f0620a7..afa44b8 100644 --- a/app/newHere1/newHere/ContentView.swift +++ b/app/newHere1/newHere/ContentView.swift @@ -4,34 +4,31 @@ // // Created by Eric Wang on 10/28/23. // +// Description: +// This file defines the ContentView struct, which serves as the main view for the application. +// It handles user authentication and navigation between the HomePage and Login views. import SwiftUI struct ContentView: View { @State private var isAuthenticated = false @State private var isRegistered = false - @ObservedObject var locationDataManager = LocationDataManager() + @ObservedObject var locationDataManager = LocationDataManager() - // testing - @State var friendsPresented = true - //@State var userId = "" + @State private var userId: String = "" + /// The body of the view, which conditionally presents either the HomePageView or LoginView based on authentication status. var body: some View { if isAuthenticated { HomePageView() .environmentObject(locationDataManager) } else { - LoginView(isAuthenticated: $isAuthenticated) + LoginView(isAuthenticated: $isAuthenticated, user_id: $userId) } -// -// if isRegistered { -// HomePageView() -// } else { -// RegistrationView(isRegistered: $isRegistered) -// } } } +/// A preview provider for ContentView, used for rendering the view in Xcode's canvas. struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() diff --git a/app/newHere1/newHere/CustomARViewRepresentable.swift b/app/newHere1/newHere/CustomARViewRepresentable.swift index 1bbd6a7..1b6b7e5 100644 --- a/app/newHere1/newHere/CustomARViewRepresentable.swift +++ b/app/newHere1/newHere/CustomARViewRepresentable.swift @@ -17,6 +17,7 @@ import ARKit //} struct CustomARViewRepresentable: UIViewRepresentable { + @Binding var userId: String @EnvironmentObject var messageState: MessageState @EnvironmentObject var fetchedMessagesState: FetchedMessagesState @@ -27,8 +28,8 @@ struct CustomARViewRepresentable: UIViewRepresentable { let configuration = ARWorldTrackingConfiguration() sceneView.session.run(configuration) - - getUserMessages(userId: "653d51478ff5b3c9ace45c26") { + print("user id: \(userId)") + getUserMessages(userId: userId) { result in switch result { case .success(let response): @@ -37,6 +38,7 @@ struct CustomARViewRepresentable: UIViewRepresentable { for m in response { do { let convertedMessage = try Message(id: m._id, + user_id: userId, location: m.location.toCLLocation(), messageStr: m.text) convertedMessages.append(convertedMessage) diff --git a/app/newHere1/newHere/Home.swift b/app/newHere1/newHere/Home.swift index 4195028..9b1cd9d 100644 --- a/app/newHere1/newHere/Home.swift +++ b/app/newHere1/newHere/Home.swift @@ -4,217 +4,102 @@ // // Created by Lindsay Chen on 10/14/23. // +// Description: +// This file defines the HomePageView and associated state management classes for the application. +// It integrates ARKit and manages UI components for messages, posts, and user profile. import SwiftUI import ARKit +/// Manages the state of the current message in the application. class MessageState: ObservableObject { @Published var currentMessage: Message? } +/// Manages the fetched messages state in the application. class FetchedMessagesState: ObservableObject { var fetchedMessages: [Message]? } +/// The main view for the home page of the application. struct HomePageView: View { @State private var isShowingProfile = false @State private var isShowingMessages = false @State private var isShowingPosts = false - - @State var userId = "6546a496b72c080d30e20493" - - @EnvironmentObject var locationDataManager: LocationDataManager - + @State var userId = "" @StateObject var messageState = MessageState() @StateObject var fetchedMessagesState = FetchedMessagesState() + @EnvironmentObject var locationDataManager: LocationDataManager + + /// The body of the view, presenting the AR view along with overlay controls for navigation and interaction. var body: some View { - CustomARViewRepresentable() + CustomARViewRepresentable(userId: $userId) .environmentObject(messageState) .environmentObject(fetchedMessagesState) - //.ignoresSafeArea() .overlay(alignment: .bottom){ - VStack(){ -// if let currentLocation = locationDataManager.location { -// Text("Your current location is:") -// Text("Latitude: \(currentLocation.coordinate.latitude.description)") -// Text("Longitude: \(currentLocation.coordinate.longitude.description)\n") -// } else { -// Text("Finding your location...\n") -// ProgressView() -// } - -// // render the stored messages on the screen -// if !storedMessages.isEmpty { -// List { -// ForEach(0..