Adding model objects and configuring navigation
You now have a view that can be used to represent a journal entry on the Journal List screen. You’ll use this view as a cell in a SwiftUI list, which is a container that presents data in a single column. You’ll also configure model objects to populate this list. Follow these steps:
- Right-click on the
HStack
view and choose Embed in VStack from the pop-up menu. This keeps all the views together when you embed them in a list. - Right-click on the outer
VStack
view and choose Embed in List to display a list containing five cells in the canvas. Remove the padding modifiers as well. - Verify that your code now looks like this:
struct ContentView: View { var body: some View { List(0 ..< 5) { item in VStack { HStack { Image(systemName: "face.smiling") .resizable() .frame(width: 90, height: 90) VStack { Text("...