Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat interface hosting web components #20

Merged
merged 9 commits into from
Feb 9, 2024
4 changes: 4 additions & 0 deletions Prisma.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
AC69903E2B6C5A2F00D92970 /* PrivacyControls.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC69903D2B6C5A2F00D92970 /* PrivacyControls.swift */; };
AC6990402B6C627100D92970 /* ToggleTestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC69903F2B6C627100D92970 /* ToggleTestView.swift */; };
F8AF6F9A2B5F2B1A0011C32D /* AppIcon-NoBG.png in Resources */ = {isa = PBXBuildFile; fileRef = F8AF6F992B5F2B1A0011C32D /* AppIcon-NoBG.png */; };
Expand Down Expand Up @@ -148,6 +149,7 @@
A9720E422ABB68CC00872D23 /* AccountSetupHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSetupHeader.swift; sourceTree = "<group>"; };
A9DFE8A82ABE551400428242 /* AccountButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountButton.swift; sourceTree = "<group>"; };
A9FE7ACF2AA39BAB0077B045 /* AccountSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSheet.swift; sourceTree = "<group>"; };
E4C766252B72D50500C1DEDA /* WebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = "<group>"; };
AC69903D2B6C5A2F00D92970 /* PrivacyControls.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyControls.swift; sourceTree = "<group>"; };
AC69903F2B6C627100D92970 /* ToggleTestView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleTestView.swift; sourceTree = "<group>"; };
F8AF6F992B5F2B1A0011C32D /* AppIcon-NoBG.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "AppIcon-NoBG.png"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -404,6 +406,7 @@
isa = PBXGroup;
children = (
F8AF6F9E2B5F35400011C32D /* ChatView.swift */,
E4C766252B72D50500C1DEDA /* WebView.swift */,
);
path = Chat;
sourceTree = "<group>";
Expand Down Expand Up @@ -642,6 +645,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 */,
Expand Down
22 changes: 13 additions & 9 deletions Prisma/Chat/ChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,29 @@

import Foundation
import SwiftUI
import WebKit


struct ChatView: View {
@Binding var presentingAccount: Bool


var body: some View {
NavigationStack {
Text("Coming soon!")
.navigationTitle("Chat")
.toolbar {
if AccountButton.shouldDisplay {
AccountButton(isPresented: $presentingAccount)
}
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")

Check warning on line 28 in Prisma/Chat/ChatView.swift

View check run for this annotation

Codecov / codecov/patch

Prisma/Chat/ChatView.swift#L19-L28

Added lines #L19 - L28 were not covered by tests
}
}

Check warning on line 30 in Prisma/Chat/ChatView.swift

View check run for this annotation

Codecov / codecov/patch

Prisma/Chat/ChatView.swift#L30

Added line #L30 was not covered by tests
}
}



init(presentingAccount: Binding<Bool>) {
self._presentingAccount = presentingAccount
}
Expand Down
25 changes: 25 additions & 0 deletions Prisma/Chat/WebView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// 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

struct WebView: UIViewRepresentable {
var url: URL

func makeUIView(context: Context) -> WKWebView {
let webView = WKWebView()
webView.scrollView.isScrollEnabled = true
return webView
}

Check warning on line 19 in Prisma/Chat/WebView.swift

View check run for this annotation

Codecov / codecov/patch

Prisma/Chat/WebView.swift#L15-L19

Added lines #L15 - L19 were not covered by tests

func updateUIView(_ uiView: WKWebView, context: Context) {
let request = URLRequest(url: url)
uiView.load(request)
}

Check warning on line 24 in Prisma/Chat/WebView.swift

View check run for this annotation

Codecov / codecov/patch

Prisma/Chat/WebView.swift#L21-L24

Added lines #L21 - L24 were not covered by tests
}
7 changes: 4 additions & 3 deletions Prisma/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
}
}
}
},
"chat" : {

},
"Chat" : {

Expand All @@ -89,9 +92,6 @@
}
}
}
},
"Coming soon!" : {

},
"Completed at %@" : {

Expand Down Expand Up @@ -314,6 +314,7 @@
}
}
},
"Invalid URL" : {},
"Include Active Energy Burned" : {

},
Expand Down
Loading