2021-04-02 10:24:00 +02:00
|
|
|
//
|
|
|
|
// SearchViewController+Searching.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by sxiaojian on 2021/4/2.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
2021-04-06 09:25:04 +02:00
|
|
|
import MastodonSDK
|
2021-04-02 10:24:00 +02:00
|
|
|
import UIKit
|
|
|
|
|
|
|
|
extension SearchViewController {
|
|
|
|
func setupSearchingTableView() {
|
|
|
|
searchingTableView.delegate = self
|
|
|
|
searchingTableView.register(SearchingTableViewCell.self, forCellReuseIdentifier: String(describing: SearchingTableViewCell.self))
|
2021-04-06 09:25:04 +02:00
|
|
|
searchingTableView.register(SearchBottomLoader.self, forCellReuseIdentifier: String(describing: SearchBottomLoader.self))
|
2021-04-02 10:24:00 +02:00
|
|
|
view.addSubview(searchingTableView)
|
|
|
|
searchingTableView.constrain([
|
|
|
|
searchingTableView.frameLayoutGuide.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
|
|
|
|
searchingTableView.frameLayoutGuide.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
|
|
|
|
searchingTableView.frameLayoutGuide.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
|
|
|
|
searchingTableView.frameLayoutGuide.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
|
|
|
|
searchingTableView.contentLayoutGuide.widthAnchor.constraint(equalTo: view.widthAnchor),
|
|
|
|
])
|
2021-04-06 09:25:04 +02:00
|
|
|
searchingTableView.tableFooterView = UIView()
|
2021-04-02 10:24:00 +02:00
|
|
|
viewModel.isSearching
|
|
|
|
.receive(on: DispatchQueue.main)
|
2021-04-06 09:25:04 +02:00
|
|
|
.sink { [weak self] isSearching in
|
2021-04-02 10:24:00 +02:00
|
|
|
self?.searchingTableView.isHidden = !isSearching
|
|
|
|
}
|
|
|
|
.store(in: &disposeBag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - UITableViewDelegate
|
|
|
|
|
|
|
|
extension SearchViewController: UITableViewDelegate {
|
|
|
|
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
|
|
66
|
|
|
|
}
|
2021-04-06 09:25:04 +02:00
|
|
|
|
2021-04-02 10:24:00 +02:00
|
|
|
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
|
|
66
|
|
|
|
}
|
2021-04-06 09:25:04 +02:00
|
|
|
|
2021-04-02 10:24:00 +02:00
|
|
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {}
|
|
|
|
}
|