Prevent timeline title animation on load

This commit is contained in:
Maurice Parker 2019-10-08 09:19:50 -05:00
parent f77b0834ab
commit d5031b0c1e
1 changed files with 16 additions and 8 deletions

View File

@ -476,7 +476,7 @@ private extension MasterTimelineViewController {
} }
titleView.label.text = coordinator.timelineName titleView.label.text = coordinator.timelineName
updateTitleUnreadCount() updateTitleUnreadCount(animate: false)
if coordinator.timelineFetcher is Feed { if coordinator.timelineFetcher is Feed {
titleView.heightAnchor.constraint(equalToConstant: 44.0).isActive = true titleView.heightAnchor.constraint(equalToConstant: 44.0).isActive = true
@ -493,23 +493,31 @@ private extension MasterTimelineViewController {
tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: false) tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: false)
} }
updateUI() updateToolbar()
} }
func updateUI() { func updateUI() {
updateTitleUnreadCount() updateTitleUnreadCount(animate: true)
updateToolbar()
}
func updateToolbar() {
markAllAsReadButton.isEnabled = coordinator.isTimelineUnreadAvailable markAllAsReadButton.isEnabled = coordinator.isTimelineUnreadAvailable
firstUnreadButton.isEnabled = coordinator.isTimelineUnreadAvailable firstUnreadButton.isEnabled = coordinator.isTimelineUnreadAvailable
} }
func updateTitleUnreadCount() { func updateTitleUnreadCount(animate: Bool) {
if let unreadCountProvider = coordinator.timelineFetcher as? UnreadCountProvider { if let unreadCountProvider = coordinator.timelineFetcher as? UnreadCountProvider {
if animate {
UIView.animate(withDuration: 0.3) { UIView.animate(withDuration: 0.3) {
self.titleView?.unreadCountView.unreadCount = unreadCountProvider.unreadCount self.titleView?.unreadCountView.unreadCount = unreadCountProvider.unreadCount
self.titleView?.setNeedsLayout() self.titleView?.setNeedsLayout()
self.titleView?.layoutIfNeeded() self.titleView?.layoutIfNeeded()
} }
} else {
self.titleView?.unreadCountView.unreadCount = unreadCountProvider.unreadCount
}
} }
} }