Skip to content

Commit

Permalink
some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ewang001 committed Nov 27, 2023
1 parent 680d717 commit 473b4b5
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 213 deletions.
Binary file modified app/newHere1/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions app/newHere1/newHere.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 8 additions & 11 deletions app/newHere1/newHere/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions app/newHere1/newHere/CustomARViewRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ARKit
//}

struct CustomARViewRepresentable: UIViewRepresentable {
@Binding var userId: String
@EnvironmentObject var messageState: MessageState
@EnvironmentObject var fetchedMessagesState: FetchedMessagesState

Expand All @@ -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):
Expand All @@ -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)
Expand Down
253 changes: 69 additions & 184 deletions app/newHere1/newHere/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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..<storedMessages.count, id:\.self) { i in
// Text(storedMessages[i].displayMessage())
// }
// }
// .listStyle(PlainListStyle())
// .background(Color.clear) // Set the list background to clear
// }
// else {
// Text("No Messages Stored!")
}

Spacer()
HStack{
HStack(alignment: .bottom, spacing: 28.0) {
Button{

}label:
{
Image(systemName: "map")
}

Button{isShowingMessages.toggle()

}label:
{
Image(systemName: "message")
}

Button{isShowingPosts.toggle()

}label:
{
Image(systemName: "plus.circle")
.scaleEffect(2)
}

Button{

}label:
{
Image(systemName: "square.and.arrow.up")
}

Button{isShowingProfile.toggle()

}label:
{
Image(systemName: "person")
}

}.alignmentGuide(.bottom) { d in d[.bottom]}
.font(.largeTitle)
.padding(10)
// Overlay containing buttons for various features like map, messages, posts, etc.
// Each button toggles the state to show respective views or popups.
Spacer()
HStack{
HStack(alignment: .bottom, spacing: 28.0) {
Button{

}label:
{
Image(systemName: "map")
}
}
.sheet(isPresented: $isShowingProfile) {
ProfilePopup(isPresented: $isShowingProfile, userId: $userId) // Pass the binding to control visibility
}
.sheet(isPresented: $isShowingMessages) {
MessagesPopup(isPresented: $isShowingMessages)
}
.sheet(isPresented: $isShowingPosts){
PostsPopup(isPresented: $isShowingPosts)
.environmentObject(messageState)
}


Button{isShowingMessages.toggle()

}label:
{
Image(systemName: "message")
}

Button{isShowingPosts.toggle()

}label:
{
Image(systemName: "plus.circle")
.scaleEffect(2)
}

Button{

}label:
{
Image(systemName: "square.and.arrow.up")
}

Button{isShowingProfile.toggle()

}label:
{
Image(systemName: "person")
}

}.alignmentGuide(.bottom) { d in d[.bottom]}
.font(.largeTitle)
.padding(10)
}
}
// Render popups upon state variables being true.
.sheet(isPresented: $isShowingProfile) {
ProfilePopup(isPresented: $isShowingProfile, userId: $userId) // Pass the binding to control visibility
}
.sheet(isPresented: $isShowingMessages) {
MessagesPopup(isPresented: $isShowingMessages)
}
.sheet(isPresented: $isShowingPosts){
PostsPopup(isPresented: $isShowingPosts)
.environmentObject(messageState)
}

}




//struct HomePageView: View {
// @State private var isShowingProfile = false
// @State private var isShowingMessages = false
// @State private var isShowingPosts = false
//
// @State private var storedMessages: [Message] = []
//
// @EnvironmentObject var locationDataManager: LocationDataManager
//
// var body: some View {
// CustomARViewRepresentable()
// .ignoreSafeArea()
// .overlay(alignment: .bottom){}
//
//// VStack(){
////
//// // display current locaation
//// 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..<storedMessages.count, id:\.self) { i in
//// Text(storedMessages[i].displayMessage())
//// }
//// }
//// }
//// else {
//// Text("No Messages Stored!")
//// }
////
//// Spacer()
//// HStack{
//// HStack(alignment: .bottom, spacing: 28.0) {
//// Button{
////
//// }label:
//// {
//// Image(systemName: "map")
//// }
////
//// Button{isShowingMessages.toggle()
////
//// }label:
//// {
//// Image(systemName: "message")
//// }
////
//// Button{isShowingPosts.toggle()
////
//// }label:
//// {
//// Image(systemName: "plus.circle")
//// .scaleEffect(2)
//// }
////
//// Button{
////
//// }label:
//// {
//// Image(systemName: "square.and.arrow.up")
//// }
////
//// Button{isShowingProfile.toggle()
////
//// }label:
//// {
//// Image(systemName: "person")
//// }
////
//// }.alignmentGuide(.bottom) { d in d[.bottom]}
//// .font(.largeTitle)
//// .padding(10)
//// }
//// }
//// .sheet(isPresented: $isShowingProfile) {
//// ProfilePopup(isPresented: $isShowingProfile) // Pass the binding to control visibility
//// }
//// .sheet(isPresented: $isShowingMessages) {
//// MessagesPopup(isPresented: $isShowingMessages)
//// }
//// .sheet(isPresented: $isShowingPosts){
//// PostsPopup(isPresented: $isShowingPosts,
//// storedMessages: $storedMessages)
//// .environmentObject(locationDataManager)
//// }
//// }
//}
}

/// A preview provider for HomePageView, used for rendering the view in Xcode's canvas.
struct HomePageView_Previews: PreviewProvider {
static var previews: some View {
HomePageView()
Expand Down
Loading

0 comments on commit 473b4b5

Please sign in to comment.