How do you modify container views in SwiftUI?

How do you modify container views in SwiftUI?

For example, a sheet or popover. These views have a particular shape and different properties on how they can be customized in iOS, iPadOS, macOS, etc.

However it seems that they're only available as modifiers on another view. Can someone explain why that should be the case? Like, why should a popover only be available as a .popover modifier, which does not actually modify the view that you apply it to?

From what I can tell, because .popover and .sheet are only given as modifiers (but not as an actual view struct), there seems to be no way to modify how the presentation container itself looks. For example, SwiftUI gives none of the normal customization for a sheet, such as the corner radius, detents, dimming behavior, etc. Am I missing something here? Why would Apple leave this stuff out?

Can someone explain why Apple has chosen to have .sheet or .popover as modifiers, even though:

  • it doesn't actually modify the view you're applying it to
  • it means you cannot modify the sheet or popover itself because any modifiers you apply will affect the same thing the .sheet or .popover or .alert modifier (etc.) applied to

For example, not even the font of a button in an .alert can be changed, even though it lets you try:

Text("I am not actually being modified at all.)
.alert(Text("My font won't be affected by any modifiers.").font(.myFont), isPresented: $isPresented) { ... }

This compiles just fine, but the font modifier has no effect.

I feel like I must be missing something here... am I? Does SwiftUI have a solution for us, other than writing custom wrappers around the UIAlert/AppKit/WatchKit stuff? If not, do we know why not? Like... is Apple is deliberately choosing to make SwiftUI this limited, or is this what they could do within the time that has elapsed so far?

Thanks for any insights/tips.

Note: I'm not against wrapping UIKit/AppKit/WatchKit but would like to make sure that I'm understanding how the API is designed to be used so that whatever custom APIs we craft would match the spirit of SwiftUI as closely as possible. The main thing I'm having trouble with is understanding why modal containers are not first-class citizens that you can apply view modifiers to.

I have done a lot of research into various alternate repos and strategies, but just trying to make sure there's not something that we're all missing here.