Improve UserView button behavior (IOS-140)

This commit is contained in:
Marcus Kida 2023-05-08 17:24:41 +02:00
parent 096b1200b0
commit 9d2e8eca16
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
2 changed files with 6 additions and 3 deletions

View File

@ -56,14 +56,13 @@ extension UserTableViewCell {
viewModel.followedUsers,
viewModel.blockedUsers
)
.debounce(for: 0.1, scheduler: DispatchQueue.main)
.receive(on: DispatchQueue.main)
.sink { [weak self] followed, blocked in
if blocked.contains(user.id) {
self?.userView.setButtonState(.blocked)
} else if followed.contains(user.id) {
self?.userView.setButtonState(.unfollow)
} else {
} else if user != me {
self?.userView.setButtonState(.follow)
}

View File

@ -270,7 +270,9 @@ public extension UserView {
switch state {
case .loading:
followButton.isHidden = true
followButton.isHidden = false
followButton.setTitle(nil, for: .normal)
followButton.setBackgroundColor(Asset.Colors.Button.disabled.color, for: .normal)
case .follow:
followButton.isHidden = false
@ -292,6 +294,8 @@ public extension UserView {
case .none:
followButton.isHidden = true
followButton.setTitle(nil, for: .normal)
followButton.setBackgroundColor(.clear, for: .normal)
}
followButton.addTarget(self, action: #selector(didTapButton), for: .touchUpInside)