Skip to content

Commit

Permalink
Chat interface hosting web components (#20)
Browse files Browse the repository at this point in the history
Successfully loaded a web placeholder (google) in chat interface

# *Swift Chat Interface*

## ♻️ Current situation & Problem
*New branch that hosts an interactive React web view within the SwiftUI
interface*


## ⚙️ Release Notes 
*Added WebView under Chat as a SwiftUI Wrapper*
*Modified ChatView under Chat to host desired website. Currently I put
localhost for Prisma web as a placeholder, which works.*
`if let url = URL(string: "https://www.google.com/")` 
*Need additional work on formatting.*
1. Chat interface should not zoom in after typing initial message.
2. Ensuring consistency across iPads and iPhones.
3. Next step is implementing user authentication.

## 📚 Documentation
*Please reference in-line documentation.* 
<img width="278" alt="image"
src="https://github.com/CS342/2024-Prisma/assets/153574461/a233e587-8d99-464e-8902-c5d13fbfa2d7">

## ✅ Testing
*All tests passed.*
*Additional tests to be added for web performance.*


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md).

---------

Co-authored-by: Matthew Jörke <[email protected]>
  • Loading branch information
EvelynBunnyDev and mjoerke committed Feb 9, 2024
1 parent f577d2d commit b665da2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 12 deletions.
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")
}
}
}
}



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
}

func updateUIView(_ uiView: WKWebView, context: Context) {
let request = URLRequest(url: url)
uiView.load(request)
}
}
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

0 comments on commit b665da2

Please sign in to comment.