More feedback from Sam (IOS-241)

This commit is contained in:
Nathan Mattes 2024-07-09 19:59:35 +02:00
parent 05a08f6ff2
commit 99f2fc9236
1 changed files with 78 additions and 9 deletions

View File

@ -2,21 +2,90 @@
import UIKit import UIKit
import MastodonSDK import MastodonSDK
import MastodonUI
class NotificationFilteringBannerTableViewCell: UITableViewCell { class NotificationFilteringBannerTableViewCell: UITableViewCell {
static let reuseIdentifier = "NotificationFilteringBannerTableViewCell" static let reuseIdentifier = "NotificationFilteringBannerTableViewCell"
//TODO: Add separator let iconImageView: UIImageView
let iconImageWrapperView: UIView
let titleLabel: UILabel
let subtitleLabel: UILabel
private let contentStackView: UIStackView
private let labelStackView: UIStackView
let separatorLine: UIView
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
iconImageView = UIImageView(image: UIImage(systemName: "archivebox"))
iconImageView.translatesAutoresizingMaskIntoConstraints = false
iconImageWrapperView = UIView()
iconImageWrapperView.translatesAutoresizingMaskIntoConstraints = false
iconImageWrapperView.addSubview(iconImageView)
titleLabel = UILabel()
//TODO: Add localization
titleLabel.text = "Filtered Notifications"
titleLabel.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17, weight: .regular))
subtitleLabel = UILabel()
subtitleLabel.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15, weight: .regular))
subtitleLabel.textColor = .secondaryLabel
labelStackView = UIStackView(arrangedSubviews: [titleLabel, subtitleLabel])
labelStackView.translatesAutoresizingMaskIntoConstraints = false
labelStackView.alignment = .leading
labelStackView.axis = .vertical
contentStackView = UIStackView(arrangedSubviews: [iconImageWrapperView, labelStackView])
contentStackView.translatesAutoresizingMaskIntoConstraints = false
contentStackView.alignment = .center
contentStackView.axis = .horizontal
contentStackView.spacing = 12
separatorLine = UIView.separatorLine
separatorLine.translatesAutoresizingMaskIntoConstraints = false
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.addSubview(contentStackView)
contentView.addSubview(separatorLine)
setupConstraints()
}
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
private func setupConstraints() {
let constraints = [
iconImageWrapperView.widthAnchor.constraint(equalToConstant: CGSize.authorAvatarButtonSize.width),
iconImageWrapperView.heightAnchor.constraint(equalToConstant: CGSize.authorAvatarButtonSize.height).priority(.defaultHigh),
iconImageView.centerXAnchor.constraint(equalTo: iconImageWrapperView.centerXAnchor),
iconImageView.centerYAnchor.constraint(equalTo: iconImageWrapperView.centerYAnchor),
iconImageView.widthAnchor.constraint(equalToConstant: 27),
iconImageView.heightAnchor.constraint(equalToConstant: 24),
contentStackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8),
contentStackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16),
contentView.trailingAnchor.constraint(equalTo: contentStackView.trailingAnchor, constant: 16),
separatorLine.topAnchor.constraint(equalTo: contentStackView.bottomAnchor, constant: 7),
separatorLine.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
separatorLine.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
separatorLine.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
separatorLine.heightAnchor.constraint(equalToConstant: UIView.separatorLineHeight(of: contentView))
]
NSLayoutConstraint.activate(constraints)
}
func configure(with policy: Mastodon.Entity.NotificationPolicy) { func configure(with policy: Mastodon.Entity.NotificationPolicy) {
var configuration = defaultContentConfiguration()
//TODO: Add localization //TODO: Add localization
configuration.text = "Filtered notifications" subtitleLabel.text = "\(policy.summary.pendingRequestsCount) people you may know"
configuration.secondaryText = "\(policy.summary.pendingRequestsCount) people you may know"
configuration.image = UIImage(systemName: "archivebox")
self.contentConfiguration = configuration
} }
} }