Skip to content

Commit

Permalink
Fix comment colors
Browse files Browse the repository at this point in the history
  • Loading branch information
goranmoomin committed Aug 25, 2020
1 parent 6d75a07 commit d03ccdd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion HackerNews/Extensions/Atributika.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ extension TagTransformer {
}

extension String {
var styledAttributedString: NSAttributedString {
func styledAttributedString(textColor: Color) -> NSAttributedString {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.paragraphSpacing = 8
let systemFontSize = NSFont.systemFontSize(for: .regular)
let all = Style
.font(.systemFont(ofSize: systemFontSize))
.foregroundColor(textColor)
.paragraphStyle(paragraphStyle)
let a = Style("a")
let i = Style("i")
Expand Down
9 changes: 8 additions & 1 deletion HackerNews/Page/CommentCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ class CommentCellView: NSTableCellView {
}
}
authorLabel.stringValue = comment.author
textLabel.attributedStringValue = comment.text.styledAttributedString
let textColor: NSColor
switch comment.color {
case .c00: textColor = .labelColor
case .c5a, .c73, .c82: textColor = .secondaryLabelColor
case .c88, .c9c, .cae: textColor = .tertiaryLabelColor
case .cbe, .cce, .cdd: textColor = .quaternaryLabelColor
}
textLabel.attributedStringValue = comment.text.styledAttributedString(textColor: textColor)
creationLabel.stringValue = formatter.localizedString(for: comment.creation, relativeTo: Date())
}

Expand Down
2 changes: 1 addition & 1 deletion HackerNews/Page/ItemViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ItemViewController: NSViewController {
urlButton.isHidden = false
urlButton.title = host
} else if let text = story.content.text {
textLabel.attributedStringValue = text.styledAttributedString
textLabel.attributedStringValue = text.styledAttributedString(textColor: .labelColor)
textScrollView.isHidden = false
urlButton.isHidden = true
} else {
Expand Down

0 comments on commit d03ccdd

Please sign in to comment.