EmptyList - List(SwiftUI) supports displaying Empty ListView for empty state
EmptyList(countries, listRowView: { country in
Text(country.name)
}, emptyListView: {
Text("No countries") // View displayed when the items collection isEmpty
})
// Source data for List. Source item must implement Identifiable protocol
struct Country: Identifiable {
let id: UUID
let name: String
}
// Source data items for List
let countries: [Country] = [
Country(id: UUID(), name: "Poland"),
Country(id: UUID(), name: "Germany")
/// Others countries
]
Look here if need more details
- Xcode 11+
- Swift 5.2+
And same requirements how to use SwiftUI. Availability:
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
Feel free copy-paste EmptyList
to your project or can install via CocoaPods.
For installation through CocoaPods add the following line to your Podfile:
pod 'EmptyList', '~> 1.0.0'
EmptyList is available under the MIT license. See the LICENSE file for more info.