fix: category initial selection missing issue

This commit is contained in:
CMK 2022-01-04 18:44:42 +08:00
parent d36e60e2a4
commit c9417a2e17
2 changed files with 5 additions and 2 deletions

View File

@ -110,7 +110,6 @@ extension MastodonPickServerViewController {
.observe(\.bounds, options: [.initial, .new]) { [weak self] navigationActionView, _ in .observe(\.bounds, options: [.initial, .new]) { [weak self] navigationActionView, _ in
guard let self = self else { return } guard let self = self else { return }
let inset = navigationActionView.frame.height let inset = navigationActionView.frame.height
print("*** \(inset) ***")
self.tableView.contentInset.bottom = inset self.tableView.contentInset.bottom = inset
} }
.store(in: &observations) .store(in: &observations)

View File

@ -25,7 +25,11 @@ extension MastodonPickServerViewModel {
sectionHeaderSnapshot.appendSections([.main]) sectionHeaderSnapshot.appendSections([.main])
sectionHeaderSnapshot.appendItems(categoryPickerItems, toSection: .main) sectionHeaderSnapshot.appendItems(categoryPickerItems, toSection: .main)
serverSectionHeaderView.delegate = pickServerServerSectionTableHeaderViewDelegate serverSectionHeaderView.delegate = pickServerServerSectionTableHeaderViewDelegate
serverSectionHeaderView.diffableDataSource?.applySnapshot(sectionHeaderSnapshot, animated: false) serverSectionHeaderView.diffableDataSource?.applySnapshot(sectionHeaderSnapshot, animated: false) { [weak self] in
guard let self = self else { return }
guard let indexPath = self.serverSectionHeaderView.diffableDataSource?.indexPath(for: .all) else { return }
self.serverSectionHeaderView.collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredHorizontally)
}
// set tableView // set tableView
diffableDataSource = PickServerSection.tableViewDiffableDataSource( diffableDataSource = PickServerSection.tableViewDiffableDataSource(