Skip to content

Instantly share code, notes, and snippets.

@dllewellyn
Created January 9, 2021 11:43
Show Gist options
  • Save dllewellyn/277996d2e10d1ae858460c853030c637 to your computer and use it in GitHub Desktop.
Save dllewellyn/277996d2e10d1ae858460c853030c637 to your computer and use it in GitHub Desktop.
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