Use the new TimelineAvatarView instead of an NSImageView in TimelineTableCellView.
This commit is contained in:
parent
506b621e5d
commit
a225d52ba3
|
@ -18,13 +18,7 @@ class TimelineTableCellView: NSTableCellView {
|
||||||
private let dateView = TimelineTableCellView.singleLineTextField()
|
private let dateView = TimelineTableCellView.singleLineTextField()
|
||||||
private let feedNameView = TimelineTableCellView.singleLineTextField()
|
private let feedNameView = TimelineTableCellView.singleLineTextField()
|
||||||
|
|
||||||
private lazy var avatarImageView: NSImageView = {
|
private lazy var avatarView = TimelineAvatarView()
|
||||||
let imageView = TimelineTableCellView.imageView(with: AppAssets.genericFeedImage, scaling: .scaleNone)
|
|
||||||
imageView.imageAlignment = .alignTop
|
|
||||||
imageView.imageScaling = .scaleProportionallyDown
|
|
||||||
imageView.wantsLayer = true
|
|
||||||
return imageView
|
|
||||||
}()
|
|
||||||
|
|
||||||
private let starView = TimelineTableCellView.imageView(with: AppAssets.timelineStar, scaling: .scaleNone)
|
private let starView = TimelineTableCellView.imageView(with: AppAssets.timelineStar, scaling: .scaleNone)
|
||||||
private let separatorView = TimelineTableCellView.separatorView()
|
private let separatorView = TimelineTableCellView.separatorView()
|
||||||
|
@ -43,7 +37,7 @@ class TimelineTableCellView: NSTableCellView {
|
||||||
didSet {
|
didSet {
|
||||||
if cellAppearance != oldValue {
|
if cellAppearance != oldValue {
|
||||||
updateTextFieldFonts()
|
updateTextFieldFonts()
|
||||||
avatarImageView.layer?.cornerRadius = cellAppearance.avatarCornerRadius
|
avatarView.layer?.cornerRadius = cellAppearance.avatarCornerRadius
|
||||||
needsLayout = true
|
needsLayout = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +119,7 @@ class TimelineTableCellView: NSTableCellView {
|
||||||
dateView.rs_setFrameIfNotEqual(layoutRects.dateRect)
|
dateView.rs_setFrameIfNotEqual(layoutRects.dateRect)
|
||||||
unreadIndicatorView.rs_setFrameIfNotEqual(layoutRects.unreadIndicatorRect)
|
unreadIndicatorView.rs_setFrameIfNotEqual(layoutRects.unreadIndicatorRect)
|
||||||
feedNameView.rs_setFrameIfNotEqual(layoutRects.feedNameRect)
|
feedNameView.rs_setFrameIfNotEqual(layoutRects.feedNameRect)
|
||||||
avatarImageView.rs_setFrameIfNotEqual(layoutRects.avatarImageRect)
|
avatarView.rs_setFrameIfNotEqual(layoutRects.avatarImageRect)
|
||||||
starView.rs_setFrameIfNotEqual(layoutRects.starRect)
|
starView.rs_setFrameIfNotEqual(layoutRects.starRect)
|
||||||
separatorView.rs_setFrameIfNotEqual(layoutRects.separatorRect)
|
separatorView.rs_setFrameIfNotEqual(layoutRects.separatorRect)
|
||||||
}
|
}
|
||||||
|
@ -213,7 +207,7 @@ private extension TimelineTableCellView {
|
||||||
addSubviewAtInit(unreadIndicatorView, hidden: true)
|
addSubviewAtInit(unreadIndicatorView, hidden: true)
|
||||||
addSubviewAtInit(dateView, hidden: false)
|
addSubviewAtInit(dateView, hidden: false)
|
||||||
addSubviewAtInit(feedNameView, hidden: true)
|
addSubviewAtInit(feedNameView, hidden: true)
|
||||||
addSubviewAtInit(avatarImageView, hidden: true)
|
addSubviewAtInit(avatarView, hidden: true)
|
||||||
addSubviewAtInit(starView, hidden: true)
|
addSubviewAtInit(starView, hidden: true)
|
||||||
addSubviewAtInit(separatorView, hidden: !AppDefaults.timelineShowsSeparators)
|
addSubviewAtInit(separatorView, hidden: !AppDefaults.timelineShowsSeparators)
|
||||||
|
|
||||||
|
@ -222,7 +216,7 @@ private extension TimelineTableCellView {
|
||||||
|
|
||||||
func updatedLayoutRects() -> TimelineCellLayout {
|
func updatedLayoutRects() -> TimelineCellLayout {
|
||||||
|
|
||||||
return TimelineCellLayout(width: bounds.width, height: bounds.height, cellData: cellData, appearance: cellAppearance, hasAvatar: avatarImageView.image != nil)
|
return TimelineCellLayout(width: bounds.width, height: bounds.height, cellData: cellData, appearance: cellAppearance, hasAvatar: avatarView.image != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateTitleView() {
|
func updateTitleView() {
|
||||||
|
@ -277,19 +271,19 @@ private extension TimelineTableCellView {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
showView(avatarImageView)
|
showView(avatarView)
|
||||||
if avatarImageView.image !== image {
|
if avatarView.image !== image {
|
||||||
avatarImageView.image = image
|
avatarView.image = image
|
||||||
needsLayout = true
|
needsLayout = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeAvatarEmpty() {
|
func makeAvatarEmpty() {
|
||||||
if avatarImageView.image != nil {
|
if avatarView.image != nil {
|
||||||
avatarImageView.image = nil
|
avatarView.image = nil
|
||||||
needsLayout = true
|
needsLayout = true
|
||||||
}
|
}
|
||||||
hideView(avatarImageView)
|
hideView(avatarView)
|
||||||
}
|
}
|
||||||
|
|
||||||
func hideView(_ view: NSView) {
|
func hideView(_ view: NSView) {
|
||||||
|
|
Loading…
Reference in New Issue