Skip to content

Commit

Permalink
add a send button for ios demo app
Browse files Browse the repository at this point in the history
  • Loading branch information
JoyboyBrian committed Nov 7, 2024
1 parent f4ec3c1 commit 30d4ae7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/swift-test/Shared/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import SwiftUI
struct ContentView: View {
@State private var viewModel = ViewModel()
@State private var prompt = ""
@FocusState private var isInputActive: Bool

var body: some View {
VStack {
Expand All @@ -21,6 +22,18 @@ struct ContentView: View {
guard !prompt.isEmpty else { return }
viewModel.run(for: prompt)
}
.focused($isInputActive)

Button(action: {
guard !prompt.isEmpty else { return }
viewModel.run(for: prompt)
isInputActive = false
}) {
Text("Send")
.frame(maxWidth: .infinity)
}
.buttonStyle(.borderedProminent)
.padding(.bottom)

ScrollView {
Text(viewModel.result)
Expand Down

0 comments on commit 30d4ae7

Please sign in to comment.