Blocked by state
This commit is contained in:
parent
d1640fa1d2
commit
f5aacf7624
|
@ -21,6 +21,7 @@
|
|||
"account.statuses-and-replies" = "Posts & Replies";
|
||||
"account.media" = "Media";
|
||||
"account.show-reblogs" = "Show boosts";
|
||||
"account.unavailable" = "Profile unavailable";
|
||||
"account.unblock" = "Unblock";
|
||||
"account.unblock.confirm-%@" = "Unblock %@?";
|
||||
"account.unfollow" = "Unfollow";
|
||||
|
|
|
@ -5,3 +5,10 @@ public struct CollectionUpdate: Hashable {
|
|||
public let maintainScrollPositionItemId: String?
|
||||
public let shouldAdjustContentInset: Bool
|
||||
}
|
||||
|
||||
extension CollectionUpdate {
|
||||
static let empty: Self = Self(
|
||||
sections: [],
|
||||
maintainScrollPositionItemId: nil,
|
||||
shouldAdjustContentInset: false)
|
||||
}
|
||||
|
|
|
@ -11,10 +11,7 @@ public class CollectionItemsViewModel: ObservableObject {
|
|||
@Published public var alertItem: AlertItem?
|
||||
public private(set) var nextPageMaxId: String?
|
||||
|
||||
@Published private var lastUpdate = CollectionUpdate(
|
||||
sections: [],
|
||||
maintainScrollPositionItemId: nil,
|
||||
shouldAdjustContentInset: false)
|
||||
@Published private var lastUpdate = CollectionUpdate.empty
|
||||
private let collectionService: CollectionService
|
||||
private var viewModelCache = [CollectionItem: (viewModel: CollectionItemViewModel, events: AnyCancellable)]()
|
||||
private let eventsSubject = PassthroughSubject<CollectionItemEvent, Never>()
|
||||
|
|
|
@ -67,7 +67,18 @@ extension ProfileViewModel: CollectionViewModel {
|
|||
}
|
||||
|
||||
public var updates: AnyPublisher<CollectionUpdate, Never> {
|
||||
collectionViewModel.flatMap(\.updates).eraseToAnyPublisher()
|
||||
collectionViewModel.flatMap(\.updates)
|
||||
.combineLatest($accountViewModel.map { $0?.relationship })
|
||||
.map {
|
||||
let (updates, relationship) = $0
|
||||
|
||||
if let relationship = relationship, relationship.blockedBy {
|
||||
return .empty
|
||||
} else {
|
||||
return updates
|
||||
}
|
||||
}
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
public var title: AnyPublisher<String, Never> {
|
||||
|
|
|
@ -24,6 +24,7 @@ final class AccountHeaderView: UIView {
|
|||
let followingButton = UIButton()
|
||||
let followersButton = UIButton()
|
||||
let segmentedControl = UISegmentedControl()
|
||||
let unavailableLabel = UILabel()
|
||||
|
||||
var viewModel: ProfileViewModel? {
|
||||
didSet {
|
||||
|
@ -47,8 +48,10 @@ final class AccountHeaderView: UIView {
|
|||
unfollowButton.isHidden = !relationship.following
|
||||
|
||||
relationshipButtonsStackView.isHidden = false
|
||||
unavailableLabel.isHidden = !relationship.blockedBy
|
||||
} else {
|
||||
relationshipButtonsStackView.isHidden = true
|
||||
unavailableLabel.isHidden = true
|
||||
}
|
||||
|
||||
if accountViewModel.displayName.isEmpty {
|
||||
|
@ -319,6 +322,14 @@ private extension AccountHeaderView {
|
|||
|
||||
baseStackView.addArrangedSubview(segmentedControl)
|
||||
|
||||
baseStackView.addArrangedSubview(unavailableLabel)
|
||||
unavailableLabel.adjustsFontForContentSizeCategory = true
|
||||
unavailableLabel.font = .preferredFont(forTextStyle: .title3)
|
||||
unavailableLabel.textAlignment = .center
|
||||
unavailableLabel.numberOfLines = 0
|
||||
unavailableLabel.text = NSLocalizedString("account.unavailable", comment: "")
|
||||
unavailableLabel.isHidden = true
|
||||
|
||||
let headerImageAspectRatioConstraint = headerImageView.heightAnchor.constraint(
|
||||
equalTo: headerImageView.widthAnchor,
|
||||
multiplier: 1 / 3)
|
||||
|
|
Loading…
Reference in New Issue