2021-04-14 10:24:40 +02:00
|
|
|
//
|
|
|
|
// NotificationStatusTableViewCell.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by sxiaojian on 2021/4/14.
|
|
|
|
//
|
|
|
|
|
2021-07-06 11:38:04 +02:00
|
|
|
import os.log
|
2021-04-14 10:24:40 +02:00
|
|
|
import Combine
|
|
|
|
import Foundation
|
2021-07-06 11:38:04 +02:00
|
|
|
import CoreDataStack
|
2021-04-14 10:24:40 +02:00
|
|
|
import UIKit
|
2021-04-20 07:18:27 +02:00
|
|
|
import ActiveLabel
|
2021-06-28 13:41:41 +02:00
|
|
|
import MetaTextView
|
|
|
|
import Meta
|
2021-07-02 13:48:56 +02:00
|
|
|
import FLAnimatedImage
|
|
|
|
import Nuke
|
2021-04-14 10:24:40 +02:00
|
|
|
|
2021-07-06 11:38:04 +02:00
|
|
|
protocol NotificationTableViewCellDelegate: AnyObject {
|
|
|
|
var context: AppContext! { get }
|
|
|
|
func parent() -> UIViewController
|
|
|
|
|
|
|
|
func notificationStatusTableViewCell(_ cell: NotificationStatusTableViewCell, avatarImageViewDidPressed imageView: UIImageView)
|
|
|
|
func notificationStatusTableViewCell(_ cell: NotificationStatusTableViewCell, authorNameLabelDidPressed label: ActiveLabel)
|
|
|
|
|
|
|
|
func notificationStatusTableViewCell(_ cell: NotificationStatusTableViewCell, statusView: StatusView, revealContentWarningButtonDidPressed button: UIButton)
|
|
|
|
func notificationStatusTableViewCell(_ cell: NotificationStatusTableViewCell, statusView: StatusView, contentWarningOverlayViewDidPressed contentWarningOverlayView: ContentWarningOverlayView)
|
|
|
|
func notificationStatusTableViewCell(_ cell: NotificationStatusTableViewCell, statusView: StatusView, playerContainerView: PlayerContainerView, contentWarningOverlayViewDidPressed contentWarningOverlayView: ContentWarningOverlayView)
|
|
|
|
func notificationStatusTableViewCell(_ cell: NotificationStatusTableViewCell, statusView: StatusView, metaText: MetaText, didSelectMeta meta: Meta)
|
|
|
|
|
|
|
|
func notificationTableViewCell(_ cell: NotificationStatusTableViewCell, notification: MastodonNotification, acceptButtonDidPressed button: UIButton)
|
|
|
|
func notificationTableViewCell(_ cell: NotificationStatusTableViewCell, notification: MastodonNotification, rejectButtonDidPressed button: UIButton)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-04-19 12:06:02 +02:00
|
|
|
final class NotificationStatusTableViewCell: UITableViewCell, StatusCell {
|
2021-07-02 21:22:17 +02:00
|
|
|
|
2021-04-14 10:24:40 +02:00
|
|
|
static let actionImageBorderWidth: CGFloat = 2
|
2021-04-15 04:16:30 +02:00
|
|
|
static let statusPadding = UIEdgeInsets(top: 50, left: 73, bottom: 24, right: 24)
|
2021-07-12 13:19:24 +02:00
|
|
|
static let actionImageViewSize = CGSize(width: 24, height: 24)
|
2021-07-02 21:22:17 +02:00
|
|
|
|
2021-04-14 10:24:40 +02:00
|
|
|
var disposeBag = Set<AnyCancellable>()
|
2021-04-14 11:37:58 +02:00
|
|
|
var pollCountdownSubscription: AnyCancellable?
|
2021-04-14 10:24:40 +02:00
|
|
|
var delegate: NotificationTableViewCellDelegate?
|
2021-07-02 13:48:56 +02:00
|
|
|
|
2021-07-02 21:22:17 +02:00
|
|
|
var containerStackViewBottomLayoutConstraint: NSLayoutConstraint!
|
|
|
|
let containerStackView = UIStackView()
|
|
|
|
|
2021-06-15 10:36:42 +02:00
|
|
|
let avatarImageView: UIImageView = {
|
2021-07-02 13:48:56 +02:00
|
|
|
let imageView = FLAnimatedImageView()
|
2021-04-14 10:24:40 +02:00
|
|
|
return imageView
|
|
|
|
}()
|
2021-07-20 13:59:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
let traitCollectionDidChange = PassthroughSubject<Void, Never>()
|
2021-04-14 10:24:40 +02:00
|
|
|
|
|
|
|
let actionImageView: UIImageView = {
|
|
|
|
let imageView = UIImageView()
|
2021-07-12 13:19:24 +02:00
|
|
|
imageView.contentMode = .center
|
|
|
|
imageView.isOpaque = true
|
|
|
|
imageView.layer.masksToBounds = true
|
|
|
|
imageView.layer.cornerRadius = NotificationStatusTableViewCell.actionImageViewSize.width * 0.5
|
|
|
|
imageView.layer.cornerCurve = .circular
|
|
|
|
imageView.layer.borderWidth = NotificationStatusTableViewCell.actionImageBorderWidth
|
|
|
|
imageView.layer.shouldRasterize = true
|
|
|
|
imageView.layer.rasterizationScale = UIScreen.main.scale
|
2021-04-14 10:24:40 +02:00
|
|
|
return imageView
|
|
|
|
}()
|
|
|
|
|
2021-04-16 15:55:09 +02:00
|
|
|
let avatarContainer: UIView = {
|
|
|
|
let view = UIView()
|
|
|
|
return view
|
|
|
|
}()
|
2021-07-02 21:22:17 +02:00
|
|
|
|
|
|
|
let contentStackView = UIStackView()
|
|
|
|
|
2021-04-14 10:24:40 +02:00
|
|
|
let actionLabel: UILabel = {
|
|
|
|
let label = UILabel()
|
|
|
|
label.textColor = Asset.Colors.Label.secondary.color
|
2021-05-10 12:48:04 +02:00
|
|
|
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15, weight: .regular), maximumPointSize: 20)
|
2021-04-14 10:24:40 +02:00
|
|
|
label.lineBreakMode = .byTruncatingTail
|
|
|
|
return label
|
|
|
|
}()
|
|
|
|
|
2021-07-01 12:57:05 +02:00
|
|
|
let nameLabel: ActiveLabel = {
|
|
|
|
let label = ActiveLabel(style: .statusName)
|
2021-04-14 10:24:40 +02:00
|
|
|
label.textColor = Asset.Colors.brandBlue.color
|
2021-05-10 12:48:04 +02:00
|
|
|
label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 15, weight: .semibold), maximumPointSize: 20)
|
2021-04-14 10:24:40 +02:00
|
|
|
label.lineBreakMode = .byTruncatingTail
|
|
|
|
return label
|
|
|
|
}()
|
2021-07-02 21:22:17 +02:00
|
|
|
|
|
|
|
let buttonStackView = UIStackView()
|
|
|
|
|
|
|
|
let acceptButton: UIButton = {
|
|
|
|
let button = UIButton(type: .custom)
|
|
|
|
let actionImage = UIImage(systemName: "checkmark.circle.fill", withConfiguration: UIImage.SymbolConfiguration(pointSize: 28, weight: .semibold))?.withRenderingMode(.alwaysTemplate)
|
|
|
|
button.setImage(actionImage, for: .normal)
|
|
|
|
button.tintColor = Asset.Colors.Label.secondary.color
|
|
|
|
return button
|
|
|
|
}()
|
|
|
|
|
|
|
|
let rejectButton: UIButton = {
|
|
|
|
let button = UIButton(type: .custom)
|
|
|
|
let actionImage = UIImage(systemName: "xmark.circle.fill", withConfiguration: UIImage.SymbolConfiguration(pointSize: 28, weight: .semibold))?.withRenderingMode(.alwaysTemplate)
|
|
|
|
button.setImage(actionImage, for: .normal)
|
|
|
|
button.tintColor = Asset.Colors.Label.secondary.color
|
|
|
|
return button
|
|
|
|
}()
|
|
|
|
|
|
|
|
let statusContainerView: UIView = {
|
2021-04-14 10:24:40 +02:00
|
|
|
let view = UIView()
|
2021-07-02 21:22:17 +02:00
|
|
|
view.layer.masksToBounds = true
|
2021-04-14 10:24:40 +02:00
|
|
|
view.layer.cornerRadius = 6
|
|
|
|
view.layer.cornerCurve = .continuous
|
2021-07-02 21:22:17 +02:00
|
|
|
view.layer.borderWidth = 2
|
|
|
|
view.layer.borderColor = Asset.Colors.Border.notificationStatus.color.cgColor
|
2021-04-14 10:24:40 +02:00
|
|
|
return view
|
|
|
|
}()
|
|
|
|
let statusView = StatusView()
|
|
|
|
|
2021-05-13 10:21:06 +02:00
|
|
|
let separatorLine = UIView.separatorLine
|
|
|
|
|
|
|
|
var separatorLineToEdgeLeadingLayoutConstraint: NSLayoutConstraint!
|
|
|
|
var separatorLineToEdgeTrailingLayoutConstraint: NSLayoutConstraint!
|
|
|
|
|
|
|
|
var separatorLineToMarginLeadingLayoutConstraint: NSLayoutConstraint!
|
|
|
|
var separatorLineToMarginTrailingLayoutConstraint: NSLayoutConstraint!
|
2021-07-09 13:07:12 +02:00
|
|
|
|
|
|
|
var isFiltered: Bool = false {
|
|
|
|
didSet {
|
|
|
|
configure(isFiltered: isFiltered)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let filteredLabel: UILabel = {
|
|
|
|
let label = UILabel()
|
|
|
|
label.textColor = Asset.Colors.Label.secondary.color
|
|
|
|
label.text = L10n.Common.Controls.Timeline.filtered
|
|
|
|
label.font = .preferredFont(forTextStyle: .body)
|
|
|
|
return label
|
|
|
|
}()
|
2021-05-13 10:21:06 +02:00
|
|
|
|
2021-04-14 10:24:40 +02:00
|
|
|
override func prepareForReuse() {
|
|
|
|
super.prepareForReuse()
|
2021-07-09 13:07:12 +02:00
|
|
|
isFiltered = false
|
2021-04-20 07:18:27 +02:00
|
|
|
statusView.updateContentWarningDisplay(isHidden: true, animated: false)
|
2021-04-14 10:24:40 +02:00
|
|
|
statusView.pollTableView.dataSource = nil
|
|
|
|
statusView.playerContainerView.reset()
|
|
|
|
statusView.playerContainerView.isHidden = true
|
|
|
|
disposeBag.removeAll()
|
|
|
|
}
|
|
|
|
|
|
|
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
|
|
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
|
|
|
configure()
|
|
|
|
}
|
|
|
|
|
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
super.init(coder: coder)
|
|
|
|
configure()
|
|
|
|
}
|
2021-06-23 14:47:49 +02:00
|
|
|
|
2021-04-14 10:24:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extension NotificationStatusTableViewCell {
|
|
|
|
func configure() {
|
2021-04-16 15:55:09 +02:00
|
|
|
containerStackView.axis = .horizontal
|
|
|
|
containerStackView.alignment = .top
|
2021-07-02 21:22:17 +02:00
|
|
|
containerStackView.distribution = .fill
|
|
|
|
containerStackView.spacing = 14 + 2 // 2pt for status container outline border
|
2021-04-16 15:55:09 +02:00
|
|
|
containerStackView.layoutMargins = UIEdgeInsets(top: 14, left: 0, bottom: 12, right: 0)
|
|
|
|
containerStackView.isLayoutMarginsRelativeArrangement = true
|
|
|
|
containerStackView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
contentView.addSubview(containerStackView)
|
2021-07-02 21:22:17 +02:00
|
|
|
containerStackViewBottomLayoutConstraint = contentView.bottomAnchor.constraint(equalTo: containerStackView.bottomAnchor)
|
2021-04-16 15:55:09 +02:00
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
containerStackView.topAnchor.constraint(equalTo: contentView.topAnchor),
|
|
|
|
containerStackView.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor),
|
|
|
|
contentView.readableContentGuide.trailingAnchor.constraint(equalTo: containerStackView.trailingAnchor),
|
2021-07-02 21:22:17 +02:00
|
|
|
containerStackViewBottomLayoutConstraint.priority(.required - 1),
|
2021-04-16 15:55:09 +02:00
|
|
|
])
|
|
|
|
|
|
|
|
containerStackView.addArrangedSubview(avatarContainer)
|
2021-06-15 10:36:42 +02:00
|
|
|
avatarImageView.translatesAutoresizingMaskIntoConstraints = false
|
2021-07-02 21:22:17 +02:00
|
|
|
avatarContainer.addSubview(avatarImageView)
|
2021-04-16 15:55:09 +02:00
|
|
|
NSLayoutConstraint.activate([
|
2021-07-02 21:22:17 +02:00
|
|
|
avatarImageView.topAnchor.constraint(equalTo: avatarContainer.topAnchor),
|
|
|
|
avatarImageView.leadingAnchor.constraint(equalTo: avatarContainer.leadingAnchor),
|
|
|
|
avatarImageView.trailingAnchor.constraint(equalTo: avatarContainer.trailingAnchor),
|
|
|
|
avatarImageView.bottomAnchor.constraint(equalTo: avatarContainer.bottomAnchor),
|
2021-06-15 10:36:42 +02:00
|
|
|
avatarImageView.heightAnchor.constraint(equalToConstant: 35).priority(.required - 1),
|
|
|
|
avatarImageView.widthAnchor.constraint(equalToConstant: 35).priority(.required - 1),
|
2021-04-15 04:37:46 +02:00
|
|
|
])
|
|
|
|
|
2021-04-16 15:55:09 +02:00
|
|
|
actionImageView.translatesAutoresizingMaskIntoConstraints = false
|
2021-07-12 13:19:24 +02:00
|
|
|
avatarContainer.addSubview(actionImageView)
|
2021-04-16 15:55:09 +02:00
|
|
|
NSLayoutConstraint.activate([
|
2021-07-12 13:19:24 +02:00
|
|
|
actionImageView.centerYAnchor.constraint(equalTo: avatarContainer.bottomAnchor),
|
|
|
|
actionImageView.centerXAnchor.constraint(equalTo: avatarContainer.trailingAnchor),
|
2021-07-20 13:59:09 +02:00
|
|
|
actionImageView.widthAnchor.constraint(equalToConstant: NotificationStatusTableViewCell.actionImageViewSize.width).priority(.required - 1),
|
|
|
|
actionImageView.heightAnchor.constraint(equalTo: actionImageView.widthAnchor, multiplier: 1.0),
|
2021-04-16 15:55:09 +02:00
|
|
|
])
|
|
|
|
|
2021-07-02 21:22:17 +02:00
|
|
|
containerStackView.addArrangedSubview(contentStackView)
|
|
|
|
contentStackView.axis = .vertical
|
|
|
|
contentStackView.spacing = 6
|
|
|
|
|
|
|
|
// header
|
2021-04-16 15:55:09 +02:00
|
|
|
let actionStackView = UIStackView()
|
2021-07-02 21:22:17 +02:00
|
|
|
contentStackView.addArrangedSubview(actionStackView)
|
2021-04-16 15:55:09 +02:00
|
|
|
actionStackView.axis = .horizontal
|
2021-04-16 16:58:36 +02:00
|
|
|
actionStackView.distribution = .fill
|
2021-04-16 15:55:09 +02:00
|
|
|
actionStackView.spacing = 4
|
2021-07-02 21:22:17 +02:00
|
|
|
|
2021-04-16 15:55:09 +02:00
|
|
|
actionStackView.addArrangedSubview(nameLabel)
|
|
|
|
actionStackView.addArrangedSubview(actionLabel)
|
2021-07-02 21:22:17 +02:00
|
|
|
nameLabel.setContentHuggingPriority(.required - 1, for: .horizontal)
|
|
|
|
nameLabel.setContentHuggingPriority(.required - 1, for: .vertical)
|
|
|
|
nameLabel.setContentCompressionResistancePriority(.required - 1, for: .horizontal)
|
2021-04-16 15:55:09 +02:00
|
|
|
nameLabel.setContentCompressionResistancePriority(.required - 1, for: .vertical)
|
2021-04-16 16:58:36 +02:00
|
|
|
actionLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
2021-07-02 21:22:17 +02:00
|
|
|
|
|
|
|
// follow request
|
|
|
|
contentStackView.addArrangedSubview(buttonStackView)
|
|
|
|
buttonStackView.addArrangedSubview(acceptButton)
|
|
|
|
buttonStackView.addArrangedSubview(rejectButton)
|
|
|
|
buttonStackView.axis = .horizontal
|
|
|
|
buttonStackView.distribution = .fillEqually
|
|
|
|
|
|
|
|
// status
|
|
|
|
contentStackView.addArrangedSubview(statusContainerView)
|
|
|
|
statusContainerView.layoutMargins = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
|
2021-04-16 15:55:09 +02:00
|
|
|
statusView.translatesAutoresizingMaskIntoConstraints = false
|
2021-07-02 21:22:17 +02:00
|
|
|
statusContainerView.addSubview(statusView)
|
2021-04-16 15:55:09 +02:00
|
|
|
NSLayoutConstraint.activate([
|
2021-07-02 21:22:17 +02:00
|
|
|
statusView.topAnchor.constraint(equalTo: statusContainerView.layoutMarginsGuide.topAnchor),
|
|
|
|
statusView.leadingAnchor.constraint(equalTo: statusContainerView.layoutMarginsGuide.leadingAnchor),
|
|
|
|
statusView.trailingAnchor.constraint(equalTo: statusContainerView.layoutMarginsGuide.trailingAnchor),
|
|
|
|
statusView.bottomAnchor.constraint(equalTo: statusContainerView.layoutMarginsGuide.bottomAnchor),
|
2021-04-14 10:24:40 +02:00
|
|
|
])
|
2021-07-05 10:07:17 +02:00
|
|
|
|
2021-07-06 12:00:39 +02:00
|
|
|
setupBackgroundColor(theme: ThemeService.shared.currentTheme.value)
|
2021-07-05 10:07:17 +02:00
|
|
|
ThemeService.shared.currentTheme
|
|
|
|
.receive(on: RunLoop.main)
|
|
|
|
.sink { [weak self] theme in
|
|
|
|
guard let self = self else { return }
|
2021-07-06 12:00:39 +02:00
|
|
|
self.setupBackgroundColor(theme: theme)
|
2021-07-02 21:22:17 +02:00
|
|
|
}
|
2021-07-05 10:07:17 +02:00
|
|
|
.store(in: &disposeBag)
|
2021-07-02 21:22:17 +02:00
|
|
|
// remove item don't display
|
|
|
|
statusView.actionToolbarContainer.removeFromStackView()
|
|
|
|
// it affect stackView's height, need remove
|
|
|
|
statusView.headerContainerView.removeFromStackView()
|
2021-04-16 15:55:09 +02:00
|
|
|
|
2021-07-02 21:22:17 +02:00
|
|
|
// adaptive separator
|
2021-05-13 10:21:06 +02:00
|
|
|
separatorLine.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
contentView.addSubview(separatorLine)
|
|
|
|
separatorLineToEdgeLeadingLayoutConstraint = separatorLine.leadingAnchor.constraint(equalTo: contentView.leadingAnchor)
|
|
|
|
separatorLineToEdgeTrailingLayoutConstraint = separatorLine.trailingAnchor.constraint(equalTo: contentView.trailingAnchor)
|
|
|
|
separatorLineToMarginLeadingLayoutConstraint = separatorLine.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor)
|
|
|
|
separatorLineToMarginTrailingLayoutConstraint = separatorLine.trailingAnchor.constraint(equalTo: contentView.readableContentGuide.trailingAnchor)
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
separatorLine.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
|
|
|
|
separatorLine.heightAnchor.constraint(equalToConstant: UIView.separatorLineHeight(of: contentView)),
|
|
|
|
])
|
2021-07-02 21:22:17 +02:00
|
|
|
|
2021-07-09 13:07:12 +02:00
|
|
|
filteredLabel.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
addSubview(filteredLabel)
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
filteredLabel.centerXAnchor.constraint(equalTo: statusContainerView.centerXAnchor),
|
|
|
|
filteredLabel.centerYAnchor.constraint(equalTo: statusContainerView.centerYAnchor),
|
|
|
|
])
|
|
|
|
filteredLabel.isHidden = true
|
|
|
|
|
2021-07-02 21:22:17 +02:00
|
|
|
statusView.delegate = self
|
2021-07-06 11:38:04 +02:00
|
|
|
|
|
|
|
let avatarImageViewTapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer
|
|
|
|
avatarImageViewTapGestureRecognizer.addTarget(self, action: #selector(NotificationStatusTableViewCell.avatarImageViewTapGestureRecognizerHandler(_:)))
|
|
|
|
avatarImageView.addGestureRecognizer(avatarImageViewTapGestureRecognizer)
|
|
|
|
let authorNameLabelTapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer
|
|
|
|
authorNameLabelTapGestureRecognizer.addTarget(self, action: #selector(NotificationStatusTableViewCell.authorNameLabelTapGestureRecognizerHandler(_:)))
|
|
|
|
nameLabel.addGestureRecognizer(authorNameLabelTapGestureRecognizer)
|
|
|
|
|
2021-07-02 21:22:17 +02:00
|
|
|
resetSeparatorLineLayout()
|
2021-07-20 13:59:09 +02:00
|
|
|
|
|
|
|
setupBackgroundColor(theme: ThemeService.shared.currentTheme.value)
|
|
|
|
ThemeService.shared.currentTheme
|
|
|
|
.receive(on: DispatchQueue.main)
|
|
|
|
.sink { [weak self] theme in
|
|
|
|
guard let self = self else { return }
|
|
|
|
self.setupBackgroundColor(theme: theme)
|
|
|
|
}
|
|
|
|
.store(in: &disposeBag)
|
2021-04-14 10:24:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
|
|
|
super.traitCollectionDidChange(previousTraitCollection)
|
2021-05-13 10:21:06 +02:00
|
|
|
|
|
|
|
resetSeparatorLineLayout()
|
2021-07-20 13:59:09 +02:00
|
|
|
setupBackgroundColor(theme: ThemeService.shared.currentTheme.value)
|
|
|
|
traitCollectionDidChange.send()
|
2021-04-14 10:24:40 +02:00
|
|
|
}
|
2021-06-23 14:47:49 +02:00
|
|
|
|
2021-07-09 13:07:12 +02:00
|
|
|
private func configure(isFiltered: Bool) {
|
|
|
|
statusView.alpha = isFiltered ? 0 : 1
|
|
|
|
filteredLabel.isHidden = !isFiltered
|
|
|
|
isUserInteractionEnabled = !isFiltered
|
|
|
|
}
|
2021-04-20 07:18:27 +02:00
|
|
|
}
|
|
|
|
|
2021-07-06 12:00:39 +02:00
|
|
|
extension NotificationStatusTableViewCell {
|
|
|
|
|
|
|
|
private func setupBackgroundColor(theme: Theme) {
|
2021-07-20 13:59:09 +02:00
|
|
|
actionImageView.layer.borderColor = theme.systemBackgroundColor.cgColor
|
|
|
|
avatarImageView.layer.borderColor = Asset.Theme.Mastodon.systemBackground.color.cgColor
|
|
|
|
statusContainerView.layer.borderColor = Asset.Colors.Border.notificationStatus.color.cgColor
|
2021-07-06 12:00:39 +02:00
|
|
|
statusContainerView.backgroundColor = UIColor(dynamicProvider: { traitCollection in
|
|
|
|
return traitCollection.userInterfaceStyle == .light ? theme.systemBackgroundColor : theme.tertiarySystemGroupedBackgroundColor
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-07-06 11:38:04 +02:00
|
|
|
extension NotificationStatusTableViewCell {
|
|
|
|
@objc private func avatarImageViewTapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) {
|
|
|
|
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
|
|
|
|
delegate?.notificationStatusTableViewCell(self, avatarImageViewDidPressed: avatarImageView)
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc private func authorNameLabelTapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) {
|
|
|
|
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
|
|
|
|
delegate?.notificationStatusTableViewCell(self, authorNameLabelDidPressed: nameLabel)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-20 07:18:27 +02:00
|
|
|
// MARK: - StatusViewDelegate
|
|
|
|
extension NotificationStatusTableViewCell: StatusViewDelegate {
|
2021-06-23 14:47:49 +02:00
|
|
|
|
2021-04-20 07:18:27 +02:00
|
|
|
func statusView(_ statusView: StatusView, headerInfoLabelDidPressed label: UILabel) {
|
|
|
|
// do nothing
|
|
|
|
}
|
2021-06-23 14:47:49 +02:00
|
|
|
|
|
|
|
func statusView(_ statusView: StatusView, avatarImageViewDidPressed imageView: UIImageView) {
|
2021-04-20 07:18:27 +02:00
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
func statusView(_ statusView: StatusView, revealContentWarningButtonDidPressed button: UIButton) {
|
|
|
|
delegate?.notificationStatusTableViewCell(self, statusView: statusView, revealContentWarningButtonDidPressed: button)
|
|
|
|
}
|
|
|
|
|
|
|
|
func statusView(_ statusView: StatusView, contentWarningOverlayViewDidPressed contentWarningOverlayView: ContentWarningOverlayView) {
|
|
|
|
delegate?.notificationStatusTableViewCell(self, statusView: statusView, contentWarningOverlayViewDidPressed: contentWarningOverlayView)
|
|
|
|
}
|
|
|
|
|
|
|
|
func statusView(_ statusView: StatusView, playerContainerView: PlayerContainerView, contentWarningOverlayViewDidPressed contentWarningOverlayView: ContentWarningOverlayView) {
|
|
|
|
delegate?.notificationStatusTableViewCell(self, statusView: statusView, playerContainerView: playerContainerView, contentWarningOverlayViewDidPressed: contentWarningOverlayView)
|
|
|
|
}
|
|
|
|
|
|
|
|
func statusView(_ statusView: StatusView, pollVoteButtonPressed button: UIButton) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
func statusView(_ statusView: StatusView, activeLabel: ActiveLabel, didSelectActiveEntity entity: ActiveEntity) {
|
|
|
|
// do nothing
|
|
|
|
}
|
2021-06-28 13:41:41 +02:00
|
|
|
|
|
|
|
func statusView(_ statusView: StatusView, metaText: MetaText, didSelectMeta meta: Meta) {
|
2021-07-01 12:57:05 +02:00
|
|
|
delegate?.notificationStatusTableViewCell(self, statusView: statusView, metaText: metaText, didSelectMeta: meta)
|
2021-06-28 13:41:41 +02:00
|
|
|
}
|
2021-04-20 07:18:27 +02:00
|
|
|
|
2021-05-13 10:21:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extension NotificationStatusTableViewCell {
|
|
|
|
|
|
|
|
private func resetSeparatorLineLayout() {
|
|
|
|
separatorLineToEdgeLeadingLayoutConstraint.isActive = false
|
|
|
|
separatorLineToEdgeTrailingLayoutConstraint.isActive = false
|
|
|
|
separatorLineToMarginLeadingLayoutConstraint.isActive = false
|
|
|
|
separatorLineToMarginTrailingLayoutConstraint.isActive = false
|
|
|
|
|
|
|
|
if traitCollection.userInterfaceIdiom == .phone {
|
|
|
|
// to edge
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
separatorLineToEdgeLeadingLayoutConstraint,
|
|
|
|
separatorLineToEdgeTrailingLayoutConstraint,
|
|
|
|
])
|
|
|
|
} else {
|
|
|
|
if traitCollection.horizontalSizeClass == .compact {
|
|
|
|
// to edge
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
separatorLineToEdgeLeadingLayoutConstraint,
|
|
|
|
separatorLineToEdgeTrailingLayoutConstraint,
|
|
|
|
])
|
|
|
|
} else {
|
|
|
|
// to margin
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
separatorLineToMarginLeadingLayoutConstraint,
|
|
|
|
separatorLineToMarginTrailingLayoutConstraint,
|
|
|
|
])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-20 07:18:27 +02:00
|
|
|
|
2021-04-14 10:24:40 +02:00
|
|
|
}
|
2021-07-12 13:19:24 +02:00
|
|
|
|
|
|
|
// MARK: - AvatarConfigurableView
|
|
|
|
extension NotificationStatusTableViewCell: AvatarConfigurableView {
|
|
|
|
static var configurableAvatarImageSize: CGSize { CGSize(width: 35, height: 35) }
|
|
|
|
static var configurableAvatarImageCornerRadius: CGFloat { 4 }
|
|
|
|
var configurableAvatarImageView: UIImageView? { avatarImageView }
|
|
|
|
var configurableAvatarButton: UIButton? { nil }
|
|
|
|
}
|