Created
January 9, 2021 11:43
-
-
Save dllewellyn/277996d2e10d1ae858460c853030c637 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
import SwiftUI | |
import shared | |
class ContentViewProxy : ObservableObject { | |
@Published | |
var listItems : [ListEntry] = [] | |
let repository = DefaultListItemRepository() | |
func load() { | |
listItems = repository.listItems() | |
} | |
} | |
struct ContentView: View { | |
@ObservedObject | |
var proxy = ContentViewProxy() | |
var body: some View { | |
List(proxy.listItems, id: \.title) { listItem in | |
ListViewItem(title: listItem.title, subtitle: listItem.subtitle, imageUrl: "SampleImage") | |
}.onAppear(perform: { | |
proxy.load() | |
}) | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment