Completing the Restaurant Detail screen
You now have a SwiftUI map view displaying a map. Now, you’ll create a new SwiftUI view to represent the Restaurant Detail screen and add the map view to it. Do the following steps:
- Choose File | New | File to open the template selector.
- iOS should already be selected. In the User Interface section, click SwiftUI View and click Next.
- Name the new file
RestaurantDetail
and click Create. TheRestaurantDetail
file appears in the Project navigator. - Declare and define the
RestaurantDetail
andRestaurantDetail_Previews
structures as shown:import SwiftUI struct RestaurantDetail: View { var selectedRestaurant: RestaurantItem var body: some View { VStack { MapView(lat: selectedRestaurant.lat, long: selectedRestaurant.long) .frame(height: 250) VStack(alignment: .leading) { Text(selectedRestaurant.title) .font(.largeTitle) ...