Here's how to display a list in SwiftUI. Since this is the screen after the screen transition, there is a NavigationBar.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct Fruit: Identifiable { | |
var id: Int | |
let name: String | |
} | |
struct ContentView: View { | |
let fruits: [Fruit] = [ | |
Fruit(id: 0, name: "Apple"), | |
Fruit(id: 1, name: "Banana"), | |
Fruit(id: 2, name: "Orange"), | |
Fruit(id: 3, name: "Grape"), | |
Fruit(id: 4, name: "WaterMelon"), | |
] | |
var body: some View { | |
VStack { | |
Divider() | |
List (fruits) { fruit in | |
Text(fruit.name) | |
} | |
.edgesIgnoringSafeArea([.bottom]) | |
} | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |