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 {
|
extension NSImage.Name {
|
||||||
static let star = NSImage.Name(rawValue: "star")
|
static let star = NSImage.Name(rawValue: "star")
|
||||||
static let unstar = NSImage.Name(rawValue: "unstar")
|
static let unstar = NSImage.Name(rawValue: "unstar")
|
||||||
|
static let timelineStar = NSImage.Name(rawValue: "timelineStar")
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AppImages {
|
struct AppImages {
|
||||||
|
@ -20,4 +21,8 @@ struct AppImages {
|
||||||
let image = NSImage(contentsOfFile: path)
|
let image = NSImage(contentsOfFile: path)
|
||||||
return image
|
return image
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
static var timelineStar: NSImage! = {
|
||||||
|
return NSImage(named: .timelineStar)
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 981 B |
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 showAvatar: Bool // Make space even when avatar is nil
|
||||||
let featuredImage: NSImage? // image from within the article
|
let featuredImage: NSImage? // image from within the article
|
||||||
let read: Bool
|
let read: Bool
|
||||||
|
let starred: Bool
|
||||||
|
|
||||||
init(article: Article, appearance: TimelineCellAppearance, showFeedName: Bool, feedName: String?, avatar: NSImage?, showAvatar: Bool, featuredImage: NSImage?) {
|
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.featuredImage = featuredImage
|
||||||
|
|
||||||
self.read = article.status.read
|
self.read = article.status.read
|
||||||
|
self.starred = article.status.starred
|
||||||
}
|
}
|
||||||
|
|
||||||
init() { //Empty
|
init() { //Empty
|
||||||
|
@ -88,6 +90,7 @@ struct TimelineCellData {
|
||||||
self.avatar = nil
|
self.avatar = nil
|
||||||
self.featuredImage = nil
|
self.featuredImage = nil
|
||||||
self.read = true
|
self.read = true
|
||||||
|
self.starred = false
|
||||||
}
|
}
|
||||||
|
|
||||||
static func emptyCache() {
|
static func emptyCache() {
|
||||||
|
|
|
@ -126,7 +126,7 @@ private func rectForStar(_ cellData: TimelineCellData, _ appearance: TimelineCel
|
||||||
r.size.width = appearance.starDimension
|
r.size.width = appearance.starDimension
|
||||||
r.size.height = appearance.starDimension
|
r.size.height = appearance.starDimension
|
||||||
r.origin.x = floor(unreadIndicatorRect.origin.x - ((appearance.starDimension - appearance.unreadCircleDimension) / 2.0))
|
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
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import RSTextDrawing
|
import RSTextDrawing
|
||||||
|
import DB5
|
||||||
|
|
||||||
class TimelineTableCellView: NSTableCellView {
|
class TimelineTableCellView: NSTableCellView {
|
||||||
|
|
||||||
|
@ -25,13 +26,14 @@ class TimelineTableCellView: NSTableCellView {
|
||||||
return imageView
|
return imageView
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// let faviconImageView: NSImageView = {
|
let starView: NSImageView = {
|
||||||
// let imageView = NSImageView(frame: NSRect(x: 0, y: 0, width: 16, height: 16))
|
let imageView = NSImageView(frame: NSRect.zero)
|
||||||
// imageView.imageScaling = .scaleProportionallyDown
|
imageView.imageScaling = .scaleNone
|
||||||
// imageView.animates = false
|
imageView.animates = false
|
||||||
// imageView.imageAlignment = .alignCenter
|
imageView.imageAlignment = .alignCenter
|
||||||
// return imageView
|
imageView.image = AppImages.timelineStar
|
||||||
// }()
|
return imageView
|
||||||
|
}()
|
||||||
|
|
||||||
var cellAppearance: TimelineCellAppearance! {
|
var cellAppearance: TimelineCellAppearance! {
|
||||||
didSet {
|
didSet {
|
||||||
|
@ -91,7 +93,7 @@ class TimelineTableCellView: NSTableCellView {
|
||||||
addSubviewAtInit(dateView, hidden: false)
|
addSubviewAtInit(dateView, hidden: false)
|
||||||
addSubviewAtInit(feedNameView, hidden: true)
|
addSubviewAtInit(feedNameView, hidden: true)
|
||||||
addSubviewAtInit(avatarImageView, hidden: false)
|
addSubviewAtInit(avatarImageView, hidden: false)
|
||||||
// addSubviewAtInit(faviconImageView, hidden: true)
|
addSubviewAtInit(starView, hidden: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override init(frame frameRect: NSRect) {
|
override init(frame frameRect: NSRect) {
|
||||||
|
@ -140,6 +142,7 @@ class TimelineTableCellView: NSTableCellView {
|
||||||
dateView.rs_setFrameIfNotEqual(layoutRects.dateRect)
|
dateView.rs_setFrameIfNotEqual(layoutRects.dateRect)
|
||||||
feedNameView.rs_setFrameIfNotEqual(layoutRects.feedNameRect)
|
feedNameView.rs_setFrameIfNotEqual(layoutRects.feedNameRect)
|
||||||
avatarImageView.rs_setFrameIfNotEqual(layoutRects.avatarImageRect)
|
avatarImageView.rs_setFrameIfNotEqual(layoutRects.avatarImageRect)
|
||||||
|
starView.rs_setFrameIfNotEqual(layoutRects.starRect)
|
||||||
// faviconImageView.rs_setFrameIfNotEqual(layoutRects.faviconRect)
|
// faviconImageView.rs_setFrameIfNotEqual(layoutRects.faviconRect)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,12 +189,18 @@ class TimelineTableCellView: NSTableCellView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateUnreadIndicator() {
|
private func updateUnreadIndicator() {
|
||||||
|
|
||||||
if unreadIndicatorView.isHidden != cellData.read {
|
let shouldHide = cellData.read || cellData.starred
|
||||||
unreadIndicatorView.isHidden = cellData.read
|
if unreadIndicatorView.isHidden != shouldHide {
|
||||||
|
unreadIndicatorView.isHidden = shouldHide
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func updateStarView() {
|
||||||
|
|
||||||
|
starView.isHidden = !cellData.starred
|
||||||
|
}
|
||||||
|
|
||||||
private func updateAvatar() {
|
private func updateAvatar() {
|
||||||
|
|
||||||
if !cellData.showAvatar {
|
if !cellData.showAvatar {
|
||||||
|
@ -240,6 +249,7 @@ class TimelineTableCellView: NSTableCellView {
|
||||||
updateDateView()
|
updateDateView()
|
||||||
updateFeedNameView()
|
updateFeedNameView()
|
||||||
updateUnreadIndicator()
|
updateUnreadIndicator()
|
||||||
|
updateStarView()
|
||||||
updateAvatar()
|
updateAvatar()
|
||||||
// updateFavicon()
|
// updateFavicon()
|
||||||
}
|
}
|
||||||
|
@ -256,3 +266,4 @@ class TimelineTableCellView: NSTableCellView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
<key>avatarCornerRadius</key>
|
<key>avatarCornerRadius</key>
|
||||||
<integer>7</integer>
|
<integer>7</integer>
|
||||||
<key>starDimension</key>
|
<key>starDimension</key>
|
||||||
<integer>19</integer>
|
<integer>13</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Detail</key>
|
<key>Detail</key>
|
||||||
|
|
Loading…
Reference in New Issue