Animate timeline star and unread indicators

This commit is contained in:
Maurice Parker
2019-10-15 20:59:42 -05:00
parent 42bccc2fea
commit 3faa9d7cde
2 changed files with 23 additions and 7 deletions

View File

@@ -187,12 +187,30 @@ private extension MasterTimelineTableViewCell {
}
func updateUnreadIndicator() {
showOrHideView(unreadIndicatorView, cellData.read || cellData.starred)
unreadIndicatorView.setNeedsDisplay()
let hide = cellData.read || cellData.starred
self.unreadIndicatorView.isHidden = hide
self.unreadIndicatorView.frame.size = !hide ? CGSize.zero : MasterTimelineDefaultCellLayout.unreadCircleSize
UIView.animate(
withDuration: 0.5,
delay: 0.0,
usingSpringWithDamping: 0.5,
initialSpringVelocity: 0.2,
animations: {
self.unreadIndicatorView.frame.size = !hide ? MasterTimelineDefaultCellLayout.unreadCircleSize : CGSize.zero
})
}
func updateStarView() {
showOrHideView(starView, !cellData.starred)
self.starView.isHidden = !self.cellData.starred
self.starView.frame.size = self.cellData.starred ? CGSize.zero : MasterTimelineDefaultCellLayout.starSize
UIView.animate(
withDuration: 0.5,
delay: 0.0,
usingSpringWithDamping: 0.5,
initialSpringVelocity: 0.2,
animations: {
self.starView.frame.size = self.cellData.starred ? MasterTimelineDefaultCellLayout.starSize : CGSize.zero
})
}
func updateAvatar() {
@@ -233,10 +251,6 @@ private extension MasterTimelineTableViewCell {
}
}
func showOrHideView(_ view: UIView, _ shouldHide: Bool) {
shouldHide ? hideView(view) : showView(view)
}
func updateSubviews() {
updateTitleView()
updateSummaryView()