Menu

OnSubmit

Skip support for SwiftUI.View.onSubmit on Android. Consult the SkipUI module for a complete list of supported SwiftUI.

The following example screens and source code is from SkipUI’s Showcase sample app OnSubmitPlayground.swift

Android screenshot for OnSubmit component (light mode) iPhone screenshot for OnSubmit component (light mode) iPhone screenshot for OnSubmit component (dark mode) Android screenshot for OnSubmit component (dark mode)
import SwiftUI

struct OnSubmitPlayground: View {
    @State var text1 = ""
    @State var text2 = ""
    @State var submitText = ""

    var body: some View {
        Form {
            HStack {
                Text(submitText)
                Spacer()
                Button("Clear") {
                    submitText = ""
                }
            }
            TextField("Text1", text: $text1)
                .onSubmit {
                    submitText = submitText + "Text1 "
                }
            TextField("Text2", text: $text2)
                .onSubmit {
                    submitText = submitText + "Text2 "
                }
        }
        .onSubmit {
            submitText = submitText + "Form "
        }
        .toolbar {
            PlaygroundSourceLink(file: "OnSubmitPlayground.swift")
        }
    }
}