fix: pick server table margin not works issue

This commit is contained in:
CMK 2022-05-11 19:22:22 +08:00
parent 35d572660b
commit 66d23432c1
2 changed files with 8 additions and 6 deletions

View File

@ -92,7 +92,7 @@ extension MastodonPickServerViewController {
tableView.topAnchor.constraint(equalTo: view.topAnchor),
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
tableView.bottomAnchor.constraint(equalTo: view.layoutMarginsGuide.bottomAnchor),
])
navigationActionView.translatesAutoresizingMaskIntoConstraints = false
@ -107,10 +107,10 @@ extension MastodonPickServerViewController {
])
navigationActionView
.observe(\.bounds, options: [.initial, .new]) { [weak self] navigationActionView, _ in
.observe(\.bounds, options: [.initial, .new]) { [weak self] _, _ in
guard let self = self else { return }
let inset = navigationActionView.frame.height
self.tableView.contentInset.bottom = inset
let inset = self.navigationActionView.frame.height
self.viewModel.additionalTableViewInsets.bottom = inset
}
.store(in: &observations)
@ -149,7 +149,8 @@ extension MastodonPickServerViewController {
KeyboardResponderService
.configure(
scrollView: tableView,
layoutNeedsUpdate: viewModel.viewDidAppear.eraseToAnyPublisher()
layoutNeedsUpdate: viewModel.viewDidAppear.eraseToAnyPublisher(),
additionalSafeAreaInsets: viewModel.$additionalTableViewInsets.eraseToAnyPublisher()
)
.store(in: &disposeBag)

View File

@ -46,7 +46,8 @@ class MastodonPickServerViewModel: NSObject {
let unindexedServers = CurrentValueSubject<[Mastodon.Entity.Server]?, Never>([]) // set nil when loading
let viewWillAppear = PassthroughSubject<Void, Never>()
let viewDidAppear = CurrentValueSubject<Void, Never>(Void())
@Published var additionalTableViewInsets: UIEdgeInsets = .zero
// output
var diffableDataSource: UITableViewDiffableDataSource<PickServerSection, PickServerItem>?
private(set) lazy var loadIndexedServerStateMachine: GKStateMachine = {