I am given an optional date, and would like the ability to display a date picker for it.
import SwiftUI
struct ContentView: View {
@State var someDate: Date?
var body: some View {
OptionalDate(date: $someDate)
}
}
struct OptionalDate: View {
@Binding var date: Date?
var body: some View {
if date == nil {
return Text("No date").onTapGesture {
self.date = Date() // start picking!
}
} else {
return DatePicker(selection: $date, displayedComponents: .date) {
Text("Due Date")
}
}
}
}
Cannot convert value of type 'Binding<Date?>' to expected argument type 'Binding<Date>'
Not to mention I'm going to have to figure out the opaque view...