Created
July 8, 2021 14:56
-
-
Save Toni77777/399067b97d2a7686951b9bd737b579d8 to your computer and use it in GitHub Desktop.
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
extension List { | |
func emptyListPlaceholder(_ items: [Any], _ placeholder: AnyView) -> some View { | |
modifier(EmptyDataModifier(items: items, placeholder: placeholder)) | |
} | |
} | |
struct ContentView: View { | |
@State var countries: [Country] = [] // Data source | |
var body: some View { | |
List(countries) { country in | |
Text(country.name) | |
.font(.title) | |
} | |
.emptyListPlaceholder( | |
countries, | |
AnyView(ListPlaceholderView()) // Placeholder | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment