-
-
Save anupamchugh/50c18ed71bdd92b78943fda8caad4633 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
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