Skip to content

Instantly share code, notes, and snippets.

@apatronl
Created May 2, 2024 03:36
Show Gist options
  • Save apatronl/2adb0925ac47b4c34c2c77f45abfa7dd to your computer and use it in GitHub Desktop.
Save apatronl/2adb0925ac47b4c34c2c77f45abfa7dd to your computer and use it in GitHub Desktop.
@MainActor
struct ChatView: View {
@Bindable private var viewModel: ChatViewModel = ChatViewModel()
var body: some View {
NavigationStack {
VStack {
ChatMessagesList(viewModel: viewModel)
if viewModel.error != nil {
ErrorView()
}
HStack {
MessageTextField(draftMessage: $viewModel.draftMessage)
SendMessageButton {
Task {
await viewModel.sendMessage()
}
}
.disabled(!viewModel.canSendMessage)
}
.padding(8)
}
.navigationTitle("Gemini Chat")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment