Skip to content

Instantly share code, notes, and snippets.

@anupamchugh
Created February 20, 2020 11:22
Show Gist options
  • Save anupamchugh/50c18ed71bdd92b78943fda8caad4633 to your computer and use it in GitHub Desktop.
Save anupamchugh/50c18ed71bdd92b78943fda8caad4633 to your computer and use it in GitHub Desktop.
struct ContentView: View {
@ObservedObject var hnFeed = HNStoriesFeed()
var body: some View {
NavigationView{
List(hnFeed.storyItems){ articleItem in
NavigationLink(destination: LazyView(CommentView(commentIds: articleItem.kids ?? []))){
StoryListItemView(article: articleItem)
}
}
.navigationBarTitle("Hacker News Stories")
}
}
}
struct StoryListItemView: View {
var article: StoryItem
var body: some View {
VStack(alignment: .leading) {
Text("\(article.title ?? "")")
.font(.headline)
Text("Author: \(article.by)")
.font(.subheadline)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment