diff --git a/ios/MLCChat.xcodeproj/project.pbxproj b/ios/MLCChat.xcodeproj/project.pbxproj index 7ff6650..3e6b50b 100644 --- a/ios/MLCChat.xcodeproj/project.pbxproj +++ b/ios/MLCChat.xcodeproj/project.pbxproj @@ -26,6 +26,9 @@ C0D643C829F99B34004DDAA4 /* MessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0D643C729F99B34004DDAA4 /* MessageView.swift */; }; C0DDBDF62A39103F00E9D060 /* ChatState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0D643C029F99B07004DDAA4 /* ChatState.swift */; }; C0DDBE0D2A3BCD8000E9D060 /* MLCSwift in Frameworks */ = {isa = PBXBuildFile; productRef = C0DDBE0C2A3BCD8000E9D060 /* MLCSwift */; }; + C5093A472AAFD9B200B76C1F /* Fonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5093A462AAFD9B200B76C1F /* Fonts.swift */; }; + C5093A4A2AAFD9D100B76C1F /* UIDeviceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5093A492AAFD9D100B76C1F /* UIDeviceExtension.swift */; }; + C5093A4C2AAFDAB800B76C1F /* UIScreenExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5093A4B2AAFDAB800B76C1F /* UIScreenExtension.swift */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -74,6 +77,9 @@ C0D643C229F99B07004DDAA4 /* ChatView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatView.swift; sourceTree = ""; }; C0D643C729F99B34004DDAA4 /* MessageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageView.swift; sourceTree = ""; }; C0DDBE0B2A3BA6F800E9D060 /* MLCSwift */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = MLCSwift; sourceTree = ""; }; + C5093A462AAFD9B200B76C1F /* Fonts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Fonts.swift; sourceTree = ""; }; + C5093A492AAFD9D100B76C1F /* UIDeviceExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDeviceExtension.swift; sourceTree = ""; }; + C5093A4B2AAFDAB800B76C1F /* UIScreenExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIScreenExtension.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -125,6 +131,7 @@ isa = PBXGroup; children = ( AEC27F012A86337E00254E67 /* Constants.swift */, + C5093A462AAFD9B200B76C1F /* Fonts.swift */, ); path = Common; sourceTree = ""; @@ -152,6 +159,7 @@ isa = PBXGroup; children = ( C09834182A16F4CB00A05B51 /* app-config.json */, + C5093A482AAFD9BE00B76C1F /* Extensions */, AEC27F032A86338800254E67 /* Common */, AEC27EF82A85C29000254E67 /* Models */, AEC27EFF2A85EE2800254E67 /* States */, @@ -187,6 +195,15 @@ name = Packages; sourceTree = ""; }; + C5093A482AAFD9BE00B76C1F /* Extensions */ = { + isa = PBXGroup; + children = ( + C5093A492AAFD9D100B76C1F /* UIDeviceExtension.swift */, + C5093A4B2AAFDAB800B76C1F /* UIScreenExtension.swift */, + ); + path = Extensions; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -264,6 +281,8 @@ buildActionMask = 2147483647; files = ( A773CC652A5DC98200467BFE /* ImageProcessing.swift in Sources */, + C5093A4C2AAFDAB800B76C1F /* UIScreenExtension.swift in Sources */, + C5093A472AAFD9B200B76C1F /* Fonts.swift in Sources */, 1453A4D12A1354B9001B909F /* AppState.swift in Sources */, C0D643B329F99A7F004DDAA4 /* MLCChatApp.swift in Sources */, C0DDBDF62A39103F00E9D060 /* ChatState.swift in Sources */, @@ -275,6 +294,7 @@ AEC27EFA2A85C2AC00254E67 /* ParamsConfig.swift in Sources */, AEC27EFC2A85C3B000254E67 /* AppConfig.swift in Sources */, AEC27F022A86337E00254E67 /* Constants.swift in Sources */, + C5093A4A2AAFD9D100B76C1F /* UIDeviceExtension.swift in Sources */, 1453A4D02A1354B9001B909F /* ModelView.swift in Sources */, 1453A4CF2A1354B9001B909F /* StartView.swift in Sources */, ); @@ -408,7 +428,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"MLCChat/Preview Content\""; - DEVELOPMENT_TEAM = 2RVTPP42D4; + DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; "HEADER_SEARCH_PATHS[arch=*]" = ""; @@ -418,6 +438,7 @@ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UIRequiredDeviceCapabilities = "arm64 iphone-ipad-minimum-performance-a12"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; LD_RUNPATH_SEARCH_PATHS = ( @@ -426,7 +447,7 @@ ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/build/lib", + "\"$(SRCROOT)/build/lib\"", ); MARKETING_VERSION = 1.1; OTHER_LDFLAGS = ( @@ -461,7 +482,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"MLCChat/Preview Content\""; - DEVELOPMENT_TEAM = 2RVTPP42D4; + DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; "HEADER_SEARCH_PATHS[arch=*]" = ""; @@ -471,6 +492,7 @@ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UIRequiredDeviceCapabilities = "arm64 iphone-ipad-minimum-performance-a12"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; LD_RUNPATH_SEARCH_PATHS = ( @@ -479,7 +501,7 @@ ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/build/lib", + "\"$(SRCROOT)/build/lib\"", ); MARKETING_VERSION = 1.1; OTHER_LDFLAGS = ( diff --git a/ios/MLCChat/Common/Fonts.swift b/ios/MLCChat/Common/Fonts.swift new file mode 100644 index 0000000..1c4d909 --- /dev/null +++ b/ios/MLCChat/Common/Fonts.swift @@ -0,0 +1,16 @@ +// +// Fonts.swift +// MLCChat +// +// Created by Roma iOS on 12.09.2023. +// + +import Foundation +import SwiftUI + +struct Fonts { + + static let welcomeFont: Font = UIDevice.isIPad ? Font.system(size: UIScreen.width * 0.03) : Font.system(size: UIScreen.width * 0.04) + + static let welcomeFontMinimized: Font = UIDevice.isIPad ? Font.system(size: UIScreen.width * 0.02) : Font.system(size: UIScreen.width * 0.03) +} diff --git a/ios/MLCChat/Extensions/UIDeviceExtension.swift b/ios/MLCChat/Extensions/UIDeviceExtension.swift new file mode 100644 index 0000000..b0ff2bf --- /dev/null +++ b/ios/MLCChat/Extensions/UIDeviceExtension.swift @@ -0,0 +1,14 @@ +// +// UIDeviceExtension.swift +// MLCChat +// +// Created by Roma iOS on 12.09.2023. +// + +import UIKit + +extension UIDevice { + static var isIPad: Bool { + return UIDevice.current.userInterfaceIdiom == .pad + } +} diff --git a/ios/MLCChat/Extensions/UIScreenExtension.swift b/ios/MLCChat/Extensions/UIScreenExtension.swift new file mode 100644 index 0000000..b9b6c29 --- /dev/null +++ b/ios/MLCChat/Extensions/UIScreenExtension.swift @@ -0,0 +1,23 @@ +// +// UIScreenExtension.swift +// MLCChat +// +// Created by Roma iOS on 12.09.2023. +// + +import UIKit + +extension UIScreen { + + static var size: CGSize { + return UIScreen.main.bounds.size + } + + static var width: CGFloat { + return size.width + } + + static var height: CGFloat { + return size.height + } +} diff --git a/ios/MLCChat/MLCChatApp.swift b/ios/MLCChat/MLCChatApp.swift index 139c5e0..729f9ac 100644 --- a/ios/MLCChat/MLCChatApp.swift +++ b/ios/MLCChat/MLCChatApp.swift @@ -24,6 +24,7 @@ struct MLCChatApp: App { .task { appState.loadAppConfigAndModels() } + .navigationViewStyle(.stack) } } } diff --git a/ios/MLCChat/States/AppState.swift b/ios/MLCChat/States/AppState.swift index 63b4757..f649ece 100644 --- a/ios/MLCChat/States/AppState.swift +++ b/ios/MLCChat/States/AppState.swift @@ -5,26 +5,58 @@ // Created by Yaxing Cai on 5/13/23. // -import Foundation +import UIKit final class AppState: ObservableObject { @Published var models = [ModelState]() @Published var exampleModels = [ExampleModelConfig]() @Published var chatState = ChatState() - + @Published var alertMessage = "" // TODO: Should move out @Published var alertDisplayed = false // TODO: Should move out + + @Published var isShowKeyboard: Bool = false private var appConfig: AppConfig? private var localModelIDs = Set() - + private let fileManager: FileManager = FileManager.default private lazy var cacheDirectoryURL: URL = { fileManager.urls(for: .cachesDirectory, in: .userDomainMask)[0] }() - + private let jsonDecoder = JSONDecoder() private let jsonEncoder = JSONEncoder() + + init() { + // Add observer for keyboard show notification + NotificationCenter.default.addObserver( + self, + selector: #selector(keyboardWillShow), + name: UIApplication.keyboardWillShowNotification, + object: nil + ) + + // Add observer for keyboard hide notification + NotificationCenter.default.addObserver( + self, + selector: #selector(keyboardWillHide), + name: UIApplication.keyboardWillHideNotification, + object: nil + ) + } + + deinit { + NotificationCenter.default.removeObserver(self) + } + + @objc func keyboardWillShow(notification: Notification) { + isShowKeyboard = true + } + + @objc func keyboardWillHide(notification: Notification) { + isShowKeyboard = false + } func loadAppConfigAndModels() { appConfig = loadAppConfig() diff --git a/ios/MLCChat/Views/ModelView.swift b/ios/MLCChat/Views/ModelView.swift index 8b1cfae..961effa 100644 --- a/ios/MLCChat/Views/ModelView.swift +++ b/ios/MLCChat/Views/ModelView.swift @@ -3,7 +3,7 @@ import UIKit struct CustomTextField: UIViewRepresentable { @Binding var text: String - + func makeUIView(context: Context) -> UITextField { let textField = UITextField() textField.delegate = context.coordinator @@ -51,6 +51,9 @@ struct ContentView: View { struct ModelView: View { + + @Environment(\.colorScheme) var colorScheme + @EnvironmentObject private var modelState: ModelState @EnvironmentObject private var chatState: ChatState @Binding var isRemoving: Bool @@ -91,10 +94,6 @@ struct ModelView: View { @State private var isVitalsExpanded: Bool = false @State private var isLabTestResultsExpanded: Bool = false - - - - // State to hold text field values @State private var textFields: [String] { didSet { @@ -105,7 +104,7 @@ struct ModelView: View { init(isRemoving: Binding) { _isRemoving = isRemoving - + // Initialize from UserDefaults if let savedTextFields = UserDefaults.standard.array(forKey: "textFields") as? [String] { _textFields = State(initialValue: savedTextFields) @@ -113,7 +112,7 @@ struct ModelView: View { _textFields = State(initialValue: Array(repeating: "", count: 5)) } } - + var body: some View { NavigationView { Form { @@ -122,7 +121,7 @@ struct ModelView: View { Text("Age:") .frame(width: 80, alignment: .leading) CustomTextField(text: $Age) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -130,7 +129,7 @@ struct ModelView: View { Text("Weight:") .frame(width: 80, alignment: .leading) CustomTextField(text: $Weight) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -138,7 +137,7 @@ struct ModelView: View { Text("Height:") .frame(width: 80, alignment: .leading) CustomTextField(text: $Height) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -152,7 +151,7 @@ struct ModelView: View { Text("Symptoms:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Symptoms) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -160,7 +159,7 @@ struct ModelView: View { Text("Allergies:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Allergies) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -168,7 +167,7 @@ struct ModelView: View { Text("Medications:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Medications) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -181,7 +180,7 @@ struct ModelView: View { Text("Temp.:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Temperature) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -189,7 +188,7 @@ struct ModelView: View { Text("Heart Rate:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Heart_Rate) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -197,7 +196,7 @@ struct ModelView: View { Text("Respiratory Rate:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Respiratory_Rate) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -205,7 +204,7 @@ struct ModelView: View { Text("Oxygen Saturation:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Oxygen_Saturation) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -213,7 +212,7 @@ struct ModelView: View { Text("Waist Circum.:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Waist_Circumference) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -221,7 +220,7 @@ struct ModelView: View { Text("Hip Circum.:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Hip_Circumference) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -229,7 +228,7 @@ struct ModelView: View { Text("Diastolic Blood Pressure:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Diastolic_Blood_Pressure) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -237,7 +236,7 @@ struct ModelView: View { Text("Systolic Blood Pressure:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Systolic_Blood_Pressure) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -251,7 +250,7 @@ struct ModelView: View { Text("Albumin:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Albumin) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -259,7 +258,7 @@ struct ModelView: View { Text("ALT:") .frame(width: 100, alignment: .leading) CustomTextField(text: $ALT) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -267,7 +266,7 @@ struct ModelView: View { Text("AST:") .frame(width: 100, alignment: .leading) CustomTextField(text: $AST) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -275,7 +274,7 @@ struct ModelView: View { Text("BUN:") .frame(width: 100, alignment: .leading) CustomTextField(text: $BUN) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -283,7 +282,7 @@ struct ModelView: View { Text("Calcium:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Calcium) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -291,7 +290,7 @@ struct ModelView: View { Text("Creatinine:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Creatinine) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -299,7 +298,7 @@ struct ModelView: View { Text("Glucose:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Glucose) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -307,7 +306,7 @@ struct ModelView: View { Text("HbA1c:") .frame(width: 100, alignment: .leading) CustomTextField(text: $HbA1c) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -315,7 +314,7 @@ struct ModelView: View { Text("Potassium:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Potassium) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -323,7 +322,7 @@ struct ModelView: View { Text("Sodium:") .frame(width: 100, alignment: .leading) CustomTextField(text: $Sodium) - .background(Color.gray.opacity(0.1)) + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) .cornerRadius(8) .padding() } @@ -339,12 +338,8 @@ struct ModelView: View { } - } - - - } diff --git a/ios/MLCChat/Views/StartView.swift b/ios/MLCChat/Views/StartView.swift index 07b9826..1dfa585 100644 --- a/ios/MLCChat/Views/StartView.swift +++ b/ios/MLCChat/Views/StartView.swift @@ -38,313 +38,322 @@ struct StartView: View { @AppStorage("HDL") public var HDL: String = "" @AppStorage("eGFR") public var eGFR: String = "" + @Environment(\.colorScheme) var colorScheme var body: some View { NavigationView { - + ZStack { - Color(.systemGray6) - .edgesIgnoringSafeArea(.all) - Text("Hello, World!") // <-- This is the new line of code - .font(.largeTitle) - .foregroundColor(Color.red) - .padding() + + NavigationLink(destination: ChatView() + .environmentObject(appState.chatState), + isActive: $showChatView) { + EmptyView() + } + .hidden() + .padding(20) + + // Color(.systemGray6) + // .edgesIgnoringSafeArea(.all) + // Text("Hello, World!") // <-- This is the new line of code + // .font(.largeTitle) + // .foregroundColor(Color.red) + // .padding() // Setting background image -// Image("background") -// .resizable() -// // .scaledToFill() -// .edgesIgnoringSafeArea(.all) -//// - - + // Image("background") + // .resizable() + // // .scaledToFill() + // .edgesIgnoringSafeArea(.all) + //// + + // Replacing List with ScrollView and LazyVStack - // ScrollView { - VStack { + // ScrollView { + VStack(alignment: .center) { ( Text("Welcome to the waiting room! Here you can optionally fill out your health record, which will give ") + - Text("Dr Dignity") - .foregroundColor(Color.black) + + Text("Dr Dignity").foregroundColor(colorScheme == .dark ? Color.white : Color.black) + Text(" more insight into you.") ) - .font(.largeTitle) + .font(appState.isShowKeyboard ? Fonts.welcomeFontMinimized : Fonts.welcomeFont) + .multilineTextAlignment(.center) .foregroundColor(Color.teal) .padding() - - - - + .padding(.top, appState.isShowKeyboard ? 50 : 15) +// .environment(\.colorScheme, .light) + + Spacer() LazyVStack { Section() { ForEach(appState.models) { modelState in - ModelView(isRemoving: $isRemoving) - .environmentObject(modelState) - .environmentObject(appState.chatState) - - - - } + ModelView(isRemoving: $isRemoving) + .frame(minWidth: 300, minHeight: 500) + .environmentObject(modelState) + .environmentObject(appState.chatState) + + + + } -// ModelView(isRemoving: $isRemoving).environmentObject(appState.models[1]).environmentObject(appState.chatState) -// } -// -// if appState.models.count > 1 { -// -// -// ModelView(isRemoving: $isRemoving) -// .environmentObject(appState.models[1]) -// .environmentObject(appState.chatState) -// -// -// } + // ModelView(isRemoving: $isRemoving).environmentObject(appState.models[1]).environmentObject(appState.chatState) + // } + // + // if appState.models.count > 1 { + // + // + // ModelView(isRemoving: $isRemoving) + // .environmentObject(appState.models[1]) + // .environmentObject(appState.chatState) + // + // + // } } } // New button code // NavigationLink - NavigationLink(destination: ChatView() - .environmentObject(appState.chatState), - isActive: $showChatView) { - EmptyView() - } - .hidden() - .padding(20) - - - Button("Chat with Dr. Dignity") { - - - - - // Button action here - print("Hello button tapped!") - - - var systemPrompt = "You are Doctor Dignity, the world's most advanced AI doctor, capable of accurately providing patients with high-quality medical advice. Here is your next patient's health data:\n" - - if !Age.isEmpty { - systemPrompt += "Age:\(Age)\n" - } - if !Weight.isEmpty { - systemPrompt += "Weight:\(Weight)\n" - } - if !Height.isEmpty { - systemPrompt += "Height:\(Height)\n" - } - if !Symptoms.isEmpty { - systemPrompt += "Symptoms:\(Symptoms)\n" - } - if !Allergies.isEmpty { - systemPrompt += "Allergies:\(Allergies)\n" - } - if !Medications.isEmpty { - systemPrompt += "Medications:\(Medications)\n" - } - if !Temperature.isEmpty { - systemPrompt += "Temperature:\(Temperature)\n" - } - if !Heart_Rate.isEmpty { - systemPrompt += "Heart_Rate:\(Heart_Rate)\n" - } - if !Respiratory_Rate.isEmpty { - systemPrompt += "Respiratory_Rate:\(Respiratory_Rate)\n" - } - if !Oxygen_Saturation.isEmpty { - systemPrompt += "Oxygen_Saturation:\(Oxygen_Saturation)\n" - } - if !Waist_Circumference.isEmpty { - systemPrompt += "Waist_Circumference:\(Waist_Circumference)\n" - } - if !Hip_Circumference.isEmpty { - systemPrompt += "Hip_Circumference:\(Hip_Circumference)\n" - } - if !Diastolic_Blood_Pressure.isEmpty { - systemPrompt += "Diastolic_Blood_Pressure:\(Diastolic_Blood_Pressure)\n" - } - if !Systolic_Blood_Pressure.isEmpty { - systemPrompt += "Systolic_Blood_Pressure:\(Systolic_Blood_Pressure)\n" - } - if !Albumin.isEmpty { - systemPrompt += "Albumin:\(Albumin)\n" - } - if !ALT.isEmpty { - systemPrompt += "ALT:\(ALT)\n" - } - if !AST.isEmpty { - systemPrompt += "AST:\(AST)\n" - } - if !BUN.isEmpty { - systemPrompt += "BUN:\(BUN)\n" - } - if !Calcium.isEmpty { - systemPrompt += "Calcium:\(Calcium)\n" - } - if !Creatinine.isEmpty { - systemPrompt += "Creatinine:\(Creatinine)\n" - } - if !Glucose.isEmpty { - systemPrompt += "Glucose:\(Glucose)\n" - } - if !HbA1c.isEmpty { - systemPrompt += "HbA1c:\(HbA1c)\n" - } - if !Potassium.isEmpty { - systemPrompt += "Potassium:\(Potassium)\n" - } - if !Sodium.isEmpty { - systemPrompt += "Sodium:\(Sodium)\n" - } - if !Triglycerides.isEmpty { - systemPrompt += "Triglycerides:\(Triglycerides)\n" - } - if !LDL.isEmpty { - systemPrompt += "LDL:\(LDL)\n" - } - if !HDL.isEmpty { - systemPrompt += "HDL:\(HDL)\n" - } - if !eGFR.isEmpty { - systemPrompt += "eGFR:\(eGFR)\n" - } - - // systemPrompt += "\nNow that you've seen these biomarkers, the patient would like to see you. Please respond exactly like a licensed medical doctor would. Do not make any assumptions about the patient initially, but use the patient's biomarker data you've been to guide your response. The patient asks the following question:\n" - - systemPrompt += "\nPlease remember this information to provide either an accurate assessment of their health or a comprehensive overall assessment of their health. They would now would like to speak with you. Please respond accordingly. The patient asks the following question:\n" - - - - - - - - print("information " + systemPrompt) - appState.chatState.getBioData(prompt: systemPrompt) - appState.models[0].startChat(chatState: appState.chatState) - showChatView = true - - }.padding() + + + Spacer() + + Button("Chat with Dr. Dignity") { + + + + + // Button action here + print("Hello button tapped!") + + + var systemPrompt = "You are Doctor Dignity, the world's most advanced AI doctor, capable of accurately providing patients with high-quality medical advice. Here is your next patient's health data:\n" + + if !Age.isEmpty { + systemPrompt += "Age:\(Age)\n" + } + if !Weight.isEmpty { + systemPrompt += "Weight:\(Weight)\n" + } + if !Height.isEmpty { + systemPrompt += "Height:\(Height)\n" + } + if !Symptoms.isEmpty { + systemPrompt += "Symptoms:\(Symptoms)\n" + } + if !Allergies.isEmpty { + systemPrompt += "Allergies:\(Allergies)\n" + } + if !Medications.isEmpty { + systemPrompt += "Medications:\(Medications)\n" + } + if !Temperature.isEmpty { + systemPrompt += "Temperature:\(Temperature)\n" + } + if !Heart_Rate.isEmpty { + systemPrompt += "Heart_Rate:\(Heart_Rate)\n" + } + if !Respiratory_Rate.isEmpty { + systemPrompt += "Respiratory_Rate:\(Respiratory_Rate)\n" + } + if !Oxygen_Saturation.isEmpty { + systemPrompt += "Oxygen_Saturation:\(Oxygen_Saturation)\n" + } + if !Waist_Circumference.isEmpty { + systemPrompt += "Waist_Circumference:\(Waist_Circumference)\n" + } + if !Hip_Circumference.isEmpty { + systemPrompt += "Hip_Circumference:\(Hip_Circumference)\n" + } + if !Diastolic_Blood_Pressure.isEmpty { + systemPrompt += "Diastolic_Blood_Pressure:\(Diastolic_Blood_Pressure)\n" + } + if !Systolic_Blood_Pressure.isEmpty { + systemPrompt += "Systolic_Blood_Pressure:\(Systolic_Blood_Pressure)\n" + } + if !Albumin.isEmpty { + systemPrompt += "Albumin:\(Albumin)\n" + } + if !ALT.isEmpty { + systemPrompt += "ALT:\(ALT)\n" + } + if !AST.isEmpty { + systemPrompt += "AST:\(AST)\n" + } + if !BUN.isEmpty { + systemPrompt += "BUN:\(BUN)\n" + } + if !Calcium.isEmpty { + systemPrompt += "Calcium:\(Calcium)\n" + } + if !Creatinine.isEmpty { + systemPrompt += "Creatinine:\(Creatinine)\n" + } + if !Glucose.isEmpty { + systemPrompt += "Glucose:\(Glucose)\n" + } + if !HbA1c.isEmpty { + systemPrompt += "HbA1c:\(HbA1c)\n" + } + if !Potassium.isEmpty { + systemPrompt += "Potassium:\(Potassium)\n" + } + if !Sodium.isEmpty { + systemPrompt += "Sodium:\(Sodium)\n" + } + if !Triglycerides.isEmpty { + systemPrompt += "Triglycerides:\(Triglycerides)\n" + } + if !LDL.isEmpty { + systemPrompt += "LDL:\(LDL)\n" + } + if !HDL.isEmpty { + systemPrompt += "HDL:\(HDL)\n" + } + if !eGFR.isEmpty { + systemPrompt += "eGFR:\(eGFR)\n" + } + + // systemPrompt += "\nNow that you've seen these biomarkers, the patient would like to see you. Please respond exactly like a licensed medical doctor would. Do not make any assumptions about the patient initially, but use the patient's biomarker data you've been to guide your response. The patient asks the following question:\n" + + systemPrompt += "\nPlease remember this information to provide either an accurate assessment of their health or a comprehensive overall assessment of their health. They would now would like to speak with you. Please respond accordingly. The patient asks the following question:\n" + + + + + + + + print("information " + systemPrompt) + appState.chatState.getBioData(prompt: systemPrompt) + appState.models.first?.startChat(chatState: appState.chatState) + showChatView = true + + }.padding() .foregroundColor(.white) .background(Color.teal) .cornerRadius(10) - + .padding(.bottom, 35) + } -// } -// .background(Color.clear) // Ensure the background is transparent to see the image + // } + // .background(Color.clear) // Ensure the background is transparent to see the image + .background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1)) + }.onChange(of: Age) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Weight) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Height) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Symptoms) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Allergies) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Medications) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Temperature) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Heart_Rate) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Respiratory_Rate) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Oxygen_Saturation) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Waist_Circumference) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Hip_Circumference) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Diastolic_Blood_Pressure) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Systolic_Blood_Pressure) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Albumin) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: ALT) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: AST) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: BUN) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Calcium) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Creatinine) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Glucose) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: HbA1c) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Potassium) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Sodium) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: Triglycerides) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: LDL) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: HDL) { newValue in appState.chatState.requestResetChat() - - } + + } .onChange(of: eGFR) { newValue in appState.chatState.requestResetChat() - - } + + } @@ -363,7 +372,7 @@ struct StartView: View { Text(appState.alertMessage) } } - .navigationViewStyle(StackNavigationViewStyle()) + .navigationViewStyle(.stack) .accentColor(Color.teal) // Optional: Setting the accent color to teal } }