๐Ÿ“ฆList

SwiftUI โŸฉ lists โŸฉ List

A List displays any number of views in a scrolling vertical column, optionally providing the ability to select one or more members.

// โญ๏ธ list consisting of a single type
List(1..<5) { Text("Item \($0)") }
List(names, id: \.self) { Text("Item \($0)") }

// โญ๏ธ static subviews
List {
    Text("1")
    Text("2")
    Text("3")
}

// โญ๏ธ static & dynamic subviews
List {
    
    // โญ๏ธ static
    Toggle(isOn: $showFavoritesOnly) {
        Text("Favorites Only")
    }
    
    // โญ๏ธ dynamic
    ForEach(filteredLandmarks) { landmark in
        NavigationLink {
            LandmarkDetail(landmark: landmark)
        } label: {
            LandmarkRow(landmark: landmark)
        }
    }
    
}.navigationTitle("Landmarks")

Last updated