From the course: Complete Guide to SwiftUI

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

Presenting views

Presenting views

- [Narrator] We've got all of our elements on the screen, but we still have a few problems. The screen is very crowded, even in portrait. If you check landscape for example, it's even worse. So going back to portrait here, I'm going to make a sneaky change here that we can now get rid of some of the problems we have with this crowded screen. So what I'm going to do is I'm going to add a Boolean variable, and I'll do that just underneath orders here, and I'll set that to true. And then what I'll do is I'll use an if-else construct in the body to switch between the order view and the menu view. And you can use if-else in here. So that's the one piece of logic you can get away with here in SwiftUI. So what I'm going to do is I'm going to take order view and make that one thing. And if showOrders, then we'll do that, else, I'll do MenuItemView and MenuView like that. And let's clean this up a little bit so it looks a little prettier. And now we've cleaned up the screen, so I can now go…

Contents