Last active
October 6, 2021 18:16
-
-
Save gtokman/e49a33bb8bc8ce57a74d5082ed8b3421 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
struct ContentView: View { | |
let viewModel: ViewModel | |
@State var businesses = [Business]() | |
var body: some View { | |
NavigationView { | |
ZStack { | |
if businesses.isEmpty { | |
ProgressView("Loading...") | |
} | |
List(businesses) { business in | |
RestaurantCell(business: business) | |
} | |
.listStyle(.plain) | |
.navigationTitle(Text("Restaurants")) | |
} | |
} | |
.task { | |
do { | |
let businesses = try | |
await viewModel | |
.getBusinesses(for: "restaurants") | |
self.businesses = businesses | |
} catch { | |
// Handle error | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment