feat: make content inset take effect for page navigation

This commit is contained in:
CMK 2021-07-14 20:40:27 +08:00
parent e006ea92c0
commit d8af11a9bc
2 changed files with 9 additions and 4 deletions

View File

@ -64,11 +64,12 @@ extension SearchResultViewController {
KeyboardResponderService.shared.state, KeyboardResponderService.shared.state,
KeyboardResponderService.shared.endFrame KeyboardResponderService.shared.endFrame
) )
Publishers.CombineLatest( Publishers.CombineLatest3(
keyboardEventPublishers, keyboardEventPublishers,
viewModel.viewDidAppear viewModel.viewDidAppear,
viewModel.didDataSourceUpdate
) )
.sink(receiveValue: { [weak self] keyboardEvents, _ in .sink(receiveValue: { [weak self] keyboardEvents, _, _ in
guard let self = self else { return } guard let self = self else { return }
let (isShow, state, endFrame) = keyboardEvents let (isShow, state, endFrame) = keyboardEvents

View File

@ -36,6 +36,7 @@ final class SearchResultViewModel {
}() }()
let items = CurrentValueSubject<[SearchResultItem], Never>([]) let items = CurrentValueSubject<[SearchResultItem], Never>([])
var diffableDataSource: UITableViewDiffableDataSource<SearchResultSection, SearchResultItem>! var diffableDataSource: UITableViewDiffableDataSource<SearchResultSection, SearchResultItem>!
let didDataSourceUpdate = PassthroughSubject<Void, Never>()
init(context: AppContext, searchScope: SearchDetailViewModel.SearchScope) { init(context: AppContext, searchScope: SearchDetailViewModel.SearchScope) {
self.context = context self.context = context
@ -93,7 +94,10 @@ final class SearchResultViewModel {
} }
diffableDataSource.defaultRowAnimation = .fade diffableDataSource.defaultRowAnimation = .fade
diffableDataSource.apply(snapshot, animatingDifferences: true) diffableDataSource.apply(snapshot, animatingDifferences: true) { [weak self] in
guard let self = self else { return }
self.didDataSourceUpdate.send()
}
} }
.store(in: &disposeBag) .store(in: &disposeBag)