Show accept/reject-button (IOS-241)

For now they are just ... there to gather feedback, functions follows
This commit is contained in:
Nathan Mattes 2024-07-18 12:27:51 +02:00
parent 1a123d04be
commit e645bc1fd1
2 changed files with 85 additions and 5 deletions

View File

@ -6,6 +6,13 @@ import MetaTextKit
import MastodonMeta import MastodonMeta
import MastodonUI import MastodonUI
import MastodonCore import MastodonCore
import MastodonLocalization
import MastodonAsset
protocol NotificationRequestTableViewCellDelegate: AnyObject {
// reject
// accept
}
class NotificationRequestTableViewCell: UITableViewCell { class NotificationRequestTableViewCell: UITableViewCell {
static let reuseIdentifier = "NotificationRequestTableViewCell" static let reuseIdentifier = "NotificationRequestTableViewCell"
@ -15,11 +22,22 @@ class NotificationRequestTableViewCell: UITableViewCell {
let avatarButton: AvatarButton let avatarButton: AvatarButton
private let labelStackView: UIStackView private let labelStackView: UIStackView
private let avatarStackView: UIStackView
private let contentStackView: UIStackView private let contentStackView: UIStackView
// private let stack // private let stack
// accept/deny-button // accept/deny-button
let acceptNotificationRequestButtonShadowBackgroundContainer = ShadowBackgroundContainer()
let acceptNotificationRequestButton: HighlightDimmableButton
let acceptNotificationRequestActivityIndicatorView = UIActivityIndicatorView(style: .medium)
let rejectNotificationRequestButtonShadowBackgroundContainer = ShadowBackgroundContainer()
let rejectNotificationRequestActivityIndicatorView = UIActivityIndicatorView(style: .medium)
let rejectNotificationRequestButton: HighlightDimmableButton
private let buttonStackView: UIStackView
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
nameLabel = MetaLabel(style: .statusName) nameLabel = MetaLabel(style: .statusName)
usernameLabel = MetaLabel(style: .statusUsername) usernameLabel = MetaLabel(style: .statusUsername)
@ -33,14 +51,64 @@ class NotificationRequestTableViewCell: UITableViewCell {
labelStackView.alignment = .leading labelStackView.alignment = .leading
labelStackView.spacing = 4 labelStackView.spacing = 4
contentStackView = UIStackView(arrangedSubviews: [avatarButton, labelStackView]) acceptNotificationRequestButton = HighlightDimmableButton()
acceptNotificationRequestButton.translatesAutoresizingMaskIntoConstraints = false
acceptNotificationRequestButton.titleLabel?.font = UIFont.systemFont(ofSize: 17, weight: .semibold)
acceptNotificationRequestButton.setTitleColor(.white, for: .normal)
acceptNotificationRequestButton.setTitle(L10n.Common.Controls.Actions.confirm, for: .normal)
acceptNotificationRequestButton.setImage(Asset.Editing.checkmark20.image.withRenderingMode(.alwaysTemplate), for: .normal)
acceptNotificationRequestButton.imageView?.contentMode = .scaleAspectFit
acceptNotificationRequestButton.setBackgroundImage(.placeholder(color: Asset.Scene.Notification.confirmFollowRequestButtonBackground.color), for: .normal)
acceptNotificationRequestButton.setInsets(forContentPadding: UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8), imageTitlePadding: 8)
acceptNotificationRequestButton.tintColor = .white
acceptNotificationRequestButton.layer.masksToBounds = true
acceptNotificationRequestButton.layer.cornerCurve = .continuous
acceptNotificationRequestButton.layer.cornerRadius = 10
acceptNotificationRequestButton.accessibilityLabel = L10n.Scene.Notification.FollowRequest.accept
acceptNotificationRequestButtonShadowBackgroundContainer.cornerRadius = 10
acceptNotificationRequestButtonShadowBackgroundContainer.shadowAlpha = 0.1
acceptNotificationRequestButtonShadowBackgroundContainer.addSubview(acceptNotificationRequestButton)
rejectNotificationRequestButton = HighlightDimmableButton()
rejectNotificationRequestButton.translatesAutoresizingMaskIntoConstraints = false
rejectNotificationRequestButton.titleLabel?.font = UIFont.systemFont(ofSize: 17, weight: .semibold)
rejectNotificationRequestButton.setTitleColor(.black, for: .normal)
rejectNotificationRequestButton.setTitle(L10n.Common.Controls.Actions.delete, for: .normal)
rejectNotificationRequestButton.setImage(Asset.Circles.forbidden20.image.withRenderingMode(.alwaysTemplate), for: .normal)
rejectNotificationRequestButton.imageView?.contentMode = .scaleAspectFit
rejectNotificationRequestButton.setInsets(forContentPadding: UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8), imageTitlePadding: 8)
rejectNotificationRequestButton.setBackgroundImage(.placeholder(color: Asset.Scene.Notification.deleteFollowRequestButtonBackground.color), for: .normal)
rejectNotificationRequestButton.tintColor = .black
rejectNotificationRequestButton.layer.masksToBounds = true
rejectNotificationRequestButton.layer.cornerCurve = .continuous
rejectNotificationRequestButton.layer.cornerRadius = 10
rejectNotificationRequestButton.accessibilityLabel = L10n.Scene.Notification.FollowRequest.reject
rejectNotificationRequestButtonShadowBackgroundContainer.cornerRadius = 10
rejectNotificationRequestButtonShadowBackgroundContainer.shadowAlpha = 0.1
rejectNotificationRequestButtonShadowBackgroundContainer.addSubview(rejectNotificationRequestButton)
buttonStackView = UIStackView(arrangedSubviews: [acceptNotificationRequestButtonShadowBackgroundContainer, rejectNotificationRequestButtonShadowBackgroundContainer])
buttonStackView.axis = .horizontal
buttonStackView.distribution = .fillEqually
buttonStackView.spacing = 16
buttonStackView.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: 16, right: 0) // set bottom padding
avatarStackView = UIStackView(arrangedSubviews: [avatarButton, labelStackView])
avatarStackView.axis = .horizontal
avatarStackView.alignment = .center
avatarStackView.spacing = 12
contentStackView = UIStackView(arrangedSubviews: [avatarStackView, buttonStackView])
contentStackView.translatesAutoresizingMaskIntoConstraints = false contentStackView.translatesAutoresizingMaskIntoConstraints = false
contentStackView.axis = .horizontal contentStackView.spacing = 16
contentStackView.alignment = .center contentStackView.axis = .vertical
contentStackView.spacing = 12 contentStackView.alignment = .leading
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
// acceptNotificationRequestButton.addTarget(self, action: #selector(NotificationView.acceptNotificationRequestButtonDidPressed(_:)), for: .touchUpInside)
// rejectNotificationRequestButton.addTarget(self, action: #selector(NotificationView.rejectNotificationRequestButtonDidPressed(_:)), for: .touchUpInside)
contentView.addSubview(contentStackView) contentView.addSubview(contentStackView)
setupConstraints() setupConstraints()
} }
@ -55,11 +123,16 @@ class NotificationRequestTableViewCell: UITableViewCell {
contentView.trailingAnchor.constraint(equalTo: contentStackView.trailingAnchor, constant: 16), contentView.trailingAnchor.constraint(equalTo: contentStackView.trailingAnchor, constant: 16),
contentView.bottomAnchor.constraint(equalTo: contentStackView.bottomAnchor, constant: 16), contentView.bottomAnchor.constraint(equalTo: contentStackView.bottomAnchor, constant: 16),
buttonStackView.widthAnchor.constraint(equalTo: contentStackView.widthAnchor),
avatarStackView.widthAnchor.constraint(equalTo: contentStackView.widthAnchor),
avatarButton.widthAnchor.constraint(equalToConstant: CGSize.authorAvatarButtonSize.width).priority(.required - 1), avatarButton.widthAnchor.constraint(equalToConstant: CGSize.authorAvatarButtonSize.width).priority(.required - 1),
avatarButton.heightAnchor.constraint(equalToConstant: CGSize.authorAvatarButtonSize.height).priority(.required - 1), avatarButton.heightAnchor.constraint(equalToConstant: CGSize.authorAvatarButtonSize.height).priority(.required - 1),
] ]
NSLayoutConstraint.activate(constraints) NSLayoutConstraint.activate(constraints)
acceptNotificationRequestButton.pinToParent()
rejectNotificationRequestButton.pinToParent()
} }
override func prepareForReuse() { override func prepareForReuse() {
@ -87,4 +160,8 @@ class NotificationRequestTableViewCell: UITableViewCell {
let metaUsername = PlaintextMetaContent(string: "@\(account.acct)") let metaUsername = PlaintextMetaContent(string: "@\(account.acct)")
usernameLabel.configure(content: metaUsername) usernameLabel.configure(content: metaUsername)
} }
// MARK: - Actions
// reject
// accept
} }

View File

@ -35,7 +35,7 @@ class NotificationRequestsTableViewController: UIViewController, NeedsDependency
tableView = UITableView(frame: .zero) tableView = UITableView(frame: .zero)
tableView.translatesAutoresizingMaskIntoConstraints = false tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.backgroundColor = .systemBackground tableView.backgroundColor = .secondarySystemBackground
tableView.register(NotificationRequestTableViewCell.self, forCellReuseIdentifier: NotificationRequestTableViewCell.reuseIdentifier) tableView.register(NotificationRequestTableViewCell.self, forCellReuseIdentifier: NotificationRequestTableViewCell.reuseIdentifier)
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)
@ -57,6 +57,9 @@ class NotificationRequestsTableViewController: UIViewController, NeedsDependency
tableView.dataSource = dataSource tableView.dataSource = dataSource
tableView.delegate = self tableView.delegate = self
self.dataSource = dataSource self.dataSource = dataSource
//TODO: Localization
title = "Filtered Notifications"
} }
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }