Skip to content

Instantly share code, notes, and snippets.

@StewartLynch
Last active February 14, 2026 20:08
Show Gist options
  • Select an option

  • Save StewartLynch/e0728488737d0ea3a29b63711d361343 to your computer and use it in GitHub Desktop.

Select an option

Save StewartLynch/e0728488737d0ea3a29b63711d361343 to your computer and use it in GitHub Desktop.
Gift Form View for Gift Registry SQLiteData series
import SwiftUI
struct GiftForm: View {
@State private var name = ""
@State private var price: Double?
@State private var isPurchased = false
@Environment(\.dismiss) var dismiss
var body: some View {
NavigationStack {
Form {
Section("Gift Details") {
TextField("Gift Name", text: $name)
LabeledContent("Price") {
TextField("Price", value: $price,
format: .currency(
code: Locale.current.currency?.identifier ?? "USD"
)
)
.keyboardType(.decimalPad)
.multilineTextAlignment(.trailing)
}
Toggle("Purchased", isOn: $isPurchased)
}
}
.navigationTitle("Gift")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Cancel") {
dismiss()
}
}
ToolbarItem(placement: .confirmationAction) {
Button("Save") {
dismiss()
}
.disabled(name.trimmingCharacters(in: .whitespaces).isEmpty)
}
}
}
}
}
#Preview {
GiftForm()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment