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