From cc66a0678e266c43cd60cc3fcbe6c6fdc153a700 Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Sat, 4 Nov 2023 13:56:38 -0400 Subject: [PATCH] integrated AR w/ location + messages --- app/newHere1/newHere/ContentView.swift | 3 - app/newHere1/newHere/CustomARView.swift | 24 ++ .../newHere/CustomARViewRepresentable.swift | 16 ++ app/newHere1/newHere/Home.swift | 250 ++++++++++++------ app/newHere1/newHere/Post.swift | 20 +- 5 files changed, 225 insertions(+), 88 deletions(-) create mode 100644 app/newHere1/newHere/CustomARView.swift create mode 100644 app/newHere1/newHere/CustomARViewRepresentable.swift diff --git a/app/newHere1/newHere/ContentView.swift b/app/newHere1/newHere/ContentView.swift index f34970e..7bf5e71 100644 --- a/app/newHere1/newHere/ContentView.swift +++ b/app/newHere1/newHere/ContentView.swift @@ -9,9 +9,6 @@ import SwiftUI struct ContentView: View { @ObservedObject var locationDataManager = LocationDataManager() - - - var body: some View { HomePageView() .environmentObject(locationDataManager) diff --git a/app/newHere1/newHere/CustomARView.swift b/app/newHere1/newHere/CustomARView.swift new file mode 100644 index 0000000..380db0e --- /dev/null +++ b/app/newHere1/newHere/CustomARView.swift @@ -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) + } +} diff --git a/app/newHere1/newHere/CustomARViewRepresentable.swift b/app/newHere1/newHere/CustomARViewRepresentable.swift new file mode 100644 index 0000000..607366e --- /dev/null +++ b/app/newHere1/newHere/CustomARViewRepresentable.swift @@ -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) {} +} diff --git a/app/newHere1/newHere/Home.swift b/app/newHere1/newHere/Home.swift index d5c3017..cc548f7 100644 --- a/app/newHere1/newHere/Home.swift +++ b/app/newHere1/newHere/Home.swift @@ -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..