diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift index 2d43faa56..b86c952a4 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift @@ -12,6 +12,7 @@ import GameController import AuthenticationServices import MastodonAsset import MastodonLocalization +import MastodonUI final class MastodonPickServerViewController: UIViewController, NeedsDependency { @@ -144,6 +145,13 @@ extension MastodonPickServerViewController { pickServerServerSectionTableHeaderViewDelegate: self, pickServerCellDelegate: self ) + + KeyboardResponderService + .configure( + scrollView: tableView, + layoutNeedsUpdate: viewModel.viewDidAppear.eraseToAnyPublisher() + ) + .store(in: &disposeBag) viewModel .selectedServer @@ -238,6 +246,7 @@ extension MastodonPickServerViewController { super.viewDidAppear(animated) tableView.flashScrollIndicators() + viewModel.viewDidAppear.send() } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { @@ -416,28 +425,6 @@ extension MastodonPickServerViewController: UITableViewDelegate { viewModel.selectedServer.send(nil) } - func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { - guard let diffableDataSource = viewModel.diffableDataSource else { return } - guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return } - - switch item { -// case .categoryPicker: -// guard let cell = cell as? PickServerCategoriesCell else { return } -// guard let diffableDataSource = cell.diffableDataSource else { return } -// let snapshot = diffableDataSource.snapshot() -// -// let item = viewModel.selectCategoryItem.value -// guard let section = snapshot.indexOfSection(.main), -// let row = snapshot.indexOfItem(item) else { return } -// cell.collectionView.selectItem(at: IndexPath(item: row, section: section), animated: false, scrollPosition: .centeredHorizontally) -// case .search: -// guard let cell = cell as? PickServerSearchCell else { return } -// cell.searchTextField.text = viewModel.searchText.value - default: - break - } - } - func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { guard let diffableDataSource = viewModel.diffableDataSource else { return nil } let snapshot = diffableDataSource.snapshot() diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift index af38b110b..59008c530 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift @@ -45,7 +45,8 @@ class MastodonPickServerViewModel: NSObject { let indexedServers = CurrentValueSubject<[Mastodon.Entity.Server], Never>([]) let unindexedServers = CurrentValueSubject<[Mastodon.Entity.Server]?, Never>([]) // set nil when loading let viewWillAppear = PassthroughSubject() - + let viewDidAppear = CurrentValueSubject(Void()) + // output var diffableDataSource: UITableViewDiffableDataSource? private(set) lazy var loadIndexedServerStateMachine: GKStateMachine = {