mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-25 09:41:00 +00:00
Adjust loading footer display interval behavior
This commit is contained in:
parent
699fff540e
commit
c6d644feaf
1 changed files with 7 additions and 5 deletions
|
@ -251,7 +251,7 @@ extension TableViewController: ZoomAnimatorDelegate {
|
||||||
|
|
||||||
private extension TableViewController {
|
private extension TableViewController {
|
||||||
static let bottomInset: CGFloat = .newStatusButtonDimension + .defaultSpacing * 4
|
static let bottomInset: CGFloat = .newStatusButtonDimension + .defaultSpacing * 4
|
||||||
static let loadingFooterDebounceInterval: TimeInterval = 0.5
|
static let loadingFooterDebounceInterval: TimeInterval = 0.75
|
||||||
|
|
||||||
var bottomInset: CGFloat { insetBottom ? Self.bottomInset : 0 }
|
var bottomInset: CGFloat { insetBottom ? Self.bottomInset : 0 }
|
||||||
|
|
||||||
|
@ -279,19 +279,21 @@ private extension TableViewController {
|
||||||
|
|
||||||
viewModel.loading.receive(on: DispatchQueue.main).assign(to: &$loading)
|
viewModel.loading.receive(on: DispatchQueue.main).assign(to: &$loading)
|
||||||
|
|
||||||
|
$loading.combineLatest(
|
||||||
$loading.debounce(
|
$loading.debounce(
|
||||||
for: .seconds(Self.loadingFooterDebounceInterval),
|
for: .seconds(Self.loadingFooterDebounceInterval),
|
||||||
scheduler: DispatchQueue.main)
|
scheduler: DispatchQueue.main))
|
||||||
.sink { [weak self] in
|
.sink { [weak self] loading, debouncedLoading in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
|
||||||
let refreshControlVisibile = self.refreshControl?.isRefreshing ?? false
|
let refreshControlVisibile = self.refreshControl?.isRefreshing ?? false
|
||||||
|
|
||||||
if !$0, refreshControlVisibile {
|
if !loading, refreshControlVisibile {
|
||||||
self.refreshControl?.endRefreshing()
|
self.refreshControl?.endRefreshing()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.tableView.tableFooterView = $0 && !refreshControlVisibile ? self.loadingTableFooterView : UIView()
|
self.tableView.tableFooterView =
|
||||||
|
loading && debouncedLoading && !refreshControlVisibile ? self.loadingTableFooterView : UIView()
|
||||||
self.sizeTableHeaderFooterViews()
|
self.sizeTableHeaderFooterViews()
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
Loading…
Reference in a new issue