Menu
Coddy logo textTech

Drink Screens

Part of the Introduction to SwiftUI section of Coddy's Swift journey. Lesson 44 of 50.

challenge icon

Challenge

Easy

Keep the menu from the previous step. Now make every row open a screen for its drink:

  1. Add a view OrderView with a let drink: Drink property. It shows the drink's price with two decimals in the .title font (identifier price) inside a VStack(spacing: 16), and uses the drink's name as its title.
  2. Wrap each row's HStack in a NavigationLink whose destination is OrderView(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