Drink Screens
Part of the Introduction to SwiftUI section of Coddy's Swift journey. Lesson 44 of 50.
Challenge
EasyKeep the menu from the previous step. Now make every row open a screen for its drink:
- Add a view
OrderViewwith alet drink: Drinkproperty. It shows the drink's price with two decimals in the.titlefont (identifierprice) inside aVStack(spacing: 16), and uses the drink's name as its title. - Wrap each row's
HStackin aNavigationLinkwhose destination isOrderView(drink: drink).
Try it yourself
import SwiftUI
@main
struct CoddyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}All lessons in Introduction to SwiftUI
Practice on your own: Swift playground