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
phucd5 committed Nov 4, 2023
2 parents ca8b3b9 + cc66a06 commit 341c0f0
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 88 deletions.
3 changes: 0 additions & 3 deletions app/newHere1/newHere/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import SwiftUI

struct ContentView: View {
@ObservedObject var locationDataManager = LocationDataManager()



var body: some View {
HomePageView()
.environmentObject(locationDataManager)
Expand Down
24 changes: 24 additions & 0 deletions app/newHere1/newHere/CustomARView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// CustomARView.swift
// new_here
//
// Created by TRACY LI on 2023/10/28.
//

import ARKit
import RealityKit
import SwiftUI

class CustomARView: ARView {
required init (frame frameRect: CGRect){
super.init(frame: frameRect)
}

dynamic required init?(coder decoder: NSCoder){
fatalError("init(coder:) has not been implemented")
}

convenience init(){
self.init(frame: UIScreen.main.bounds)
}
}
16 changes: 16 additions & 0 deletions app/newHere1/newHere/CustomARViewRepresentable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// CustomARViewRepresentable.swift
// new_here
//
// Created by TRACY LI on 2023/10/28.
//

import SwiftUI

struct CustomARViewRepresentable: UIViewRepresentable {
func makeUIView(context: Context) -> CustomARView {
return CustomARView()
}

func updateUIView (_ uiView: CustomARView, context: Context) {}
}
250 changes: 174 additions & 76 deletions app/newHere1/newHere/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,94 +11,192 @@ 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 {
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")
}
CustomARViewRepresentable()
.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())
}
}.opaciy
}
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")
}

Button{isShowingPosts.toggle()

}label:
{
Image(systemName: "plus.circle")
.scaleEffect(2)
}.alignmentGuide(.bottom) { d in d[.bottom]}
.font(.largeTitle)
.padding(10)
}
}
.sheet(isPresented: $isShowingProfile) {
ProfilePopup(isPresented: $isShowingProfile) // Pass the binding to control visibility
}

Button{

}label:
{
Image(systemName: "square.and.arrow.up")
.sheet(isPresented: $isShowingMessages) {
MessagesPopup(isPresented: $isShowingMessages)
}

Button{isShowingProfile.toggle()

}label:
{
Image(systemName: "person")
.sheet(isPresented: $isShowingPosts){
PostsPopup(isPresented: $isShowingPosts, storedMessages: $storedMessages)
}

}.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)
}
}


}

//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)
//// }
//// }
//}

struct HomePageView_Previews: PreviewProvider {
static var previews: some View {
HomePageView()
Expand Down
20 changes: 11 additions & 9 deletions app/newHere1/newHere/Post.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,28 @@

import SwiftUI
import CoreLocation
import Foundation

struct PostsPopup: View {
@Binding var isPresented: Bool
@Binding var storedMessages: [Message]

@State private var noteMessage: String = "This is your message!"

@State private var storedMessage: Message?


let senderName: String = "Username"

@EnvironmentObject var locationDataManager: LocationDataManager

func handleSubmitForm() {
if let currentLocation = locationDataManager.location {
let newMessage = Message(location: currentLocation,
author: senderName,
messageStr: noteMessage)
self.storedMessages.append(newMessage)
}
}

var body: some View {
GeometryReader { geometry in
ZStack {
Expand Down Expand Up @@ -69,13 +77,7 @@ struct PostsPopup: View {
Spacer()

Button(action: {
if let currentLocation = locationDataManager.location {
let newMessage = Message(location: currentLocation,
author: senderName,
messageStr: noteMessage)
self.storedMessages.append(newMessage)
}

handleSubmitForm()
}, label: {
Image(systemName: "paperplane.fill")
.resizable()
Expand Down

0 comments on commit 341c0f0

Please sign in to comment.