From 867e775e6960a31ec9e1afaa0648a8f56af4f11c Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 31 Dec 2017 12:10:30 -0800 Subject: [PATCH] Show feed icons and avatars in the timeline. --- .../Cell/TimelineCellAppearance.swift | 6 ++-- .../Timeline/Cell/TimelineTableCellView.swift | 32 ++++++++++++------- .../Timeline/TimelineViewController.swift | 1 + Evergreen/Resources/DB5.plist | 6 ++-- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/Evergreen/MainWindow/Timeline/Cell/TimelineCellAppearance.swift b/Evergreen/MainWindow/Timeline/Cell/TimelineCellAppearance.swift index 40377440e..e332c5ea1 100644 --- a/Evergreen/MainWindow/Timeline/Cell/TimelineCellAppearance.swift +++ b/Evergreen/MainWindow/Timeline/Cell/TimelineCellAppearance.swift @@ -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 } } diff --git a/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift b/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift index 07caa9a35..a04933b13 100644 --- a/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift +++ b/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift @@ -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() { diff --git a/Evergreen/MainWindow/Timeline/TimelineViewController.swift b/Evergreen/MainWindow/Timeline/TimelineViewController.swift index cb84461b7..c0d2242ad 100644 --- a/Evergreen/MainWindow/Timeline/TimelineViewController.swift +++ b/Evergreen/MainWindow/Timeline/TimelineViewController.swift @@ -81,6 +81,7 @@ class TimelineViewController: NSViewController, UndoableCommandRunner { } postTimelineSelectionDidChangeNotification(nil) + articles = ArticleArray() fetchArticles() if articles.count > 0 { tableView.scrollRowToVisible(0) diff --git a/Evergreen/Resources/DB5.plist b/Evergreen/Resources/DB5.plist index 17f87ccf5..8a8a06706 100644 --- a/Evergreen/Resources/DB5.plist +++ b/Evergreen/Resources/DB5.plist @@ -104,13 +104,15 @@ unreadCircleMarginRight 8 avatarHeight - 42 + 48 avatarWidth - 42 + 48 avatarMarginRight 8 avatarAdjustmentTop 4 + avatarCornerRadius + 7 Detail