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