From 171503bf594a540ebe4f0ae8dc36218f2074ea3f Mon Sep 17 00:00:00 2001 From: EvelynBunnyDev Date: Tue, 6 Feb 2024 13:09:32 -0800 Subject: [PATCH 1/7] Chat interface hosting web components Successfully loaded a web placeholder (google) in chat interface --- Prisma.xcodeproj/project.pbxproj | 4 ++++ Prisma/Chat/ChatView.swift | 21 +++++++++++++-------- Prisma/Chat/WebView.swift | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 Prisma/Chat/WebView.swift diff --git a/Prisma.xcodeproj/project.pbxproj b/Prisma.xcodeproj/project.pbxproj index 1067caf..f0f620f 100644 --- a/Prisma.xcodeproj/project.pbxproj +++ b/Prisma.xcodeproj/project.pbxproj @@ -70,6 +70,7 @@ A9D83F962B083794000D0C78 /* SpeziFirebaseAccountStorage in Frameworks */ = {isa = PBXBuildFile; productRef = A9D83F952B083794000D0C78 /* SpeziFirebaseAccountStorage */; }; A9DFE8A92ABE551400428242 /* AccountButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9DFE8A82ABE551400428242 /* AccountButton.swift */; }; A9FE7AD02AA39BAB0077B045 /* AccountSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FE7ACF2AA39BAB0077B045 /* AccountSheet.swift */; }; + E4C766262B72D50500C1DEDA /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4C766252B72D50500C1DEDA /* WebView.swift */; }; F8AF6F9A2B5F2B1A0011C32D /* AppIcon-NoBG.png in Resources */ = {isa = PBXBuildFile; fileRef = F8AF6F992B5F2B1A0011C32D /* AppIcon-NoBG.png */; }; F8AF6F9F2B5F35400011C32D /* ChatView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8AF6F9E2B5F35400011C32D /* ChatView.swift */; }; F8AF6FA52B5F3AE70011C32D /* EventContextCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8AF6FA42B5F3AE70011C32D /* EventContextCard.swift */; }; @@ -146,6 +147,7 @@ A9720E422ABB68CC00872D23 /* AccountSetupHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSetupHeader.swift; sourceTree = ""; }; A9DFE8A82ABE551400428242 /* AccountButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountButton.swift; sourceTree = ""; }; A9FE7ACF2AA39BAB0077B045 /* AccountSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSheet.swift; sourceTree = ""; }; + E4C766252B72D50500C1DEDA /* WebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = ""; }; F8AF6F992B5F2B1A0011C32D /* AppIcon-NoBG.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "AppIcon-NoBG.png"; sourceTree = ""; }; F8AF6F9E2B5F35400011C32D /* ChatView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatView.swift; sourceTree = ""; }; F8AF6FA42B5F3AE70011C32D /* EventContextCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventContextCard.swift; sourceTree = ""; }; @@ -398,6 +400,7 @@ isa = PBXGroup; children = ( F8AF6F9E2B5F35400011C32D /* ChatView.swift */, + E4C766252B72D50500C1DEDA /* WebView.swift */, ); path = Chat; sourceTree = ""; @@ -636,6 +639,7 @@ 2F4FC8D729EE69D300BFFE26 /* MockUpload.swift in Sources */, 2FE5DC3A29EDD7CA004B9AB4 /* Welcome.swift in Sources */, 2FE5DC3829EDD7CA004B9AB4 /* Features.swift in Sources */, + E4C766262B72D50500C1DEDA /* WebView.swift in Sources */, 2FE5DC4529EDD7F2004B9AB4 /* Binding+Negate.swift in Sources */, 2FC975A82978F11A00BA99FE /* Home.swift in Sources */, 2FE5DC4E29EDD7FA004B9AB4 /* ScheduleView.swift in Sources */, diff --git a/Prisma/Chat/ChatView.swift b/Prisma/Chat/ChatView.swift index 2ddb39f..e5ac069 100644 --- a/Prisma/Chat/ChatView.swift +++ b/Prisma/Chat/ChatView.swift @@ -8,6 +8,7 @@ import Foundation import SwiftUI +import WebKit struct ChatView: View { @@ -16,17 +17,21 @@ struct ChatView: View { var body: some View { NavigationStack { - Text("Coming soon!") - .navigationTitle("Chat") - .toolbar { - if AccountButton.shouldDisplay { - AccountButton(isPresented: $presentingAccount) + if let url = URL(string: "https://www.google.com/") { + WebView(url: url) + .navigationTitle("chat") + .toolbar { + if AccountButton.shouldDisplay { + AccountButton(isPresented: $presentingAccount) + } } - } + .edgesIgnoringSafeArea(.bottom) + } else { + Text("Invalid URL") + } } } - - + init(presentingAccount: Binding) { self._presentingAccount = presentingAccount } diff --git a/Prisma/Chat/WebView.swift b/Prisma/Chat/WebView.swift new file mode 100644 index 0000000..32a3f60 --- /dev/null +++ b/Prisma/Chat/WebView.swift @@ -0,0 +1,15 @@ +import SwiftUI +import WebKit + +struct WebView: UIViewRepresentable { + var url: URL + + func makeUIView(context: Context) -> WKWebView { + return WKWebView() + } + + func updateUIView(_ uiView: WKWebView, context: Context) { + let request = URLRequest(url: url) + uiView.load(request) + } +} From d95563c4269602c685f910dc3c6e5e3436d8de10 Mon Sep 17 00:00:00 2001 From: EvelynBunnyDev Date: Tue, 6 Feb 2024 13:20:54 -0800 Subject: [PATCH 2/7] Updated licensing & copyright information --- Prisma/Chat/WebView.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Prisma/Chat/WebView.swift b/Prisma/Chat/WebView.swift index 32a3f60..ae3369a 100644 --- a/Prisma/Chat/WebView.swift +++ b/Prisma/Chat/WebView.swift @@ -1,3 +1,11 @@ +// +// This source file is part of the Stanford Prisma Application based on the Stanford Spezi Template Application project +// +// SPDX-FileCopyrightText: 2023 Stanford University +// +// SPDX-License-Identifier: MIT +// + import SwiftUI import WebKit From 666ea9729faa40cafa33538e10fd630dbbb1bfae Mon Sep 17 00:00:00 2001 From: EvelynBunnyDev Date: Tue, 6 Feb 2024 13:24:47 -0800 Subject: [PATCH 3/7] Fixing implicit return violation --- Prisma/Chat/WebView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Prisma/Chat/WebView.swift b/Prisma/Chat/WebView.swift index ae3369a..77e5ce7 100644 --- a/Prisma/Chat/WebView.swift +++ b/Prisma/Chat/WebView.swift @@ -13,7 +13,7 @@ struct WebView: UIViewRepresentable { var url: URL func makeUIView(context: Context) -> WKWebView { - return WKWebView() + WKWebView() } func updateUIView(_ uiView: WKWebView, context: Context) { From 18cf102ac8cd6db71e4b472028078a71ae53f0ce Mon Sep 17 00:00:00 2001 From: EvelynBunnyDev Date: Tue, 6 Feb 2024 13:44:09 -0800 Subject: [PATCH 4/7] Replacing URL with Prisma web localhost --- Prisma/Chat/ChatView.swift | 3 ++- Prisma/Chat/WebView.swift | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Prisma/Chat/ChatView.swift b/Prisma/Chat/ChatView.swift index e5ac069..9f5a703 100644 --- a/Prisma/Chat/ChatView.swift +++ b/Prisma/Chat/ChatView.swift @@ -17,8 +17,9 @@ struct ChatView: View { var body: some View { NavigationStack { - if let url = URL(string: "https://www.google.com/") { + if let url = URL(string: "http://localhost:3000") { WebView(url: url) + .frame(maxWidth: .infinity, maxHeight: .infinity) .navigationTitle("chat") .toolbar { if AccountButton.shouldDisplay { diff --git a/Prisma/Chat/WebView.swift b/Prisma/Chat/WebView.swift index 77e5ce7..650dc28 100644 --- a/Prisma/Chat/WebView.swift +++ b/Prisma/Chat/WebView.swift @@ -13,7 +13,9 @@ struct WebView: UIViewRepresentable { var url: URL func makeUIView(context: Context) -> WKWebView { - WKWebView() + let webView = WKWebView(frame: .zero) + webView.scrollView.isScrollEnabled = true + return webView } func updateUIView(_ uiView: WKWebView, context: Context) { From f18d7bd5c3437ebbc5f80dca9f7e433b02f806f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthew=20J=C3=B6rke?= Date: Wed, 7 Feb 2024 14:44:58 -0800 Subject: [PATCH 5/7] Updating WebView frame to account for navbars/toolsbars --- Prisma/Chat/ChatView.swift | 24 +++++++++++------------- Prisma/Chat/WebView.swift | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Prisma/Chat/ChatView.swift b/Prisma/Chat/ChatView.swift index 9f5a703..34e0165 100644 --- a/Prisma/Chat/ChatView.swift +++ b/Prisma/Chat/ChatView.swift @@ -14,21 +14,19 @@ import WebKit struct ChatView: View { @Binding var presentingAccount: Bool - var body: some View { NavigationStack { - if let url = URL(string: "http://localhost:3000") { - WebView(url: url) - .frame(maxWidth: .infinity, maxHeight: .infinity) - .navigationTitle("chat") - .toolbar { - if AccountButton.shouldDisplay { - AccountButton(isPresented: $presentingAccount) - } - } - .edgesIgnoringSafeArea(.bottom) - } else { - Text("Invalid URL") + GeometryReader { geometry in + if let url = URL(string: "http://localhost:3000") { + WebView(url: url) + .navigationTitle("Chat") + .frame( + width: geometry.size.width, + height: geometry.size.height + ) + } else { + Text("Invalid URL") + } } } } diff --git a/Prisma/Chat/WebView.swift b/Prisma/Chat/WebView.swift index 650dc28..c185599 100644 --- a/Prisma/Chat/WebView.swift +++ b/Prisma/Chat/WebView.swift @@ -13,7 +13,7 @@ struct WebView: UIViewRepresentable { var url: URL func makeUIView(context: Context) -> WKWebView { - let webView = WKWebView(frame: .zero) + let webView = WKWebView() webView.scrollView.isScrollEnabled = true return webView } From b3e726e95e7d8bc61a66b0ca45e16f42772bd3ab Mon Sep 17 00:00:00 2001 From: EvelynBunnyDev Date: Thu, 8 Feb 2024 15:02:31 -0800 Subject: [PATCH 6/7] Fixing merge conflicts --- Prisma.xcodeproj/xcshareddata/xcschemes/Prisma.xcscheme | 2 +- Prisma/Chat/ChatView.swift | 3 +-- Prisma/Resources/Localizable.xcstrings | 9 ++++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Prisma.xcodeproj/xcshareddata/xcschemes/Prisma.xcscheme b/Prisma.xcodeproj/xcshareddata/xcschemes/Prisma.xcscheme index 71b8ac8..4c54b42 100644 --- a/Prisma.xcodeproj/xcshareddata/xcschemes/Prisma.xcscheme +++ b/Prisma.xcodeproj/xcshareddata/xcschemes/Prisma.xcscheme @@ -87,7 +87,7 @@ + isEnabled = "YES"> Date: Thu, 8 Feb 2024 17:19:05 -0800 Subject: [PATCH 7/7] Very minor changes --- Prisma.xcodeproj/xcshareddata/xcschemes/Prisma.xcscheme | 2 +- Prisma/Chat/ChatView.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Prisma.xcodeproj/xcshareddata/xcschemes/Prisma.xcscheme b/Prisma.xcodeproj/xcshareddata/xcschemes/Prisma.xcscheme index 4c54b42..71b8ac8 100644 --- a/Prisma.xcodeproj/xcshareddata/xcschemes/Prisma.xcscheme +++ b/Prisma.xcodeproj/xcshareddata/xcschemes/Prisma.xcscheme @@ -87,7 +87,7 @@ + isEnabled = "NO">