Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
231 changes: 94 additions & 137 deletions Neuro App/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,15 @@ struct HomeView: View {
@EnvironmentObject var signalingClient: SignalingClient
@EnvironmentObject var authViewModel: AuthViewModel
@StateObject private var formViewModel = StrokeScaleFormViewModel()
@State private var isNavigatingToSavedForms = false // State variable to control navigation
@State private var path = NavigationPath()

var body: some View {
if signalingClient.isInCall {
CallView(formViewModel: formViewModel)
} else {

NavigationView {
NavigationStack(path: $path) {
VStack {
/* Can use when we implement login and replace 'user' with username
Text("Hello, user!")
.font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
.bold()
.padding(10)
.foregroundColor(Color.black)
*/

// Logout button
HStack {
Spacer()
Button(action: {
Expand All @@ -51,133 +43,119 @@ struct HomeView: View {
.padding(.bottom, 5)
}

// Peer ID
VStack(spacing: 10) {
Text("Your Peer ID:")
.font(.headline)
.bold()
.multilineTextAlignment(.center)
.foregroundColor(
Color(UIColor { traitCollection in
return traitCollection.userInterfaceStyle == .dark ? .white : .black
})
)
Text("Your Peer ID:")
.font(.headline)
.bold()
.multilineTextAlignment(.center)
.foregroundColor(adaptiveColor())

Text(signalingClient.ourPeerID)
.font(.subheadline)
.multilineTextAlignment(.center)
.foregroundColor(adaptiveColor())
}
.padding()
.frame(maxWidth: .infinity)
.background(adaptiveBackground())
.cornerRadius(10)
.shadow(radius: 2)

Text(signalingClient.ourPeerID)
.font(.subheadline)
.multilineTextAlignment(.center)
.foregroundColor(
Color(UIColor { traitCollection in
return traitCollection.userInterfaceStyle == .dark ? .white : .black
})
)
}
// Active Consultations Header
Text("Active Consultations:")
.font(.headline)
.padding(.top, 20)
.foregroundColor(.black)

// Online Users List
ScrollView {
let filteredOnlineUsers = signalingClient.onlineUsers.filter { $0 != signalingClient.ourPeerID }

if filteredOnlineUsers.isEmpty {
Text("Hmm, nobody's here right now!")
.padding()
.frame(maxWidth: .infinity)
.background(
Color(UIColor { traitCollection in
return traitCollection.userInterfaceStyle == .dark ? .black : .white
})
)
.background(adaptiveBackground())
.cornerRadius(10)
.shadow(radius: 2)

Text("Active Consultations:")
.font(.headline)
.padding(.top, 20)
.foregroundColor(Color.black)

// Online Users List
ScrollView {
let filteredOnlineUsers = signalingClient.onlineUsers.filter { $0 != signalingClient.ourPeerID }

if filteredOnlineUsers.isEmpty {
Text("Hmm, nobody's here right now!")
.padding()
.frame(maxWidth: .infinity)
.background(
Color(UIColor { traitCollection in
return traitCollection.userInterfaceStyle == .dark ? .black : .white
})
)
.cornerRadius(10)
.shadow(radius: 2)
.padding(.horizontal)
.foregroundColor(
Color(UIColor { traitCollection in
return traitCollection.userInterfaceStyle == .dark ? .white : .black
})
)
} else {
VStack(spacing: 10) {
ForEach(filteredOnlineUsers, id: \.self) { user in
OnlineUserCardView(uuid: user)
}
}
}
.padding(.horizontal)
.foregroundColor(adaptiveColor())
} else {
VStack(spacing: 10) {
ForEach(filteredOnlineUsers, id: \.self) { user in
OnlineUserCardView(uuid: user)
}
.padding(.top, 10)

Spacer()

VStack {
Button(action: {
isNavigatingToSavedForms = true // Trigger navigation
}) {
Text("NIH Forms")
.font(.headline)
.foregroundColor(
Color(UIColor { traitCollection in
return traitCollection.userInterfaceStyle == .dark ? .white : .black
})
)
.padding()
.frame(maxWidth: .infinity)
.background(
Color(UIColor { traitCollection in
return traitCollection.userInterfaceStyle == .dark ? .black : .white
})
)
.cornerRadius(10)
}
.padding(.horizontal)
.padding(.bottom, 20)
.background(
NavigationLink(
destination: SavedFormsView(isNavigatingBack: $isNavigatingToSavedForms),
isActive: $isNavigatingToSavedForms,
label: { EmptyView() }
)
)
}
}
.padding(.top, 10)

Spacer()

// NIH Forms Button
Button(action: {
path.append("savedForms")
}) {
Text("NIH Forms")
.font(.headline)
.foregroundColor(adaptiveColor())
.padding()
.frame(maxWidth: .infinity)
.background(adaptiveBackground())
.cornerRadius(10)
}
.padding(.horizontal)
.padding(.bottom, 20)
}

// Navigation destination
.navigationDestination(for: String.self) { route in
switch route {
case "savedForms":
SavedFormsView(navigationPath: $path)
default:
EmptyView()
}
}

// Ringing overlay
.overlay(
Group {
if signalingClient.isRinging {
RingingPopopView(signalingClient: signalingClient)
}
}
)

// Background
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.padding()
.onAppear {
signalingClient.fetchOnlineUsers()
}
.background {
.background(
LinearGradient(colors: [.gray, .white, .gray], startPoint: .topLeading, endPoint: .bottomTrailing)
.edgesIgnoringSafeArea(.all)
.hueRotation(.degrees(45))
.onAppear {
withAnimation(
.easeInOut(duration: 2)
.repeatForever(autoreverses: true)) {}
}
.edgesIgnoringSafeArea(.all)
.hueRotation(.degrees(45))
.onAppear {
withAnimation(
.easeInOut(duration: 2)
.repeatForever(autoreverses: true)) {}
}
)
}
.navigationBarBackButtonHidden(true)
}
}

private func adaptiveColor() -> Color {
Color(UIColor { $0.userInterfaceStyle == .dark ? .white : .black })
}

private func adaptiveBackground() -> Color {
Color(UIColor { $0.userInterfaceStyle == .dark ? .black : .white })
}
}

struct OnlineUserCardView: View {
Expand All @@ -189,48 +167,27 @@ struct OnlineUserCardView: View {
.font(.subheadline)
.padding(.vertical, 10)
.padding(.leading, 15)
.foregroundColor(
Color(UIColor { traitCollection in
return traitCollection.userInterfaceStyle == .dark ? .white : .black
})
)
.foregroundColor(Color(UIColor { $0.userInterfaceStyle == .dark ? .white : .black }))

Spacer()

Button(action: {
// Action for call button
// Call action
}, label: {
HStack {
Image(systemName: "phone.fill")
.foregroundColor(
Color(UIColor { traitCollection in
return traitCollection.userInterfaceStyle == .dark ? .black : .white
})
)
.foregroundColor(Color(UIColor { $0.userInterfaceStyle == .dark ? .black : .white }))
Text("Call")
.foregroundColor(
Color(UIColor { traitCollection in
return traitCollection.userInterfaceStyle == .dark ? .black : .white
})
)
.foregroundColor(Color(UIColor { $0.userInterfaceStyle == .dark ? .black : .white }))
}
.padding(10)
.background(
Color(UIColor { traitCollection in
return traitCollection.userInterfaceStyle == .dark ? .white : .black
})
)
.background(Color(UIColor { $0.userInterfaceStyle == .dark ? .white : .black }))
.cornerRadius(8)
})
.padding(.trailing, 15)
}
.frame(maxWidth: .infinity)
.frame(maxWidth: .infinity, minHeight: 60)
.background(
Color(UIColor { traitCollection in
return traitCollection.userInterfaceStyle == .dark ? .black : .white
})
)
.background(Color(UIColor { $0.userInterfaceStyle == .dark ? .black : .white }))
.cornerRadius(10)
.shadow(radius: 2)
.padding(.horizontal)
Expand All @@ -248,13 +205,13 @@ struct RingingPopopView: View {
.foregroundColor(.white)
Button(action: {
signalingClient.cancelCall()
}, label: {
}) {
Text("Cancel")
.foregroundColor(.red)
.padding(5)
.background(Color.white)
.cornerRadius(10)
})
}
.padding(.bottom, 10)
}
.frame(width: 200, height: 100)
Expand Down
12 changes: 9 additions & 3 deletions Neuro App/NewNIHFormView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ struct NewNIHFormView: View {
var remoteForm: RemoteStrokeForm?
var initialSelectedOptions: [Int]

@Environment(\.presentationMode) var presentationMode
@Binding var navigationPath: NavigationPath
@Environment(\.managedObjectContext) private var viewContext
@StateObject private var viewModel = StrokeScaleFormViewModel()
@State private var patientName: String
@State private var patientDOB: Date
@State private var selectedOptions: [Int]
@State private var showDOBPicker: Bool = false

init(remoteForm: RemoteStrokeForm? = nil, initialSelectedOptions: [Int] = Array(repeating: -1, count: 15)) {
init(
navigationPath: Binding<NavigationPath>,
remoteForm: RemoteStrokeForm? = nil,
initialSelectedOptions: [Int] = Array(repeating: -1, count: 15)
) {
self._navigationPath = navigationPath
self.remoteForm = remoteForm
self.initialSelectedOptions = initialSelectedOptions

Expand Down Expand Up @@ -143,6 +148,7 @@ struct NewNIHFormView: View {
HStack {
Button(action: {
saveForm()
navigationPath.removeLast(navigationPath.count)
}) {
Text("Save")
.font(.headline)
Expand All @@ -155,7 +161,7 @@ struct NewNIHFormView: View {
}

Button(action: {
presentationMode.wrappedValue.dismiss() // Dismiss without saving
navigationPath.removeLast(navigationPath.count)
}) {
Text("Cancel")
.font(.headline)
Expand Down
Loading
Loading