Skip to content

Commit

Permalink
Added text chat input validation, enabling 'Send' button only for val…
Browse files Browse the repository at this point in the history
…id input.
  • Loading branch information
ssasika committed Oct 3, 2023
1 parent c45f332 commit 689283e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Demo/DemoChat/Sources/UI/DetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,20 @@ struct DetailView: View {
.frame(width: 24, height: 24)
.padding(.trailing)
}
.disabled(inputText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
}
.padding(.bottom)
}

private func tapSendMessage(
scrollViewProxy: ScrollViewProxy
) {
sendMessage(inputText, selectedChatModel)
let message = inputText.trimmingCharacters(in: .whitespacesAndNewlines)
if message.isEmpty {
return
}

sendMessage(message, selectedChatModel)
inputText = ""

// if let lastMessage = conversation.messages.last {
Expand Down

0 comments on commit 689283e

Please sign in to comment.