2022-05-17 16:09:43 +02:00
|
|
|
//
|
|
|
|
// RebloggedByViewController.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK on 2022-5-17.
|
|
|
|
//
|
|
|
|
|
|
|
|
import os.log
|
|
|
|
import UIKit
|
|
|
|
import GameplayKit
|
|
|
|
import Combine
|
2022-10-08 07:43:06 +02:00
|
|
|
import MastodonCore
|
2022-05-17 16:09:43 +02:00
|
|
|
import MastodonLocalization
|
|
|
|
|
|
|
|
final class RebloggedByViewController: UIViewController, NeedsDependency {
|
|
|
|
|
|
|
|
let logger = Logger(subsystem: "RebloggedByViewController", category: "ViewController")
|
|
|
|
|
|
|
|
weak var context: AppContext! { willSet { precondition(!isViewLoaded) } }
|
|
|
|
weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } }
|
|
|
|
|
|
|
|
var disposeBag = Set<AnyCancellable>()
|
|
|
|
var viewModel: UserListViewModel!
|
|
|
|
|
|
|
|
lazy var tableView: UITableView = {
|
|
|
|
let tableView = UITableView()
|
|
|
|
tableView.rowHeight = UITableView.automaticDimension
|
|
|
|
tableView.separatorStyle = .none
|
|
|
|
tableView.backgroundColor = .clear
|
|
|
|
return tableView
|
|
|
|
}()
|
|
|
|
|
|
|
|
deinit {
|
|
|
|
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extension RebloggedByViewController {
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
switch viewModel.kind {
|
|
|
|
case .rebloggedBy: break
|
|
|
|
default: assertionFailure()
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-05-17 17:27:58 +02:00
|
|
|
title = L10n.Scene.RebloggedBy.title
|
2022-05-17 16:09:43 +02:00
|
|
|
|
|
|
|
view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
|
|
|
|
ThemeService.shared.currentTheme
|
|
|
|
.receive(on: DispatchQueue.main)
|
|
|
|
.sink { [weak self] theme in
|
|
|
|
guard let self = self else { return }
|
|
|
|
self.view.backgroundColor = theme.secondarySystemBackgroundColor
|
|
|
|
}
|
|
|
|
.store(in: &disposeBag)
|
|
|
|
|
|
|
|
tableView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
view.addSubview(tableView)
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
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.delegate = self
|
|
|
|
viewModel.setupDiffableDataSource(
|
|
|
|
tableView: tableView,
|
|
|
|
userTableViewCellDelegate: self
|
|
|
|
)
|
|
|
|
|
|
|
|
// setup batch fetch
|
|
|
|
viewModel.listBatchFetchViewModel.setup(scrollView: tableView)
|
|
|
|
viewModel.listBatchFetchViewModel.shouldFetch
|
|
|
|
.receive(on: DispatchQueue.main)
|
|
|
|
.sink { [weak self] _ in
|
|
|
|
guard let self = self else { return }
|
|
|
|
self.viewModel.stateMachine.enter(UserListViewModel.State.Loading.self)
|
|
|
|
}
|
|
|
|
.store(in: &disposeBag)
|
|
|
|
}
|
|
|
|
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
|
|
super.viewWillAppear(animated)
|
|
|
|
|
|
|
|
tableView.deselectRow(with: transitionCoordinator, animated: animated)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-10-09 14:07:57 +02:00
|
|
|
// MARK: - AuthContextProvider
|
|
|
|
extension RebloggedByViewController: AuthContextProvider {
|
|
|
|
var authContext: AuthContext { viewModel.authContext }
|
|
|
|
}
|
|
|
|
|
2022-05-17 16:09:43 +02:00
|
|
|
// MARK: - UITableViewDelegate
|
|
|
|
extension RebloggedByViewController: UITableViewDelegate, AutoGenerateTableViewDelegate {
|
|
|
|
// sourcery:inline:RebloggedByViewController.AutoGenerateTableViewDelegate
|
|
|
|
|
|
|
|
// Generated using Sourcery
|
|
|
|
// DO NOT EDIT
|
|
|
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
|
|
aspectTableView(tableView, didSelectRowAt: indexPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
// sourcery:end
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - UserTableViewCellDelegate
|
|
|
|
extension RebloggedByViewController: UserTableViewCellDelegate { }
|