diff --git a/Evergreen/AppImages.swift b/Evergreen/AppImages.swift index 6b08ab7b7..17c160577 100644 --- a/Evergreen/AppImages.swift +++ b/Evergreen/AppImages.swift @@ -11,6 +11,7 @@ import AppKit extension NSImage.Name { static let star = NSImage.Name(rawValue: "star") static let unstar = NSImage.Name(rawValue: "unstar") + static let timelineStar = NSImage.Name(rawValue: "timelineStar") } struct AppImages { @@ -20,4 +21,8 @@ struct AppImages { let image = NSImage(contentsOfFile: path) return image }() + + static var timelineStar: NSImage! = { + return NSImage(named: .timelineStar) + }() } diff --git a/Evergreen/Assets.xcassets/timelineStar.imageset/Contents.json b/Evergreen/Assets.xcassets/timelineStar.imageset/Contents.json new file mode 100644 index 000000000..838695523 --- /dev/null +++ b/Evergreen/Assets.xcassets/timelineStar.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "timelineStar.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "timelineStar@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Evergreen/Assets.xcassets/timelineStar.imageset/timelineStar.png b/Evergreen/Assets.xcassets/timelineStar.imageset/timelineStar.png new file mode 100644 index 000000000..eb88ecbc7 Binary files /dev/null and b/Evergreen/Assets.xcassets/timelineStar.imageset/timelineStar.png differ diff --git a/Evergreen/Assets.xcassets/timelineStar.imageset/timelineStar@2x.png b/Evergreen/Assets.xcassets/timelineStar.imageset/timelineStar@2x.png new file mode 100644 index 000000000..4bd2acdf1 Binary files /dev/null and b/Evergreen/Assets.xcassets/timelineStar.imageset/timelineStar@2x.png differ diff --git a/Evergreen/MainWindow/Timeline/Cell/TimelineCellData.swift b/Evergreen/MainWindow/Timeline/Cell/TimelineCellData.swift index 314a52d4f..f7e6ff5e2 100644 --- a/Evergreen/MainWindow/Timeline/Cell/TimelineCellData.swift +++ b/Evergreen/MainWindow/Timeline/Cell/TimelineCellData.swift @@ -27,6 +27,7 @@ struct TimelineCellData { let showAvatar: Bool // Make space even when avatar is nil let featuredImage: NSImage? // image from within the article let read: Bool + let starred: Bool init(article: Article, appearance: TimelineCellAppearance, showFeedName: Bool, feedName: String?, avatar: NSImage?, showAvatar: Bool, featuredImage: NSImage?) { @@ -72,6 +73,7 @@ struct TimelineCellData { self.featuredImage = featuredImage self.read = article.status.read + self.starred = article.status.starred } init() { //Empty @@ -88,6 +90,7 @@ struct TimelineCellData { self.avatar = nil self.featuredImage = nil self.read = true + self.starred = false } static func emptyCache() { diff --git a/Evergreen/MainWindow/Timeline/Cell/TimelineCellLayout.swift b/Evergreen/MainWindow/Timeline/Cell/TimelineCellLayout.swift index 9f08dba9d..daed6895b 100644 --- a/Evergreen/MainWindow/Timeline/Cell/TimelineCellLayout.swift +++ b/Evergreen/MainWindow/Timeline/Cell/TimelineCellLayout.swift @@ -126,7 +126,7 @@ private func rectForStar(_ cellData: TimelineCellData, _ appearance: TimelineCel r.size.width = appearance.starDimension r.size.height = appearance.starDimension r.origin.x = floor(unreadIndicatorRect.origin.x - ((appearance.starDimension - appearance.unreadCircleDimension) / 2.0)) - r.origin.y = unreadIndicatorRect.origin.y + r.origin.y = unreadIndicatorRect.origin.y - 3.0 return r } diff --git a/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift b/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift index 23500c854..f200b1cb3 100644 --- a/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift +++ b/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift @@ -8,6 +8,7 @@ import Foundation import RSTextDrawing +import DB5 class TimelineTableCellView: NSTableCellView { @@ -25,13 +26,14 @@ class TimelineTableCellView: NSTableCellView { return imageView }() -// let faviconImageView: NSImageView = { -// let imageView = NSImageView(frame: NSRect(x: 0, y: 0, width: 16, height: 16)) -// imageView.imageScaling = .scaleProportionallyDown -// imageView.animates = false -// imageView.imageAlignment = .alignCenter -// return imageView -// }() + let starView: NSImageView = { + let imageView = NSImageView(frame: NSRect.zero) + imageView.imageScaling = .scaleNone + imageView.animates = false + imageView.imageAlignment = .alignCenter + imageView.image = AppImages.timelineStar + return imageView + }() var cellAppearance: TimelineCellAppearance! { didSet { @@ -91,7 +93,7 @@ class TimelineTableCellView: NSTableCellView { addSubviewAtInit(dateView, hidden: false) addSubviewAtInit(feedNameView, hidden: true) addSubviewAtInit(avatarImageView, hidden: false) -// addSubviewAtInit(faviconImageView, hidden: true) + addSubviewAtInit(starView, hidden: false) } override init(frame frameRect: NSRect) { @@ -140,6 +142,7 @@ class TimelineTableCellView: NSTableCellView { dateView.rs_setFrameIfNotEqual(layoutRects.dateRect) feedNameView.rs_setFrameIfNotEqual(layoutRects.feedNameRect) avatarImageView.rs_setFrameIfNotEqual(layoutRects.avatarImageRect) + starView.rs_setFrameIfNotEqual(layoutRects.starRect) // faviconImageView.rs_setFrameIfNotEqual(layoutRects.faviconRect) } @@ -186,12 +189,18 @@ class TimelineTableCellView: NSTableCellView { } private func updateUnreadIndicator() { - - if unreadIndicatorView.isHidden != cellData.read { - unreadIndicatorView.isHidden = cellData.read + + let shouldHide = cellData.read || cellData.starred + if unreadIndicatorView.isHidden != shouldHide { + unreadIndicatorView.isHidden = shouldHide } } + private func updateStarView() { + + starView.isHidden = !cellData.starred + } + private func updateAvatar() { if !cellData.showAvatar { @@ -240,6 +249,7 @@ class TimelineTableCellView: NSTableCellView { updateDateView() updateFeedNameView() updateUnreadIndicator() + updateStarView() updateAvatar() // updateFavicon() } @@ -256,3 +266,4 @@ class TimelineTableCellView: NSTableCellView { } } } + diff --git a/Evergreen/Resources/DB5.plist b/Evergreen/Resources/DB5.plist index 196dc661c..6188f6b17 100644 --- a/Evergreen/Resources/DB5.plist +++ b/Evergreen/Resources/DB5.plist @@ -114,7 +114,7 @@ avatarCornerRadius 7 starDimension - 19 + 13 Detail