From 30d4ae7444dcb197d86f7367de4c7cf7852f1bf1 Mon Sep 17 00:00:00 2001 From: JoyboyBrian Date: Wed, 6 Nov 2024 16:46:14 -0800 Subject: [PATCH] add a send button for ios demo app --- examples/swift-test/Shared/ContentView.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/examples/swift-test/Shared/ContentView.swift b/examples/swift-test/Shared/ContentView.swift index 8b969b54..ad686c70 100644 --- a/examples/swift-test/Shared/ContentView.swift +++ b/examples/swift-test/Shared/ContentView.swift @@ -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 { @@ -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)