Make unread and star animations cancel on cell reuse. Issue #2054
This commit is contained in:
parent
b3c0fac5d3
commit
d453a94330
@ -23,6 +23,9 @@ class MasterTimelineTableViewCell: VibrantTableViewCell {
|
|||||||
return NonIntrinsicImageView(image: AppAssets.timelineStarImage)
|
return NonIntrinsicImageView(image: AppAssets.timelineStarImage)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
private var unreadIndicatorPropertyAnimator: UIViewPropertyAnimator?
|
||||||
|
private var starViewPropertyAnimator: UIViewPropertyAnimator?
|
||||||
|
|
||||||
var cellData: MasterTimelineCellData! {
|
var cellData: MasterTimelineCellData! {
|
||||||
didSet {
|
didSet {
|
||||||
updateSubviews()
|
updateSubviews()
|
||||||
@ -35,7 +38,12 @@ class MasterTimelineTableViewCell: VibrantTableViewCell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func prepareForReuse() {
|
override func prepareForReuse() {
|
||||||
|
unreadIndicatorPropertyAnimator?.stopAnimation(true)
|
||||||
|
unreadIndicatorPropertyAnimator = nil
|
||||||
unreadIndicatorView.isHidden = true
|
unreadIndicatorView.isHidden = true
|
||||||
|
|
||||||
|
starViewPropertyAnimator?.stopAnimation(true)
|
||||||
|
starViewPropertyAnimator = nil
|
||||||
starView.isHidden = true
|
starView.isHidden = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,10 +192,15 @@ private extension MasterTimelineTableViewCell {
|
|||||||
|
|
||||||
func updateUnreadIndicator() {
|
func updateUnreadIndicator() {
|
||||||
if !unreadIndicatorView.isHidden && cellData.read && !cellData.starred {
|
if !unreadIndicatorView.isHidden && cellData.read && !cellData.starred {
|
||||||
UIView.animate(withDuration: 0.66, animations: { self.unreadIndicatorView.alpha = 0 }) { _ in
|
unreadIndicatorPropertyAnimator = UIViewPropertyAnimator(duration: 0.66, curve: .easeInOut) { [weak self] in
|
||||||
self.unreadIndicatorView.isHidden = true
|
self?.unreadIndicatorView.alpha = 0
|
||||||
self.unreadIndicatorView.alpha = 1
|
|
||||||
}
|
}
|
||||||
|
unreadIndicatorPropertyAnimator?.addCompletion { [weak self] _ in
|
||||||
|
self?.unreadIndicatorView.isHidden = true
|
||||||
|
self?.unreadIndicatorView.alpha = 1
|
||||||
|
self?.unreadIndicatorPropertyAnimator = nil
|
||||||
|
}
|
||||||
|
unreadIndicatorPropertyAnimator?.startAnimation()
|
||||||
} else {
|
} else {
|
||||||
showOrHideView(unreadIndicatorView, cellData.read || cellData.starred)
|
showOrHideView(unreadIndicatorView, cellData.read || cellData.starred)
|
||||||
}
|
}
|
||||||
@ -195,10 +208,15 @@ private extension MasterTimelineTableViewCell {
|
|||||||
|
|
||||||
func updateStarView() {
|
func updateStarView() {
|
||||||
if !starView.isHidden && cellData.read && !cellData.starred {
|
if !starView.isHidden && cellData.read && !cellData.starred {
|
||||||
UIView.animate(withDuration: 0.66, animations: { self.starView.alpha = 0 }) { _ in
|
starViewPropertyAnimator = UIViewPropertyAnimator(duration: 0.66, curve: .easeInOut) { [weak self] in
|
||||||
self.starView.isHidden = true
|
self?.starView.alpha = 0
|
||||||
self.starView.alpha = 1
|
|
||||||
}
|
}
|
||||||
|
starViewPropertyAnimator?.addCompletion { [weak self] _ in
|
||||||
|
self?.starView.isHidden = true
|
||||||
|
self?.starView.alpha = 1
|
||||||
|
self?.starViewPropertyAnimator = nil
|
||||||
|
}
|
||||||
|
starViewPropertyAnimator?.startAnimation()
|
||||||
} else {
|
} else {
|
||||||
showOrHideView(starView, !cellData.starred)
|
showOrHideView(starView, !cellData.starred)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user