Skip to content

Commit

Permalink
Merge pull request llSourcell#34 from bowels/main
Browse files Browse the repository at this point in the history
pulling in changes to UI
  • Loading branch information
llSourcell authored Sep 20, 2023
2 parents 6c5f9ef + 6bd8cf7 commit 5e31a4c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 31 deletions.
6 changes: 4 additions & 2 deletions ios/MLCChat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,12 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"MLCChat/Preview Content\"";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = 3724XY74U5;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
"HEADER_SEARCH_PATHS[arch=*]" = "";
INFOPLIST_FILE = MLCChat/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Doctor Dignity";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
INFOPLIST_KEY_NSCameraUsageDescription = "This app requires usage of camera to function properly.";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
Expand Down Expand Up @@ -482,11 +483,12 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"MLCChat/Preview Content\"";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = 3724XY74U5;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
"HEADER_SEARCH_PATHS[arch=*]" = "";
INFOPLIST_FILE = MLCChat/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Doctor Dignity";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
INFOPLIST_KEY_NSCameraUsageDescription = "This app requires usage of camera to function properly.";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
disableMainThreadChecker = "YES"
Expand Down
10 changes: 8 additions & 2 deletions ios/MLCChat/States/ChatState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ final class ChatState: ObservableObject {
}

func requestResetChat() {
guard isResettable else {
return
}

assert(isResettable)
// assert(isResettable)
interruptChat(prologue: {
switchToResetting()
}, epilogue: { [weak self] in
Expand Down Expand Up @@ -337,7 +340,10 @@ private extension ChatState {
func mainResetChat() {
threadWorker.push {[weak self] in
guard let self else { return }
chatModule.resetChat()

if isResettable {
chatModule.resetChat()
}
if useVision {
chatModule.resetImageModule()
}
Expand Down
63 changes: 37 additions & 26 deletions ios/MLCChat/Views/ModelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@ import UIKit

struct CustomTextField: UIViewRepresentable {
@Binding var text: String
let keyboardType: UIKeyboardType

func makeUIView(context: Context) -> UITextField {
let textField = UITextField()
textField.delegate = context.coordinator
textField.returnKeyType = .done
textField.autocorrectionType = .no // Disable autocorrection
textField.autocapitalizationType = .none // Disable autocapitalization
textField.inputView = nil // Remove custom input views
textField.inputAccessoryView = nil // Remove custom accessory views
textField.keyboardType = keyboardType

return textField
}

Expand All @@ -30,6 +37,9 @@ struct CustomTextField: UIViewRepresentable {
textField.resignFirstResponder()
return true
}
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
return true
}

func textFieldDidChangeSelection(_ textField: UITextField) {
parent.text = textField.text ?? ""
Expand All @@ -39,9 +49,10 @@ struct CustomTextField: UIViewRepresentable {

struct ContentView: View {
@State private var text: String = ""

let keyboardType: UIKeyboardType = .default

var body: some View {
CustomTextField(text: $text)
CustomTextField(text: $text, keyboardType: keyboardType)
.background(Color.gray.opacity(0.2))
.cornerRadius(8)
.padding()
Expand Down Expand Up @@ -120,23 +131,23 @@ struct ModelView: View {
HStack {
Text("Age:")
.frame(width: 80, alignment: .leading)
CustomTextField(text: $Age)
CustomTextField(text: $Age, keyboardType: .numberPad)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Weight:")
.frame(width: 80, alignment: .leading)
CustomTextField(text: $Weight)
CustomTextField(text: $Weight, keyboardType: .numbersAndPunctuation)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Height:")
.frame(width: 80, alignment: .leading)
CustomTextField(text: $Height)
CustomTextField(text: $Height, keyboardType: .numbersAndPunctuation)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
Expand All @@ -150,23 +161,23 @@ struct ModelView: View {
HStack {
Text("Symptoms:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Symptoms)
CustomTextField(text: $Symptoms, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Allergies:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Allergies)
CustomTextField(text: $Allergies, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Medications:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Medications)
CustomTextField(text: $Medications, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
Expand All @@ -179,63 +190,63 @@ struct ModelView: View {
HStack {
Text("Temp.:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Temperature)
CustomTextField(text: $Temperature, keyboardType: .numbersAndPunctuation)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Heart Rate:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Heart_Rate)
CustomTextField(text: $Heart_Rate, keyboardType: .numbersAndPunctuation)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Respiratory Rate:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Respiratory_Rate)
CustomTextField(text: $Respiratory_Rate, keyboardType: .default)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Oxygen Saturation:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Oxygen_Saturation)
CustomTextField(text: $Oxygen_Saturation, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Waist Circum.:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Waist_Circumference)
CustomTextField(text: $Waist_Circumference, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Hip Circum.:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Hip_Circumference)
CustomTextField(text: $Hip_Circumference, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Diastolic Blood Pressure:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Diastolic_Blood_Pressure)
CustomTextField(text: $Diastolic_Blood_Pressure, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Systolic Blood Pressure:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Systolic_Blood_Pressure)
CustomTextField(text: $Systolic_Blood_Pressure, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
Expand All @@ -249,79 +260,79 @@ struct ModelView: View {
HStack {
Text("Albumin:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Albumin)
CustomTextField(text: $Albumin, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("ALT:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $ALT)
CustomTextField(text: $ALT, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("AST:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $AST)
CustomTextField(text: $AST, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("BUN:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $BUN)
CustomTextField(text: $BUN, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Calcium:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Calcium)
CustomTextField(text: $Calcium, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Creatinine:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Creatinine)
CustomTextField(text: $Creatinine, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Glucose:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Glucose)
CustomTextField(text: $Glucose, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("HbA1c:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $HbA1c)
CustomTextField(text: $HbA1c, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Potassium:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Potassium)
CustomTextField(text: $Potassium, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
}
HStack {
Text("Sodium:")
.frame(width: 100, alignment: .leading)
CustomTextField(text: $Sodium)
CustomTextField(text: $Sodium, keyboardType: .alphabet)
.background(colorScheme == .dark ? Color.clear : Color.gray.opacity(0.1))
.cornerRadius(8)
.padding()
Expand Down

0 comments on commit 5e31a4c

Please sign in to comment.