Disable "Follow all"-button if there are no suggestions (#1124)

This commit is contained in:
Nathan Mattes 2023-09-26 14:26:16 +02:00 committed by GitHub
parent 32564ff871
commit be11f632cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 11 deletions

View File

@ -104,6 +104,8 @@ extension SuggestionAccountViewController: UITableViewDelegate {
return nil
}
footerView.followAllButton.isEnabled = viewModel.userFetchedResultsController.records.isNotEmpty
footerView.delegate = self
return footerView
}

View File

@ -66,7 +66,7 @@ final class SuggestionAccountViewModel: NSObject {
}
guard !userIDs.isEmpty else { return }
guard userIDs.isNotEmpty else { return }
userFetchedResultsController.userIDs = userIDs
}

View File

@ -14,20 +14,20 @@ class SuggestionAccountTableViewFooter: UITableViewHeaderFooterView {
weak var delegate: SuggestionAccountTableViewFooterDelegate?
let followAllButton: FollowButton
let followAllButton: UIButton
override init(reuseIdentifier: String?) {
//TODO: Check if we can use UIButton.configuration here instead?
followAllButton = FollowButton()
followAllButton.translatesAutoresizingMaskIntoConstraints = false
followAllButton.setTitle(L10n.Scene.SuggestionAccount.followAll, for: .normal)
followAllButton.setBackgroundColor(Asset.Colors.Button.userFollow.color, for: .normal)
followAllButton.setTitleColor(.white, for: .normal)
followAllButton.contentEdgeInsets = .init(horizontal: 20, vertical: 12)
followAllButton.cornerRadius = 10
followAllButton.titleLabel?.font = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .boldSystemFont(ofSize: 15))
var buttonConfiguration = UIButton.Configuration.filled()
buttonConfiguration.baseForegroundColor = .white
buttonConfiguration.baseBackgroundColor = Asset.Colors.Button.userFollow.color
buttonConfiguration.background.cornerRadius = 10
buttonConfiguration.attributedTitle = AttributedString(L10n.Scene.SuggestionAccount.followAll, attributes: AttributeContainer([.font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .boldSystemFont(ofSize: 15))]))
buttonConfiguration.contentInsets = NSDirectionalEdgeInsets(top: 12, leading: 20, bottom: 12, trailing: 20)
followAllButton = UIButton(configuration: buttonConfiguration)
followAllButton.isEnabled = false
followAllButton.translatesAutoresizingMaskIntoConstraints = false
followAllButton.setContentCompressionResistancePriority(.required, for: .horizontal)
followAllButton.setContentHuggingPriority(.required, for: .horizontal)