Remove TimelineCellData attributed string properties that are no longer needed.
This commit is contained in:
parent
b52c82e8b6
commit
c9df252f9a
|
@ -19,9 +19,7 @@ struct TimelineCellData {
|
|||
let text: String
|
||||
let attributedTitle: NSAttributedString //title + text
|
||||
let dateString: String
|
||||
let attributedDateString: NSAttributedString
|
||||
let feedName: String
|
||||
let attributedFeedName: NSAttributedString
|
||||
let showFeedName: Bool
|
||||
let avatar: NSImage? // feed icon, user avatar, or favicon
|
||||
let showAvatar: Bool // Make space even when avatar is nil
|
||||
|
@ -44,13 +42,6 @@ struct TimelineCellData {
|
|||
}
|
||||
|
||||
self.dateString = timelineDateString(article.logicalDatePublished)
|
||||
if let s = attributedDateCache[self.dateString] {
|
||||
self.attributedDateString = s
|
||||
}
|
||||
else {
|
||||
self.attributedDateString = NSAttributedString(string: self.dateString, attributes: [NSAttributedStringKey.foregroundColor: appearance.dateColor, NSAttributedStringKey.font: appearance.dateFont])
|
||||
attributedDateCache[self.dateString] = self.attributedDateString
|
||||
}
|
||||
|
||||
if let feedName = feedName {
|
||||
self.feedName = timelineTruncatedFeedName(feedName)
|
||||
|
@ -58,13 +49,6 @@ struct TimelineCellData {
|
|||
else {
|
||||
self.feedName = ""
|
||||
}
|
||||
if let s = attributedFeedNameCache[self.feedName] {
|
||||
self.attributedFeedName = s
|
||||
}
|
||||
else {
|
||||
self.attributedFeedName = NSAttributedString(string: self.feedName, attributes: [NSAttributedStringKey.foregroundColor: appearance.feedNameColor, NSAttributedStringKey.font: appearance.feedNameFont])
|
||||
attributedFeedNameCache[self.feedName] = self.attributedFeedName
|
||||
}
|
||||
|
||||
self.showFeedName = showFeedName
|
||||
|
||||
|
@ -82,9 +66,7 @@ struct TimelineCellData {
|
|||
self.attributedTitle = NSAttributedString(string: "")
|
||||
self.text = ""
|
||||
self.dateString = ""
|
||||
self.attributedDateString = NSAttributedString(string: "")
|
||||
self.feedName = ""
|
||||
self.attributedFeedName = NSAttributedString(string: "")
|
||||
self.showFeedName = false
|
||||
self.showAvatar = false
|
||||
self.avatar = nil
|
||||
|
|
|
@ -87,7 +87,7 @@ private extension TimelineCellLayout {
|
|||
|
||||
static func rectForDate(_ textBoxRect: NSRect, _ titleRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect {
|
||||
|
||||
return rectOfLineBelow(textBoxRect, titleRect, appearance.titleBottomMargin, cellData.attributedDateString)
|
||||
return rectOfLineBelow(textBoxRect, titleRect, appearance.titleBottomMargin, cellData.dateString, appearance.dateFont)
|
||||
}
|
||||
|
||||
static func rectForFeedName(_ textBoxRect: NSRect, _ dateRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect {
|
||||
|
@ -96,13 +96,12 @@ private extension TimelineCellLayout {
|
|||
return NSZeroRect
|
||||
}
|
||||
|
||||
return rectOfLineBelow(textBoxRect, dateRect, appearance.titleBottomMargin, cellData.attributedFeedName)
|
||||
return rectOfLineBelow(textBoxRect, dateRect, appearance.titleBottomMargin, cellData.feedName, appearance.feedNameFont)
|
||||
}
|
||||
|
||||
static func rectOfLineBelow(_ textBoxRect: NSRect, _ rectAbove: NSRect, _ topMargin: CGFloat, _ attributedString: NSAttributedString) -> NSRect {
|
||||
static func rectOfLineBelow(_ textBoxRect: NSRect, _ rectAbove: NSRect, _ topMargin: CGFloat, _ value: String, _ font: NSFont) -> NSRect {
|
||||
|
||||
let font = attributedString.attribute(NSAttributedStringKey.font, at: 0, effectiveRange: nil) as! NSFont
|
||||
let textFieldSize = SingleLineTextFieldSizer.size(for: attributedString.string, font: font)
|
||||
let textFieldSize = SingleLineTextFieldSizer.size(for: value, font: font)
|
||||
var r = NSZeroRect
|
||||
r.size = textFieldSize
|
||||
r.origin.y = NSMaxY(rectAbove) + topMargin
|
||||
|
|
|
@ -236,7 +236,7 @@ private extension TimelineTableCellView {
|
|||
|
||||
func updateDateView() {
|
||||
|
||||
dateView.stringValue = cellData.attributedDateString.string
|
||||
dateView.stringValue = cellData.dateString
|
||||
needsLayout = true
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ private extension TimelineTableCellView {
|
|||
if feedNameView.isHidden {
|
||||
feedNameView.isHidden = false
|
||||
}
|
||||
feedNameView.stringValue = cellData.attributedFeedName.string
|
||||
feedNameView.stringValue = cellData.feedName
|
||||
}
|
||||
else {
|
||||
if !feedNameView.isHidden {
|
||||
|
|
Loading…
Reference in New Issue