Make unread indicator animatable
This commit is contained in:
parent
8fb87a7c87
commit
3f46c0e939
|
@ -47,7 +47,11 @@ class MasterTimelineTableViewCell: VibrantTableViewCell {
|
|||
updateLabelVibrancy(feedNameView, 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,31 +10,10 @@ import UIKit
|
|||
|
||||
class MasterUnreadIndicatorView: UIView {
|
||||
|
||||
var isSelected = false {
|
||||
didSet {
|
||||
setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
layer.cornerRadius = frame.size.width / 2.0
|
||||
clipsToBounds = true
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue