diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineNavigationBarState.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineNavigationBarState.swift index 6650d323b..3ae74a264 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineNavigationBarState.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineNavigationBarState.swift @@ -9,7 +9,6 @@ import Combine import Foundation import UIKit - final class HomeTimelineNavigationBarState { static let errorCountMax: Int = 3 var disposeBag = Set() @@ -46,7 +45,7 @@ extension HomeTimelineNavigationBarState { func showPublishingNewPostInNavigationBar() { let progressView = HomeTimelineNavigationBarView.progressView - if let navigationBar = viewController?.navigationBar(), progressView.superview == nil { + if let navigationBar = viewController?.navigationBar(), progressView.superview == nil { navigationBar.addSubview(progressView) NSLayoutConstraint.activate([ progressView.bottomAnchor.constraint(equalTo: navigationBar.bottomAnchor), @@ -65,7 +64,7 @@ extension HomeTimelineNavigationBarState { times += 1 return Double(times) } - .scan(0) { value,count in + .scan(0) { value, count in value + 1 / pow(Double(2), count) } .receive(on: DispatchQueue.main) @@ -149,7 +148,7 @@ extension HomeTimelineNavigationBarState { if newContent { self.showNewPostsInNavigationBar() } - if (newContent) { + if newContent { self.newTopContent.value = false } } @@ -173,7 +172,10 @@ extension HomeTimelineNavigationBarState { networkErrorCountSubject.send(false) case .finished: reCountdown() - showPublishingNewPostInNavigationBar() + let isShowingOfflineView = viewController?.navigationItem.titleView === HomeTimelineNavigationBarView.offlineView + if isShowingOfflineView { + showMastodonLogoInNavigationBar() + } } } } diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineNavigationBarView.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineNavigationBarView.swift index 1669f0124..d371ffe59 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineNavigationBarView.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineNavigationBarView.swift @@ -8,7 +8,6 @@ import UIKit final class HomeTimelineNavigationBarView { - static let mastodonLogoTitleView: UIImageView = { let imageView = UIImageView(image: Asset.Asset.mastodonTextLogo.image.withRenderingMode(.alwaysTemplate)) imageView.tintColor = Asset.Colors.Label.primary.color @@ -50,7 +49,7 @@ final class HomeTimelineNavigationBarView { return label }() - static func addLabelToView(label: UILabel,view:UIView) { + static func addLabelToView(label: UILabel, view: UIView) { view.addSubview(label) NSLayoutConstraint.activate([ label.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16), @@ -60,11 +59,11 @@ final class HomeTimelineNavigationBarView { ]) label.sizeToFit() view.layoutIfNeeded() - view.layer.cornerRadius = view.frame.height/2 + view.layer.cornerRadius = view.frame.height / 2 view.clipsToBounds = true } - static func backgroundViewWithColor(color:UIColor) -> UIView { + static func backgroundViewWithColor(color: UIColor) -> UIView { let view = UIView() view.backgroundColor = color view.translatesAutoresizingMaskIntoConstraints = false @@ -80,4 +79,3 @@ final class HomeTimelineNavigationBarView { return label } } - diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadOldestState.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadOldestState.swift index 84bde2e4a..b18a66c01 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadOldestState.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadOldestState.swift @@ -71,10 +71,8 @@ extension HomeTimelineViewModel.LoadOldestState { // enter no more state when no new toots if toots.isEmpty || (toots.count == 1 && toots[0].id == maxID) { stateMachine.enter(NoMore.self) - viewModel.homeTimelineNavigationBarState.newBottomContent.value = false } else { stateMachine.enter(Idle.self) - viewModel.homeTimelineNavigationBarState.newBottomContent.value = true } } .store(in: &viewModel.disposeBag)