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)
}
}
@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