Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/yale-swe/f23-here
Browse files Browse the repository at this point in the history
  • Loading branch information
annayzhang1337 committed Nov 8, 2023
2 parents 99e685c + 9dce3c5 commit e4dbaa6
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ server/node_modules
app/newHere1/newHere.xcodeproj/xcuserdata/*
app/newHere1/newHere.xcodeproj/xcshareddata/*
app/newHere1/newHere.xcodeproj/project.xcworkspace/xcuserdata
.DS_Store
app/newHere1/newHere.xcodeproj/project.pbxproj
Binary file modified app/.DS_Store
Binary file not shown.
Binary file modified app/newHere1/.DS_Store
Binary file not shown.
44 changes: 21 additions & 23 deletions app/newHere1/newHere.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
1506543B2AF8484A004C7909 /* api_call.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1506543A2AF84849004C7909 /* api_call.swift */; };
1531A8DE2AED95FD009F644E /* newHereApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1531A8DD2AED95FD009F644E /* newHereApp.swift */; };
1531A8E02AED95FD009F644E /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1531A8DF2AED95FD009F644E /* ContentView.swift */; };
1531A8E22AED95FF009F644E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1531A8E12AED95FF009F644E /* Assets.xcassets */; };
Expand All @@ -21,9 +20,9 @@
1531A90F2AED9917009F644E /* Post.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1531A90E2AED9917009F644E /* Post.swift */; };
1531A9132AEDAE2A009F644E /* LocationDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1531A9122AEDAE2A009F644E /* LocationDataManager.swift */; };
1531A9152AEDCADB009F644E /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1531A9142AEDCADB009F644E /* Message.swift */; };
15582E372AFB1544003910A2 /* Registration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15582E362AFB1544003910A2 /* Registration.swift */; };
1562EDE82AF6EA2B00A41779 /* CustomARView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1562EDE62AF6EA2B00A41779 /* CustomARView.swift */; };
1562EDE92AF6EA2B00A41779 /* CustomARViewRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1562EDE72AF6EA2B00A41779 /* CustomARViewRepresentable.swift */; };
71D79D8A2AFB3AEE009A054C /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71D79D892AFB3AEE009A054C /* LoginView.swift */; };
71D79D8C2AFB3BA9009A054C /* CustomARView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71D79D8B2AFB3BA9009A054C /* CustomARView.swift */; };
71D79D8E2AFB3BBA009A054C /* Registration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71D79D8D2AFB3BBA009A054C /* Registration.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -44,7 +43,6 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
1506543A2AF84849004C7909 /* api_call.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = api_call.swift; sourceTree = "<group>"; };
1531A8DA2AED95FD009F644E /* newHere.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = newHere.app; sourceTree = BUILT_PRODUCTS_DIR; };
1531A8DD2AED95FD009F644E /* newHereApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = newHereApp.swift; sourceTree = "<group>"; };
1531A8DF2AED95FD009F644E /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand All @@ -62,9 +60,9 @@
1531A90E2AED9917009F644E /* Post.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = "<group>"; };
1531A9122AEDAE2A009F644E /* LocationDataManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationDataManager.swift; sourceTree = "<group>"; };
1531A9142AEDCADB009F644E /* Message.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; };
15582E362AFB1544003910A2 /* Registration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Registration.swift; sourceTree = "<group>"; };
1562EDE62AF6EA2B00A41779 /* CustomARView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomARView.swift; sourceTree = "<group>"; };
1562EDE72AF6EA2B00A41779 /* CustomARViewRepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomARViewRepresentable.swift; sourceTree = "<group>"; };
71D79D892AFB3AEE009A054C /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = "<group>"; };
71D79D8B2AFB3BA9009A054C /* CustomARView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomARView.swift; sourceTree = "<group>"; };
71D79D8D2AFB3BBA009A054C /* Registration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Registration.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -118,14 +116,13 @@
1531A8DD2AED95FD009F644E /* newHereApp.swift */,
1531A8DF2AED95FD009F644E /* ContentView.swift */,
1531A9082AED9618009F644E /* Home.swift */,
1562EDE62AF6EA2B00A41779 /* CustomARView.swift */,
1562EDE72AF6EA2B00A41779 /* CustomARViewRepresentable.swift */,
1531A90C2AED9663009F644E /* Messages.swift */,
71D79D8B2AFB3BA9009A054C /* CustomARView.swift */,
1531A90A2AED964A009F644E /* Profile.swift */,
1531A90E2AED9917009F644E /* Post.swift */,
15582E362AFB1544003910A2 /* Registration.swift */,
1506543A2AF84849004C7909 /* api_call.swift */,
1531A9142AEDCADB009F644E /* Message.swift */,
71D79D8D2AFB3BBA009A054C /* Registration.swift */,
71D79D892AFB3AEE009A054C /* LoginView.swift */,
1531A9122AEDAE2A009F644E /* LocationDataManager.swift */,
1531A8E12AED95FF009F644E /* Assets.xcassets */,
1531A8E32AED95FF009F644E /* newHere.entitlements */,
Expand Down Expand Up @@ -289,14 +286,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
71D79D8C2AFB3BA9009A054C /* CustomARView.swift in Sources */,
71D79D8E2AFB3BBA009A054C /* Registration.swift in Sources */,
1531A9132AEDAE2A009F644E /* LocationDataManager.swift in Sources */,
1531A8E02AED95FD009F644E /* ContentView.swift in Sources */,
1531A90B2AED964A009F644E /* Profile.swift in Sources */,
71D79D8A2AFB3AEE009A054C /* LoginView.swift in Sources */,
1531A90D2AED9663009F644E /* Messages.swift in Sources */,
15582E372AFB1544003910A2 /* Registration.swift in Sources */,
1562EDE82AF6EA2B00A41779 /* CustomARView.swift in Sources */,
1506543B2AF8484A004C7909 /* api_call.swift in Sources */,
1562EDE92AF6EA2B00A41779 /* CustomARViewRepresentable.swift in Sources */,
1531A90F2AED9917009F644E /* Post.swift in Sources */,
1531A9152AEDCADB009F644E /* Message.swift in Sources */,
1531A9092AED9618009F644E /* Home.swift in Sources */,
Expand Down Expand Up @@ -457,15 +453,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = newHere/newHere.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"newHere/Preview Content\"";
DEVELOPMENT_TEAM = A7X36A78B2;
DEVELOPMENT_TEAM = ACLZN9M2VC;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_LSApplicationCategoryType = "";
INFOPLIST_KEY_NSCameraUsageDescription = "Here needs access to your camera.";
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Here needs to access your location data to tell you your location";
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
Expand All @@ -477,13 +473,14 @@
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.eric.newHere;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -498,10 +495,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = newHere/newHere.entitlements;
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"newHere/Preview Content\"";
DEVELOPMENT_TEAM = A7X36A78B2;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -525,6 +522,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.eric.newHere;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -540,7 +538,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = A7X36A78B2;
DEVELOPMENT_TEAM = ACLZN9M2VC;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
MACOSX_DEPLOYMENT_TARGET = 14.0;
Expand Down Expand Up @@ -585,7 +583,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = A7X36A78B2;
DEVELOPMENT_TEAM = ACLZN9M2VC;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
MACOSX_DEPLOYMENT_TARGET = 14.0;
Expand Down
8 changes: 5 additions & 3 deletions app/newHere1/newHere/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@
import SwiftUI

struct ContentView: View {
@State private var isAuthenticated = false
@State private var isRegistered = false
@ObservedObject var locationDataManager = LocationDataManager()
@ObservedObject var locationDataManager = LocationDataManager()

var body: some View {
if isRegistered {
if isAuthenticated {
// NavigationView {
HomePageView()
.environmentObject(locationDataManager)

// }
} else {
RegistrationView(isRegistered: $isRegistered)
LoginView(isAuthenticated: $isAuthenticated)
// RegistrationView(isRegistered: $isRegistered)
}
// HomePageView()
// .environmentObject(locationDataManager)
Expand Down
102 changes: 102 additions & 0 deletions app/newHere1/newHere/LoginView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//
// LoginView.swift
// newHere
//
// Created by TRACY LI on 2023/11/7.
//

import SwiftUI

let loginUrlString = "https://here-swe.vercel.app/auth/login"
let logApiKey = "qe5YT6jOgiA422_UcdbmVxxG1Z6G48aHV7fSV4TbAPs"

struct LoginView: View {
@State private var username: String = ""
@State private var password: String = ""
@State private var isRegistered = false
@Binding var isAuthenticated: Bool

var body: some View {

NavigationView {
VStack {
Text("Login")
.font(.largeTitle)
.padding(.bottom, 50)

TextField("Username", text: $username)
.padding()
.background(Color(.systemGray6))
.cornerRadius(5.0)
.padding(.bottom, 20)

SecureField("Password", text: $password)
.padding()
.background(Color(.systemGray6))
.cornerRadius(5.0)
.padding(.bottom, 20)

Button(action: LogInUser) {
Text("Login")
.frame(minWidth: 0, maxWidth: .infinity)
.frame(height: 50)
.foregroundColor(.white)
.font(.system(size: 18, weight: .bold))
.background(Color.blue)
.cornerRadius(5.0)
}
.padding(.horizontal)

NavigationLink(destination: RegistrationView(isRegistered: $isRegistered)) {
Text("Don't have an account? Signup")
}
.padding()

Spacer()
}
.padding()
}
}

func LogInUser(){
let requestBody: [String: Any] = [
"userName": username,
"password": password]

guard let jsonData = try? JSONSerialization.data(withJSONObject: requestBody)
else{
return
}

guard let url = URL(string: loginUrlString) else {
return
}

var request = URLRequest(url: url)
request.httpMethod = "POST"
request.httpBody = jsonData
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue(logApiKey, forHTTPHeaderField: "x-api-key")


URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error{
print("error:\(error)")
} else if let data = data {
if let responseString = String(data: data, encoding: .utf8) {
print("Response: \(responseString)")
}
self.isAuthenticated = true;
}
}.resume()

}

}

//// Preview Provider
//struct LoginView_Previews: PreviewProvider {
// static var previews: some View {
// LoginView(isAuthenticated: $isAuthenticated)
// }
//}
8 changes: 4 additions & 4 deletions app/newHere1/newHere/Post.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ struct PostsPopup: View {
Text("Close")
.font(.headline)
.padding()
.background(Color.blue)
.foregroundColor(.white)
.background(Color.blue.opacity(0.8))
.foregroundColor(.white.opacity(0.8))
.cornerRadius(10)
}
.padding(.trailing, 20) // Adjust the position of the close button
Expand All @@ -120,7 +120,7 @@ struct PostsPopup: View {
}, label: {
Image(systemName: "square.and.arrow.up.fill")
.resizable()
.foregroundColor(.blue)
.foregroundColor(.blue.opacity(0.8))
.frame(width: 24, height: 24)
.padding(.leading, 20)
})
Expand Down Expand Up @@ -158,7 +158,7 @@ struct PostsPopup: View {
}, label: {
Image(systemName: "paperplane.fill")
.resizable()
.foregroundColor(.blue)
.foregroundColor(.blue.opacity(0.8))
.frame(width: 24, height: 24)
.padding(.trailing, 20)
})
Expand Down
14 changes: 7 additions & 7 deletions app/newHere1/newHere/Profile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ struct ProfilePopup: View {
Text("Close")
.font(.headline)
.padding()
.background(Color.blue)
.foregroundColor(.white)
.background(Color.blue.opacity(0.8))
.foregroundColor(.white.opacity(0.8))
.cornerRadius(10)
}
.padding(.trailing, 20) // Adjust the position of the close button
Expand Down Expand Up @@ -122,8 +122,8 @@ struct ProfileButtons: View {
Image(systemName: "person.badge.plus")
.font(.system(size: 20))
.padding(10)
.background(Color.blue)
.foregroundColor(.white)
.background(Color.blue.opacity(0.8))
.foregroundColor(.white.opacity(0.8))
.clipShape(Circle())
}
}
Expand All @@ -142,13 +142,13 @@ struct ProfileStats: View {
VStack {
Text(stat.title)
.font(.caption)
.foregroundColor(.gray)
.foregroundColor(.gray.opacity(0.8))

Text(stat.value)
.font(.headline)
}
.padding()
.background(Color.white)
.background(Color.white.opacity(0.8))
.cornerRadius(8)
.shadow(radius: 3)
}
Expand All @@ -169,7 +169,7 @@ struct ProfileStatItem: View {

Text(title)
.font(.subheadline)
.foregroundColor(.gray)
.foregroundColor(.gray.opacity(0.8))
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions app/newHere1/newHere/Registration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct RegistrationView: View {
@State private var password: String = ""
@State private var confirmPassword: String = ""
@Binding var isRegistered: Bool
@State private var isAuthenticated = false

var body: some View {
NavigationView {
Expand All @@ -37,8 +38,13 @@ struct RegistrationView: View {
}

Section {
Button(action: registerUser) {
Text("Submit")
NavigationLink(destination: LoginView(isAuthenticated: $isAuthenticated)) {
Button(action: registerUser) {
Text("Submit")
}
}
NavigationLink(destination: LoginView(isAuthenticated: $isAuthenticated)) {
Text("Already have an account? Login")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Creates a new user account.

Authenticates a user and returns user data if successful.

- **Endpoint:** `GET /auth/login`
- **Endpoint:** `POST /auth/login`
- **Body:**

```json
Expand Down
Loading

0 comments on commit e4dbaa6

Please sign in to comment.