Skip to content

Instantly share code, notes, and snippets.

@laevandus
Last active September 24, 2019 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/c025c1a670355157338ab3d7dc9d16ff to your computer and use it in GitHub Desktop.
Save laevandus/c025c1a670355157338ab3d7dc9d16ff to your computer and use it in GitHub Desktop.
import Combine
import SwiftUI
struct InputView: View {
let conversation: Conversation
@State private var inputText = ""
var body: some View {
HStack {
TextField("", text: $inputText)
.padding(6)
.background(Color.white)
Button(action: sendMessage) {
Text("Send")
}
}.padding(12).background(Color.init(white: 0.75))
}
private func sendMessage() {
self.conversation.send(Message(sender: "PersonA", text: self.inputText))
self.inputText = ""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment