Skip to content

Instantly share code, notes, and snippets.

@anupamchugh
Created February 20, 2020 13:06
Show Gist options
  • Save anupamchugh/d26788b88dd081d9d24d650857557a94 to your computer and use it in GitHub Desktop.
Save anupamchugh/d26788b88dd081d9d24d650857557a94 to your computer and use it in GitHub Desktop.
struct CommentView : View{
@ObservedObject var commentFeed = HNCommentFeed()
var body: some View {
List(commentFeed.comments){ item in
Text(item.sentimentScore)
.background(((item.sentimentScore as NSString).floatValue >= 0.0) ? Color.green : Color.red)
.frame(alignment: .trailing)
Text(item.text ?? "")
}
.navigationBarTitle("Comment Score \(commentFeed.sentimentAvg)")
.navigationBarItems(trailing: (((commentFeed.sentimentAvg as NSString).floatValue >= 0.0) ? Image(systemName: "smiley.fill").foregroundColor(Color.green) : Image(systemName: "smiley.fill").foregroundColor(Color.red)))
}
init(commentIds: [Int]) {
commentFeed.getIds(ids: commentIds)
}
}
@abrahamali5
Copy link

Why have you shared the code in bits and pieces and not in the form of project?

@abrahamali5
Copy link

I went through your article and really disappointed to see the different files being shared instead of one github project. Can you please make it one github project, so that things are easy for everyone?

Thanks for your effort !

@anupamchugh
Copy link
Author

anupamchugh commented Jul 12, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment