Show feed icons and avatars in the timeline.

This commit is contained in:
Brent Simmons 2017-12-31 12:10:30 -08:00
parent b35193b823
commit 867e775e69
4 changed files with 29 additions and 16 deletions

View File

@ -40,7 +40,8 @@ struct TimelineCellAppearance {
let avatarSize: NSSize
let avatarMarginRight: CGFloat
let avatarAdjustmentTop: CGFloat
let avatarCornerRadius: CGFloat
init(theme: VSTheme, fontSize: FontSize) {
let actualFontSize = AppDefaults.actualFontSize(for: fontSize)
@ -72,8 +73,9 @@ struct TimelineCellAppearance {
self.avatarSize = theme.size(forKey: "MainWindow.Timeline.cell.avatar")
self.avatarMarginRight = theme.float(forKey: "MainWindow.Timeline.cell.avatarMarginRight")
self.avatarAdjustmentTop = theme.float(forKey: "MainWindow.Timeline.cell.avatarAdjustmentTop")
self.avatarCornerRadius = theme.float(forKey: "MainWindow.Timeline.cell.avatarCornerRadius")
self.boxLeftMargin = self.cellPadding.left + self.unreadCircleDimension + self.unreadCircleMarginRight //+ self.avatarSize.width + self.avatarMarginRight
self.boxLeftMargin = self.cellPadding.left + self.unreadCircleDimension + self.unreadCircleMarginRight + self.avatarSize.width + self.avatarMarginRight
}
}

View File

@ -20,7 +20,7 @@ class TimelineTableCellView: NSTableCellView {
let imageView = NSImageView(frame: NSRect.zero)
imageView.imageScaling = .scaleProportionallyDown
imageView.animates = false
imageView.imageAlignment = .alignTop
imageView.imageAlignment = .alignCenter
return imageView
}()
@ -32,7 +32,13 @@ class TimelineTableCellView: NSTableCellView {
// return imageView
// }()
var cellAppearance: TimelineCellAppearance!
var cellAppearance: TimelineCellAppearance! {
didSet {
avatarImageView.layer?.cornerRadius = cellAppearance.avatarCornerRadius
avatarImageView.needsDisplay = true
}
}
var cellData: TimelineCellData! {
didSet {
updateSubviews()
@ -186,15 +192,17 @@ class TimelineTableCellView: NSTableCellView {
private func updateAvatar() {
// if let image = cellData.avatar {
// if avatarImageView.image !== image {
// avatarImageView.image = image
// }
// avatarImageView.isHidden = false
// }
// else {
// avatarImageView.isHidden = true
// }
avatarImageView.layer?.cornerRadius = cellAppearance.avatarCornerRadius
if let image = cellData.avatar {
if avatarImageView.image !== image {
avatarImageView.image = image
}
avatarImageView.isHidden = false
}
else {
avatarImageView.isHidden = true
}
}
private func updateFavicon() {
@ -216,7 +224,7 @@ class TimelineTableCellView: NSTableCellView {
updateFeedNameView()
updateUnreadIndicator()
updateAvatar()
updateFavicon()
// updateFavicon()
}
private func updateAppearance() {

View File

@ -81,6 +81,7 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
}
postTimelineSelectionDidChangeNotification(nil)
articles = ArticleArray()
fetchArticles()
if articles.count > 0 {
tableView.scrollRowToVisible(0)

View File

@ -104,13 +104,15 @@
<key>unreadCircleMarginRight</key>
<integer>8</integer>
<key>avatarHeight</key>
<integer>42</integer>
<integer>48</integer>
<key>avatarWidth</key>
<integer>42</integer>
<integer>48</integer>
<key>avatarMarginRight</key>
<integer>8</integer>
<key>avatarAdjustmentTop</key>
<integer>4</integer>
<key>avatarCornerRadius</key>
<integer>7</integer>
</dict>
</dict>
<key>Detail</key>