So I have a minimum target of iOS 16, am using .sheet() with .presentationDetents([.medium]) and it works fine on iOS (iPhone). But when I load it on iPadOS it's always a fullsized sheet, seemingly ignoring the presentation detents. Here is a minimal reproducable code that demonstrates this behaviour.
import SwiftUI
struct ContentView: View {
@State var shouldShowSheet: Bool = false
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
Button("Show Sheet") {
shouldShowSheet.toggle()
}
}
.padding()
.sheet(isPresented: $shouldShowSheet, content: {
VStack {
Text("Some content")
Text("Some more content")
Text("Even more content")
Button("Dismiss Sheet") {
shouldShowSheet.toggle()
}
}
.presentationDetents([.medium])
})
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Below are screenshots of the same code running on iOS and running on iPadOS
I tried using .fraction, .medium, .height and none of them had any effect on iPad sheets. The sheet is always a full-sized one as shown in the image. But on iOS(iPhone) it works as expected.
I'm expecting sheets on iPads to also respect the presentation detents. How can I get different sized sheets on iPad?