Make unread indicator animatable

This commit is contained in:
Maurice Parker 2019-11-02 20:15:48 -05:00
parent 8fb87a7c87
commit 3f46c0e939
2 changed files with 9 additions and 26 deletions

View File

@ -47,7 +47,11 @@ class MasterTimelineTableViewCell: VibrantTableViewCell {
updateLabelVibrancy(feedNameView, animated: animated) updateLabelVibrancy(feedNameView, animated: animated)
UIView.animate(withDuration: duration(animated: animated)) { UIView.animate(withDuration: duration(animated: animated)) {
self.unreadIndicatorView.isSelected = self.isHighlighted || self.isSelected if self.isHighlighted || self.isSelected {
self.unreadIndicatorView.backgroundColor = AppAssets.vibrantTextColor
} else {
self.unreadIndicatorView.backgroundColor = AppAssets.secondaryAccentColor
}
} }
} }

View File

@ -10,31 +10,10 @@ import UIKit
class MasterUnreadIndicatorView: UIView { class MasterUnreadIndicatorView: UIView {
var isSelected = false { override func layoutSubviews() {
didSet { super.layoutSubviews()
setNeedsDisplay() layer.cornerRadius = frame.size.width / 2.0
} clipsToBounds = true
} }
override init(frame: CGRect) {
super.init(frame: frame)
self.isOpaque = false
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.isOpaque = false
}
static let bezierPath: UIBezierPath = {
let r = CGRect(x: 0.0, y: 0.0, width: MasterTimelineDefaultCellLayout.unreadCircleDimension, height: MasterTimelineDefaultCellLayout.unreadCircleDimension)
return UIBezierPath(ovalIn: r)
}()
override func draw(_ dirtyRect: CGRect) {
let color = isSelected ? AppAssets.vibrantTextColor : AppAssets.secondaryAccentColor
color.setFill()
MasterUnreadIndicatorView.bezierPath.fill()
}
} }