Show a star in the timeline for starred articles.
This commit is contained in:
parent
e789130248
commit
203637b30e
@ -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)
|
||||
}()
|
||||
}
|
||||
|
22
Evergreen/Assets.xcassets/timelineStar.imageset/Contents.json
vendored
Normal file
22
Evergreen/Assets.xcassets/timelineStar.imageset/Contents.json
vendored
Normal file
@ -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"
|
||||
}
|
||||
}
|
BIN
Evergreen/Assets.xcassets/timelineStar.imageset/timelineStar.png
vendored
Normal file
BIN
Evergreen/Assets.xcassets/timelineStar.imageset/timelineStar.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 981 B |
BIN
Evergreen/Assets.xcassets/timelineStar.imageset/timelineStar@2x.png
vendored
Normal file
BIN
Evergreen/Assets.xcassets/timelineStar.imageset/timelineStar@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -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() {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@
|
||||
<key>avatarCornerRadius</key>
|
||||
<integer>7</integer>
|
||||
<key>starDimension</key>
|
||||
<integer>19</integer>
|
||||
<integer>13</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>Detail</key>
|
||||
|
Loading…
x
Reference in New Issue
Block a user