I use this in my code:
private var idiom : UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom }
private var isPortrait : Bool { UIDevice.current.orientation.isPortrait }
Then you can do this:
var body: some View {
NavigationView {
masterView()
if isPortrait {
portraitDetailView()
} else {
landscapeDetailView()
}
}
}
private func portraitDetailView() -> some View {
if idiom == .pad {
return Text("iPadOS")
} else {
return Text("iOS")
}
}