Is there a way to lock a SwiftUI View into a particular orientation?

I am able to listen for existing orientation changes by using UIDevice.orientationDidChangeNotification. However I want to lock SwiftUI views to a particular orientation based on a requirement.

Is there a way to do it without introducing AppDelegate?

I did not find a simple way to do it for a view (not the whole app).

As you noticed, it seems necessary for now to go through appDelegate (not very SwitUIesque but not a big issue though)

You probably have seen this: https://www.polpiella.dev/changing-orientation-for-a-single-screen-in-swiftui

Is there a way to lock a SwiftUI View into a particular orientation?
 
 
Q