Don't show follow-button for me (IOS-141)
This commit is contained in:
parent
11863b9458
commit
b74f17c6b6
|
@ -5,17 +5,8 @@ import MastodonCore
|
|||
import MastodonSDK
|
||||
import MastodonLocalization
|
||||
|
||||
protocol SearchResultsOverviewTableViewControllerDeleagte: AnyObject {
|
||||
func showPeople(_ viewController: UIViewController)
|
||||
func showProfile(_ viewController: UIViewController)
|
||||
func openLink(_ viewController: UIViewController)
|
||||
}
|
||||
|
||||
// we could move lots of this stuff to a coordinator, it's too much for work a viewcontroller
|
||||
class SearchResultsOverviewTableViewController: UIViewController, NeedsDependency, AuthContextProvider {
|
||||
// similar to the other search results view controller but without the whole statemachine bullshit
|
||||
// with scope all
|
||||
|
||||
var context: AppContext!
|
||||
let authContext: AuthContext
|
||||
var coordinator: SceneCoordinator!
|
||||
|
@ -23,7 +14,6 @@ class SearchResultsOverviewTableViewController: UIViewController, NeedsDependenc
|
|||
private let tableView: UITableView
|
||||
var dataSource: UITableViewDiffableDataSource<SearchResultOverviewSection, SearchResultOverviewItem>?
|
||||
|
||||
weak var delegate: SearchResultsOverviewTableViewControllerDeleagte?
|
||||
var activeTask: Task<Void, Never>?
|
||||
|
||||
init(appContext: AppContext, authContext: AuthContext, coordinator: SceneCoordinator) {
|
||||
|
@ -330,7 +320,6 @@ class SearchResultsOverviewTableViewController: UIViewController, NeedsDependenc
|
|||
extension SearchResultsOverviewTableViewController: UITableViewDelegate {
|
||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
|
||||
//TODO: Implement properly!
|
||||
guard let snapshot = dataSource?.snapshot() else { return }
|
||||
let section = snapshot.sectionIdentifiers[indexPath.section]
|
||||
let item = snapshot.itemIdentifiers(inSection: section)[indexPath.row]
|
||||
|
|
|
@ -115,8 +115,6 @@ final class SearchDetailViewController: UIViewController, NeedsDependency {
|
|||
searchHistoryViewController.view.pinToParent()
|
||||
}
|
||||
|
||||
searchResultsOverviewViewController.delegate = self
|
||||
|
||||
addChild(searchResultsOverviewViewController)
|
||||
searchResultsOverviewViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(searchResultsOverviewViewController.view)
|
||||
|
@ -261,18 +259,3 @@ extension SearchDetailViewController: UISearchBarDelegate {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: SearchResultsOverviewViewControllerDelegate
|
||||
extension SearchDetailViewController: SearchResultsOverviewTableViewControllerDeleagte {
|
||||
func showPeople(_ viewController: UIViewController) {
|
||||
//TODO: Implement
|
||||
}
|
||||
|
||||
func showProfile(_ viewController: UIViewController) {
|
||||
//TODO: Implement
|
||||
}
|
||||
|
||||
func openLink(_ viewController: UIViewController) {
|
||||
//TODO: Implement
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,9 @@ extension SearchHistoryUserCollectionViewCell {
|
|||
)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] followed, requested, blocked in
|
||||
if blocked.contains(user.id) {
|
||||
if user == me {
|
||||
self?.userView.setButtonState(.none)
|
||||
} else if blocked.contains(user.id) {
|
||||
self?.userView.setButtonState(.blocked)
|
||||
} else if followed.contains(user.id) {
|
||||
self?.userView.setButtonState(.unfollow)
|
||||
|
@ -67,6 +69,5 @@ extension SearchHistoryUserCollectionViewCell {
|
|||
}
|
||||
}
|
||||
.store(in: &_disposeBag)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,9 @@ extension UserTableViewCell {
|
|||
)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] followed, requested, blocked in
|
||||
if blocked.contains(viewModel.user.id) {
|
||||
if viewModel.user == me {
|
||||
self?.userView.setButtonState(.none)
|
||||
} else if blocked.contains(viewModel.user.id) {
|
||||
self?.userView.setButtonState(.blocked)
|
||||
} else if followed.contains(viewModel.user.id) {
|
||||
self?.userView.setButtonState(.unfollow)
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
//
|
||||
|
||||
import CoreDataStack
|
||||
import os.log
|
||||
import UIKit
|
||||
import Combine
|
||||
import MetaTextKit
|
||||
|
@ -19,9 +18,7 @@ extension UserView {
|
|||
public final class ViewModel: ObservableObject {
|
||||
public var disposeBag = Set<AnyCancellable>()
|
||||
public var observations = Set<NSKeyValueObservation>()
|
||||
|
||||
let logger = Logger(subsystem: "StatusView", category: "ViewModel")
|
||||
|
||||
|
||||
@Published public var authorAvatarImage: UIImage?
|
||||
@Published public var authorAvatarImageURL: URL?
|
||||
@Published public var authorName: MetaContent?
|
||||
|
|
|
@ -261,41 +261,48 @@ public extension UserView {
|
|||
switch state {
|
||||
|
||||
case .loading:
|
||||
followButtonWrapper.isHidden = false
|
||||
followButton.isHidden = false
|
||||
followButton.setTitle(nil, for: .normal)
|
||||
followButton.setBackgroundColor(Asset.Colors.Button.disabled.color, for: .normal)
|
||||
|
||||
case .follow:
|
||||
followButtonWrapper.isHidden = false
|
||||
followButton.isHidden = false
|
||||
followButton.setTitle(L10n.Common.Controls.Friendship.follow, for: .normal)
|
||||
followButton.setBackgroundColor(Asset.Colors.Button.userFollow.color, for: .normal)
|
||||
followButton.setTitleColor(.white, for: .normal)
|
||||
|
||||
case .request:
|
||||
followButtonWrapper.isHidden = false
|
||||
followButton.isHidden = false
|
||||
followButton.setTitle(L10n.Common.Controls.Friendship.request, for: .normal)
|
||||
followButton.setBackgroundColor(Asset.Colors.Button.userFollow.color, for: .normal)
|
||||
followButton.setTitleColor(.white, for: .normal)
|
||||
|
||||
case .pending:
|
||||
followButtonWrapper.isHidden = false
|
||||
followButton.isHidden = false
|
||||
followButton.setTitle(L10n.Common.Controls.Friendship.pending, for: .normal)
|
||||
followButton.setTitleColor(Asset.Colors.Button.userFollowingTitle.color, for: .normal)
|
||||
followButton.setBackgroundColor(Asset.Colors.Button.userFollowing.color, for: .normal)
|
||||
|
||||
case .unfollow:
|
||||
followButtonWrapper.isHidden = false
|
||||
followButton.isHidden = false
|
||||
followButton.setTitle(L10n.Common.Controls.Friendship.following, for: .normal)
|
||||
followButton.setBackgroundColor(Asset.Colors.Button.userFollowing.color, for: .normal)
|
||||
followButton.setTitleColor(Asset.Colors.Button.userFollowingTitle.color, for: .normal)
|
||||
|
||||
case .blocked:
|
||||
followButtonWrapper.isHidden = false
|
||||
followButton.isHidden = false
|
||||
followButton.setTitle(L10n.Common.Controls.Friendship.blocked, for: .normal)
|
||||
followButton.setBackgroundColor(Asset.Colors.Button.userBlocked.color, for: .normal)
|
||||
followButton.setTitleColor(.systemRed, for: .normal)
|
||||
|
||||
case .none:
|
||||
followButtonWrapper.isHidden = true
|
||||
followButton.isHidden = true
|
||||
followButton.setTitle(nil, for: .normal)
|
||||
followButton.setBackgroundColor(.clear, for: .normal)
|
||||
|
|
Loading…
Reference in New Issue