From 479ca23e00daeef73043d6e9220fb2b7c857fae6 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Thu, 10 Sep 2020 22:54:01 -0400 Subject: [PATCH] Tweak follow request notification cells --- ...llowRequestNotificationTableViewCell.swift | 26 ++++++++++------ ...FollowRequestNotificationTableViewCell.xib | 31 ++++++++++++------- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.swift b/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.swift index ff0fb6b7..1438a361 100644 --- a/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.swift +++ b/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.swift @@ -104,36 +104,42 @@ class FollowRequestNotificationTableViewCell: UITableViewCell { updateTimestampWorkItem = nil } + private func addLabel(_ text: String) { + let label = UILabel() + label.textAlignment = .center + label.font = .boldSystemFont(ofSize: 17) + label.text = text + self.stackView.addArrangedSubview(label) + } + // MARK: - Interaction @IBAction func rejectButtonPressed() { + acceptButton.isEnabled = false + rejectButton.isEnabled = false + let request = Account.rejectFollowRequest(account) mastodonController.run(request) { (response) in guard case .success(_, _) = response else { fatalError() } DispatchQueue.main.async { UINotificationFeedbackGenerator().notificationOccurred(.success) self.actionButtonsStackView.isHidden = true - let label = UILabel() - label.textAlignment = .center - label.font = .boldSystemFont(ofSize: 17) - label.text = NSLocalizedString("Rejected", comment: "rejected follow request label") - self.stackView.addArrangedSubview(label) + self.addLabel(NSLocalizedString("Rejected", comment: "rejected follow request label")) } } } @IBAction func acceptButtonPressed() { + acceptButton.isEnabled = false + rejectButton.isEnabled = false + let request = Account.authorizeFollowRequest(account) mastodonController.run(request) { (response) in guard case .success(_, _) = response else { fatalError() } DispatchQueue.main.async { UINotificationFeedbackGenerator().notificationOccurred(.success) self.actionButtonsStackView.isHidden = true - let label = UILabel() - label.textAlignment = .center - label.font = .boldSystemFont(ofSize: 17) - label.text = NSLocalizedString("Accepted", comment: "accepted follow request label") - self.stackView.addArrangedSubview(label) + self.addLabel(NSLocalizedString("Accepted", comment: "accepted follow request label")) } } } diff --git a/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.xib b/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.xib index 55abf8f7..be1f165d 100644 --- a/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.xib +++ b/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.xib @@ -1,9 +1,11 @@ - + - + + + @@ -30,12 +32,12 @@ - + @@ -49,19 +51,20 @@ - -