Sure. The surrounding body looks like this:
var body: some View {
NavigationView {
Form {
TextField("Name", text: $child.name)
DatePicker("Date of Birth", selection: $child.dob, displayedComponents: .date)
}
.navigationBarTitle("Add Child", displayMode: .inline)
.navigationBarItems(leading: Button(action: self.onCancel) { Text("Cancel") }, trailing: Button(action: self.onSave) { Text("Save") })
}
}
The view is displayed in a sheet. in iOS 13, the DatePicker expands inline when the date value is touched. in iOS 14, instead of expanding inline, it displays modally instead.
Post
Replies
Boosts
Views
Activity
.datePickerStyle() doesn't alter whether the calendar is displayed inline or modally in iOS 14. I tired that and what it changes is how the date picker display is rendered (wheel/graphical/default). Please, test it yourself in iOS 14 - I can't upload a screenshot, but in my code, the new (iOS 14 calendar style) date picker is displayed in a modal view above a blurred overlay covering the rest of the screen. In the Apple apps, it expands beneath the row.
OK I think I've figured it out (but haven't proven it yet). I just watched the "Stacks, Grids and Outlines in SwiftUI" WWDC20 video and I think the Apple apps are using a DisclosureGroup to display the DatePicker inline in a Form. Will try it tomorrow and report back.
Thanks @tundaware - yeah the GraphicalDatePickerStyle is completely broken, and I dismissed it because of that, but now I see your point. You are correct that the DisclosureGroup didn't help in any way. I'll implement @OOPer 's solution, and hopefully the sizing issue will be fixed in the next beta.
Yeah I was all excited after watching wwdc20-10205, and then realised SwiftUI Button doesn't currently have a .menu 😔
Yeah it would be great to display just minutes for example, for the style: .relative case, as the constantly ticking seconds is a bit distracting.