2022-01-27 14:23:39 +01:00
|
|
|
//
|
|
|
|
// StatusView.swift
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Created by MainasuK on 2022-1-10.
|
|
|
|
//
|
|
|
|
|
|
|
|
import os.log
|
|
|
|
import UIKit
|
|
|
|
import Combine
|
|
|
|
import MetaTextKit
|
|
|
|
import Meta
|
|
|
|
import MastodonAsset
|
2022-10-08 07:43:06 +02:00
|
|
|
import MastodonCore
|
2022-01-27 14:23:39 +01:00
|
|
|
import MastodonLocalization
|
|
|
|
|
2022-10-31 21:01:19 +01:00
|
|
|
public extension CGSize {
|
|
|
|
static let authorAvatarButtonSize = CGSize(width: 46, height: 46)
|
|
|
|
}
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
public protocol StatusViewDelegate: AnyObject {
|
|
|
|
func statusView(_ statusView: StatusView, headerDidPressed header: UIView)
|
|
|
|
func statusView(_ statusView: StatusView, authorAvatarButtonDidPressed button: AvatarButton)
|
2022-02-11 13:21:28 +01:00
|
|
|
func statusView(_ statusView: StatusView, contentSensitiveeToggleButtonDidPressed button: UIButton)
|
2022-01-27 14:23:39 +01:00
|
|
|
func statusView(_ statusView: StatusView, metaText: MetaText, didSelectMeta meta: Meta)
|
2022-11-24 16:48:07 +01:00
|
|
|
func statusView(_ statusView: StatusView, didTapCardWithURL url: URL)
|
2022-01-27 14:23:39 +01:00
|
|
|
func statusView(_ statusView: StatusView, mediaGridContainerView: MediaGridContainerView, mediaView: MediaView, didSelectMediaViewAt index: Int)
|
|
|
|
func statusView(_ statusView: StatusView, pollTableView tableView: UITableView, didSelectRowAt indexPath: IndexPath)
|
|
|
|
func statusView(_ statusView: StatusView, pollVoteButtonPressed button: UIButton)
|
|
|
|
func statusView(_ statusView: StatusView, actionToolbarContainer: ActionToolbarContainer, buttonDidPressed button: UIButton, action: ActionToolbarContainer.Action)
|
|
|
|
func statusView(_ statusView: StatusView, menuButton button: UIButton, didSelectAction action: MastodonMenu.Action)
|
2022-02-08 12:50:18 +01:00
|
|
|
func statusView(_ statusView: StatusView, spoilerOverlayViewDidPressed overlayView: SpoilerOverlayView)
|
2022-02-09 13:35:19 +01:00
|
|
|
func statusView(_ statusView: StatusView, mediaGridContainerView: MediaGridContainerView, mediaSensitiveButtonDidPressed button: UIButton)
|
2022-05-17 16:09:43 +02:00
|
|
|
func statusView(_ statusView: StatusView, statusMetricView: StatusMetricView, reblogButtonDidPressed button: UIButton)
|
|
|
|
func statusView(_ statusView: StatusView, statusMetricView: StatusMetricView, favoriteButtonDidPressed button: UIButton)
|
2022-02-10 13:01:52 +01:00
|
|
|
|
|
|
|
// a11y
|
|
|
|
func statusView(_ statusView: StatusView, accessibilityActivate: Void)
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public final class StatusView: UIView {
|
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
public static let containerLayoutMargin: CGFloat = 16
|
2022-01-27 14:23:39 +01:00
|
|
|
|
|
|
|
let logger = Logger(subsystem: "StatusView", category: "View")
|
|
|
|
|
|
|
|
private var _disposeBag = Set<AnyCancellable>() // which lifetime same to view scope
|
|
|
|
public var disposeBag = Set<AnyCancellable>()
|
|
|
|
|
|
|
|
public weak var delegate: StatusViewDelegate?
|
|
|
|
|
|
|
|
public private(set) var style: Style?
|
|
|
|
|
|
|
|
public private(set) lazy var viewModel: ViewModel = {
|
|
|
|
let viewModel = ViewModel()
|
|
|
|
viewModel.bind(statusView: self)
|
|
|
|
return viewModel
|
|
|
|
}()
|
|
|
|
|
|
|
|
let containerStackView: UIStackView = {
|
|
|
|
let stackView = UIStackView()
|
|
|
|
stackView.axis = .vertical
|
|
|
|
stackView.spacing = 10
|
|
|
|
return stackView
|
|
|
|
}()
|
|
|
|
|
|
|
|
// header
|
2022-02-18 10:49:20 +01:00
|
|
|
let headerAdaptiveMarginContainerView = AdaptiveMarginContainerView()
|
2022-02-14 12:34:22 +01:00
|
|
|
public let headerContainerView = UIView()
|
2022-01-27 14:23:39 +01:00
|
|
|
|
|
|
|
// header icon
|
|
|
|
let headerIconImageView: UIImageView = {
|
|
|
|
let imageView = UIImageView()
|
|
|
|
imageView.tintColor = Asset.Colors.Label.secondary.color
|
|
|
|
imageView.contentMode = .scaleAspectFill
|
|
|
|
return imageView
|
|
|
|
}()
|
|
|
|
|
|
|
|
// header info
|
|
|
|
let headerInfoLabel = MetaLabel(style: .statusHeader)
|
|
|
|
|
|
|
|
// author
|
2022-02-18 10:49:20 +01:00
|
|
|
let authorAdaptiveMarginContainerView = AdaptiveMarginContainerView()
|
2022-10-31 17:01:14 +01:00
|
|
|
public let authorView = StatusAuthorView()
|
2022-01-27 14:23:39 +01:00
|
|
|
|
|
|
|
// content
|
2022-02-18 10:49:20 +01:00
|
|
|
let contentAdaptiveMarginContainerView = AdaptiveMarginContainerView()
|
2022-01-27 14:23:39 +01:00
|
|
|
let contentContainer = UIStackView()
|
|
|
|
public let contentMetaText: MetaText = {
|
|
|
|
let metaText = MetaText()
|
|
|
|
metaText.textView.backgroundColor = .clear
|
|
|
|
metaText.textView.isEditable = false
|
|
|
|
metaText.textView.isSelectable = false
|
|
|
|
metaText.textView.isScrollEnabled = false
|
|
|
|
metaText.textView.textContainer.lineFragmentPadding = 0
|
|
|
|
metaText.textView.textContainerInset = .zero
|
|
|
|
metaText.textView.layer.masksToBounds = false
|
|
|
|
metaText.textView.textDragInteraction?.isEnabled = false // disable drag for link and attachment
|
|
|
|
|
|
|
|
metaText.paragraphStyle = {
|
|
|
|
let style = NSMutableParagraphStyle()
|
|
|
|
style.lineSpacing = 5
|
|
|
|
style.paragraphSpacing = 8
|
|
|
|
style.alignment = .natural
|
|
|
|
return style
|
|
|
|
}()
|
|
|
|
metaText.textAttributes = [
|
2022-04-07 13:28:06 +02:00
|
|
|
.font: UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)),
|
2022-01-27 14:23:39 +01:00
|
|
|
.foregroundColor: Asset.Colors.Label.primary.color,
|
|
|
|
]
|
|
|
|
metaText.linkAttributes = [
|
2022-06-02 11:31:23 +02:00
|
|
|
.font: UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)),
|
|
|
|
.foregroundColor: Asset.Colors.brand.color,
|
2022-01-27 14:23:39 +01:00
|
|
|
]
|
|
|
|
return metaText
|
|
|
|
}()
|
2022-11-12 03:35:18 +01:00
|
|
|
|
2022-11-27 06:47:49 +01:00
|
|
|
public let statusCardControl = StatusCardControl()
|
2022-01-29 10:02:30 +01:00
|
|
|
|
2022-02-08 12:50:18 +01:00
|
|
|
// content warning
|
2022-02-14 12:34:22 +01:00
|
|
|
public let spoilerOverlayView = SpoilerOverlayView()
|
2022-01-27 14:23:39 +01:00
|
|
|
|
|
|
|
// media
|
|
|
|
public let mediaContainerView = UIView()
|
|
|
|
public let mediaGridContainerView = MediaGridContainerView()
|
|
|
|
|
|
|
|
// poll
|
2022-02-18 10:49:20 +01:00
|
|
|
let pollAdaptiveMarginContainerView = AdaptiveMarginContainerView()
|
|
|
|
let pollContainerView = UIStackView()
|
2022-01-27 14:23:39 +01:00
|
|
|
public let pollTableView: UITableView = {
|
|
|
|
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
|
|
|
|
tableView.register(PollOptionTableViewCell.self, forCellReuseIdentifier: String(describing: PollOptionTableViewCell.self))
|
|
|
|
tableView.isScrollEnabled = false
|
|
|
|
tableView.estimatedRowHeight = 36
|
|
|
|
tableView.tableFooterView = UIView()
|
|
|
|
tableView.backgroundColor = .clear
|
|
|
|
tableView.separatorStyle = .none
|
|
|
|
return tableView
|
|
|
|
}()
|
|
|
|
public var pollTableViewHeightLayoutConstraint: NSLayoutConstraint!
|
|
|
|
public var pollTableViewDiffableDataSource: UITableViewDiffableDataSource<PollSection, PollItem>?
|
|
|
|
|
2022-02-14 12:34:22 +01:00
|
|
|
public let pollStatusStackView = UIStackView()
|
2022-01-27 14:23:39 +01:00
|
|
|
let pollVoteCountLabel: UILabel = {
|
|
|
|
let label = UILabel()
|
|
|
|
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 12, weight: .regular))
|
|
|
|
label.textColor = Asset.Colors.Label.secondary.color
|
|
|
|
label.text = L10n.Plural.Count.vote(0)
|
|
|
|
return label
|
|
|
|
}()
|
|
|
|
let pollStatusDotLabel: UILabel = {
|
|
|
|
let label = UILabel()
|
|
|
|
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 12, weight: .regular))
|
|
|
|
label.textColor = Asset.Colors.Label.secondary.color
|
|
|
|
label.text = " · "
|
2022-02-14 12:34:22 +01:00
|
|
|
label.isAccessibilityElement = false
|
2022-01-27 14:23:39 +01:00
|
|
|
return label
|
|
|
|
}()
|
|
|
|
let pollCountdownLabel: UILabel = {
|
|
|
|
let label = UILabel()
|
|
|
|
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 12, weight: .regular))
|
|
|
|
label.textColor = Asset.Colors.Label.secondary.color
|
|
|
|
label.text = "1 day left"
|
|
|
|
return label
|
|
|
|
}()
|
|
|
|
let pollVoteButton: UIButton = {
|
|
|
|
let button = HitTestExpandedButton()
|
|
|
|
button.titleLabel?.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 14, weight: .semibold))
|
|
|
|
button.setTitle(L10n.Common.Controls.Status.Poll.vote, for: .normal)
|
2022-06-02 11:31:23 +02:00
|
|
|
button.setTitleColor(Asset.Colors.brand.color, for: .normal)
|
|
|
|
button.setTitleColor(Asset.Colors.brand.color.withAlphaComponent(0.8), for: .highlighted)
|
2022-01-27 14:23:39 +01:00
|
|
|
button.setTitleColor(Asset.Colors.Button.disabled.color, for: .disabled)
|
|
|
|
button.isEnabled = false
|
|
|
|
return button
|
|
|
|
}()
|
|
|
|
let pollVoteActivityIndicatorView: UIActivityIndicatorView = {
|
|
|
|
let indicatorView = UIActivityIndicatorView(style: .medium)
|
|
|
|
indicatorView.hidesWhenStopped = true
|
|
|
|
indicatorView.stopAnimating()
|
|
|
|
return indicatorView
|
|
|
|
}()
|
2022-02-18 10:49:20 +01:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
// toolbar
|
2022-02-18 10:49:20 +01:00
|
|
|
let actionToolbarAdaptiveMarginContainerView = AdaptiveMarginContainerView()
|
2022-01-27 14:23:39 +01:00
|
|
|
public let actionToolbarContainer = ActionToolbarContainer()
|
|
|
|
|
|
|
|
// metric
|
2022-02-18 10:49:20 +01:00
|
|
|
let statusMetricViewAdaptiveMarginContainerView = AdaptiveMarginContainerView()
|
2022-01-27 14:23:39 +01:00
|
|
|
public let statusMetricView = StatusMetricView()
|
|
|
|
|
2022-02-15 12:44:45 +01:00
|
|
|
// filter hint
|
|
|
|
public let filterHintLabel: UILabel = {
|
|
|
|
let label = UILabel()
|
|
|
|
label.textColor = Asset.Colors.Label.secondary.color
|
|
|
|
label.text = L10n.Common.Controls.Timeline.filtered
|
|
|
|
label.font = .systemFont(ofSize: 17, weight: .regular)
|
|
|
|
return label
|
|
|
|
}()
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
public func prepareForReuse() {
|
|
|
|
disposeBag.removeAll()
|
|
|
|
|
|
|
|
viewModel.objects.removeAll()
|
2022-01-29 10:02:30 +01:00
|
|
|
viewModel.prepareForReuse()
|
2022-01-27 14:23:39 +01:00
|
|
|
|
2022-10-31 17:01:14 +01:00
|
|
|
authorView.avatarButton.avatarImageView.cancelTask()
|
2022-01-27 14:23:39 +01:00
|
|
|
if var snapshot = pollTableViewDiffableDataSource?.snapshot() {
|
|
|
|
snapshot.deleteAllItems()
|
|
|
|
if #available(iOS 15.0, *) {
|
|
|
|
pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
|
|
|
} else {
|
|
|
|
// Fallback on earlier versions
|
|
|
|
pollTableViewDiffableDataSource?.apply(snapshot, animatingDifferences: false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
setHeaderDisplay(isDisplay: false)
|
|
|
|
setContentSensitiveeToggleButtonDisplay(isDisplay: false)
|
2022-02-08 12:50:18 +01:00
|
|
|
setSpoilerOverlayViewHidden(isHidden: true)
|
2022-02-18 10:49:20 +01:00
|
|
|
setMediaDisplay(isDisplay: false)
|
|
|
|
setPollDisplay(isDisplay: false)
|
|
|
|
setFilterHintLabelDisplay(isDisplay: false)
|
2022-11-27 06:47:49 +01:00
|
|
|
setStatusCardControlDisplay(isDisplay: false)
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override init(frame: CGRect) {
|
|
|
|
super.init(frame: frame)
|
|
|
|
_init()
|
|
|
|
}
|
|
|
|
|
|
|
|
public required init?(coder: NSCoder) {
|
|
|
|
super.init(coder: coder)
|
|
|
|
_init()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extension StatusView {
|
|
|
|
private func _init() {
|
|
|
|
// container
|
|
|
|
containerStackView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
addSubview(containerStackView)
|
2022-11-17 17:45:27 +01:00
|
|
|
containerStackView.pinToParent()
|
2022-01-27 14:23:39 +01:00
|
|
|
|
|
|
|
// header
|
|
|
|
headerIconImageView.isUserInteractionEnabled = false
|
|
|
|
headerInfoLabel.isUserInteractionEnabled = false
|
2022-11-09 22:59:02 +01:00
|
|
|
headerInfoLabel.isAccessibilityElement = false
|
2022-01-27 14:23:39 +01:00
|
|
|
let headerTapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer
|
|
|
|
headerTapGestureRecognizer.addTarget(self, action: #selector(StatusView.headerDidPressed(_:)))
|
|
|
|
headerContainerView.addGestureRecognizer(headerTapGestureRecognizer)
|
2022-10-31 17:01:14 +01:00
|
|
|
|
|
|
|
// author view
|
|
|
|
authorView.statusView = self
|
|
|
|
|
2022-02-08 12:50:18 +01:00
|
|
|
// content warning
|
|
|
|
let spoilerOverlayViewTapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer
|
|
|
|
spoilerOverlayView.addGestureRecognizer(spoilerOverlayViewTapGestureRecognizer)
|
|
|
|
spoilerOverlayViewTapGestureRecognizer.addTarget(self, action: #selector(StatusView.spoilerOverlayViewTapGestureRecognizerHandler(_:)))
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
// content
|
|
|
|
contentMetaText.textView.delegate = self
|
|
|
|
contentMetaText.textView.linkDelegate = self
|
2022-11-27 06:47:49 +01:00
|
|
|
|
|
|
|
// card
|
|
|
|
statusCardControl.addTarget(self, action: #selector(statusCardControlPressed), for: .touchUpInside)
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
// media
|
|
|
|
mediaGridContainerView.delegate = self
|
2022-11-24 16:48:07 +01:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
// poll
|
|
|
|
pollTableView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
pollTableViewHeightLayoutConstraint = pollTableView.heightAnchor.constraint(equalToConstant: 44.0).priority(.required - 1)
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
pollTableViewHeightLayoutConstraint,
|
|
|
|
])
|
|
|
|
pollTableView.delegate = self
|
|
|
|
pollVoteButton.addTarget(self, action: #selector(StatusView.pollVoteButtonDidPressed(_:)), for: .touchUpInside)
|
2022-05-17 16:09:43 +02:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
// toolbar
|
|
|
|
actionToolbarContainer.delegate = self
|
2022-05-17 16:09:43 +02:00
|
|
|
|
|
|
|
// statusMetricView
|
|
|
|
statusMetricView.delegate = self
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension StatusView {
|
|
|
|
|
|
|
|
@objc private func headerDidPressed(_ sender: UITapGestureRecognizer) {
|
|
|
|
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)")
|
|
|
|
assert(sender.view === headerContainerView)
|
|
|
|
delegate?.statusView(self, headerDidPressed: headerContainerView)
|
|
|
|
}
|
2022-01-29 10:02:30 +01:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
@objc private func pollVoteButtonDidPressed(_ sender: UIButton) {
|
|
|
|
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)")
|
|
|
|
delegate?.statusView(self, pollVoteButtonPressed: pollVoteButton)
|
|
|
|
}
|
|
|
|
|
2022-02-08 12:50:18 +01:00
|
|
|
@objc private func spoilerOverlayViewTapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) {
|
|
|
|
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)")
|
|
|
|
delegate?.statusView(self, spoilerOverlayViewDidPressed: spoilerOverlayView)
|
|
|
|
}
|
2022-11-24 16:48:07 +01:00
|
|
|
|
2022-11-27 06:47:49 +01:00
|
|
|
@objc private func statusCardControlPressed(_ sender: StatusCardControl) {
|
2022-11-24 16:48:07 +01:00
|
|
|
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)")
|
|
|
|
guard let url = viewModel.card?.url else { return }
|
|
|
|
delegate?.statusView(self, didTapCardWithURL: url)
|
|
|
|
}
|
2022-02-08 12:50:18 +01:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
extension StatusView {
|
|
|
|
|
|
|
|
public func setup(style: Style) {
|
|
|
|
guard self.style == nil else {
|
|
|
|
assertionFailure("Should only setup once")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
self.style = style
|
|
|
|
style.layout(statusView: self)
|
|
|
|
prepareForReuse()
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum Style {
|
|
|
|
case inline
|
|
|
|
case plain
|
2022-02-08 05:36:06 +01:00
|
|
|
case report
|
2022-01-27 14:23:39 +01:00
|
|
|
case notification
|
|
|
|
case notificationQuote
|
|
|
|
case composeStatusReplica
|
|
|
|
case composeStatusAuthor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension StatusView.Style {
|
|
|
|
|
|
|
|
func layout(statusView: StatusView) {
|
|
|
|
switch self {
|
|
|
|
case .inline: inline(statusView: statusView)
|
|
|
|
case .plain: plain(statusView: statusView)
|
2022-02-08 05:36:06 +01:00
|
|
|
case .report: report(statusView: statusView)
|
2022-01-27 14:23:39 +01:00
|
|
|
case .notification: notification(statusView: statusView)
|
|
|
|
case .notificationQuote: notificationQuote(statusView: statusView)
|
|
|
|
case .composeStatusReplica: composeStatusReplica(statusView: statusView)
|
|
|
|
case .composeStatusAuthor: composeStatusAuthor(statusView: statusView)
|
|
|
|
}
|
2022-10-31 17:01:14 +01:00
|
|
|
|
|
|
|
statusView.authorView.layout(style: self)
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
2022-02-08 12:50:18 +01:00
|
|
|
private func base(statusView: StatusView) {
|
2022-01-27 14:23:39 +01:00
|
|
|
// container: V - [ header container | author container | content container | media container | pollTableView | actionToolbarContainer ]
|
|
|
|
|
|
|
|
// header container: H - [ icon | label ]
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.headerAdaptiveMarginContainerView.contentView = statusView.headerContainerView
|
|
|
|
statusView.headerAdaptiveMarginContainerView.margin = StatusView.containerLayoutMargin
|
|
|
|
statusView.containerStackView.addArrangedSubview(statusView.headerAdaptiveMarginContainerView)
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.headerIconImageView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
statusView.headerInfoLabel.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
statusView.headerContainerView.addSubview(statusView.headerIconImageView)
|
|
|
|
statusView.headerContainerView.addSubview(statusView.headerInfoLabel)
|
|
|
|
NSLayoutConstraint.activate([
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.headerIconImageView.leadingAnchor.constraint(equalTo: statusView.headerContainerView.leadingAnchor),
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.headerIconImageView.heightAnchor.constraint(equalTo: statusView.headerInfoLabel.heightAnchor, multiplier: 1.0).priority(.required - 1),
|
2022-05-17 11:03:19 +02:00
|
|
|
statusView.headerIconImageView.widthAnchor.constraint(equalTo: statusView.headerInfoLabel.heightAnchor, multiplier: 1.0).priority(.required - 1),
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.headerInfoLabel.topAnchor.constraint(equalTo: statusView.headerContainerView.topAnchor),
|
|
|
|
statusView.headerInfoLabel.leadingAnchor.constraint(equalTo: statusView.headerIconImageView.trailingAnchor, constant: 6),
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.headerInfoLabel.trailingAnchor.constraint(equalTo: statusView.headerContainerView.trailingAnchor),
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.headerInfoLabel.bottomAnchor.constraint(equalTo: statusView.headerContainerView.bottomAnchor),
|
|
|
|
statusView.headerInfoLabel.centerYAnchor.constraint(equalTo: statusView.headerIconImageView.centerYAnchor),
|
|
|
|
])
|
2022-05-17 11:03:19 +02:00
|
|
|
statusView.headerInfoLabel.setContentHuggingPriority(.required - 1, for: .vertical)
|
|
|
|
statusView.headerInfoLabel.setContentCompressionResistancePriority(.required - 1, for: .vertical)
|
|
|
|
statusView.headerIconImageView.setContentHuggingPriority(.defaultLow - 100, for: .vertical)
|
|
|
|
statusView.headerIconImageView.setContentHuggingPriority(.defaultLow - 100, for: .horizontal)
|
|
|
|
statusView.headerIconImageView.setContentCompressionResistancePriority(.defaultLow - 100, for: .vertical)
|
|
|
|
statusView.headerIconImageView.setContentCompressionResistancePriority(.defaultLow - 100, for: .horizontal)
|
2022-01-27 14:23:39 +01:00
|
|
|
|
2022-10-31 17:01:14 +01:00
|
|
|
statusView.authorAdaptiveMarginContainerView.contentView = statusView.authorView
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.authorAdaptiveMarginContainerView.margin = StatusView.containerLayoutMargin
|
|
|
|
statusView.containerStackView.addArrangedSubview(statusView.authorAdaptiveMarginContainerView)
|
2022-02-09 13:35:19 +01:00
|
|
|
|
2022-11-27 06:47:49 +01:00
|
|
|
// content container: V - [ contentMetaText statusCardControl ]
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.contentContainer.axis = .vertical
|
2022-11-27 04:22:05 +01:00
|
|
|
statusView.contentContainer.spacing = 12
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.contentContainer.distribution = .fill
|
2022-11-12 03:35:18 +01:00
|
|
|
statusView.contentContainer.alignment = .fill
|
2022-02-09 13:35:19 +01:00
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.contentAdaptiveMarginContainerView.contentView = statusView.contentContainer
|
|
|
|
statusView.contentAdaptiveMarginContainerView.margin = StatusView.containerLayoutMargin
|
|
|
|
statusView.containerStackView.addArrangedSubview(statusView.contentAdaptiveMarginContainerView)
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.contentContainer.setContentHuggingPriority(.required - 1, for: .vertical)
|
|
|
|
statusView.contentContainer.setContentCompressionResistancePriority(.required - 1, for: .vertical)
|
2022-02-09 13:35:19 +01:00
|
|
|
|
2022-01-29 10:02:30 +01:00
|
|
|
// status content
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.contentContainer.addArrangedSubview(statusView.contentMetaText.textView)
|
2022-11-27 06:47:49 +01:00
|
|
|
statusView.contentContainer.addArrangedSubview(statusView.statusCardControl)
|
2022-02-09 13:35:19 +01:00
|
|
|
|
2022-01-29 10:02:30 +01:00
|
|
|
statusView.spoilerOverlayView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
statusView.containerStackView.addSubview(statusView.spoilerOverlayView)
|
2022-11-17 17:45:27 +01:00
|
|
|
statusView.contentContainer.pinTo(to: statusView.spoilerOverlayView)
|
2022-02-09 13:35:19 +01:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
// media container: V - [ mediaGridContainerView ]
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.mediaContainerView.translatesAutoresizingMaskIntoConstraints = false
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.containerStackView.addArrangedSubview(statusView.mediaContainerView)
|
2022-02-18 10:49:20 +01:00
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
statusView.mediaContainerView.leadingAnchor.constraint(equalTo: statusView.containerStackView.leadingAnchor),
|
|
|
|
statusView.mediaContainerView.trailingAnchor.constraint(equalTo: statusView.containerStackView.trailingAnchor),
|
|
|
|
])
|
2022-02-09 13:35:19 +01:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.mediaGridContainerView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
statusView.mediaContainerView.addSubview(statusView.mediaGridContainerView)
|
2022-11-17 17:45:27 +01:00
|
|
|
statusView.mediaGridContainerView.pinToParent()
|
2022-02-09 13:35:19 +01:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
// pollContainerView: V - [ pollTableView | pollStatusStackView ]
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.pollAdaptiveMarginContainerView.contentView = statusView.pollContainerView
|
|
|
|
statusView.pollAdaptiveMarginContainerView.margin = StatusView.containerLayoutMargin
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.pollContainerView.axis = .vertical
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.containerStackView.addArrangedSubview(statusView.pollAdaptiveMarginContainerView)
|
2022-02-09 13:35:19 +01:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
// pollTableView
|
|
|
|
statusView.pollContainerView.addArrangedSubview(statusView.pollTableView)
|
2022-02-09 13:35:19 +01:00
|
|
|
|
2022-02-14 12:34:22 +01:00
|
|
|
// pollStatusStackView: H - [ pollVoteCountLabel | pollCountdownLabel | pollVoteButton ]
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.pollStatusStackView.axis = .horizontal
|
|
|
|
statusView.pollContainerView.addArrangedSubview(statusView.pollStatusStackView)
|
2022-02-09 13:35:19 +01:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.pollStatusStackView.addArrangedSubview(statusView.pollVoteCountLabel)
|
|
|
|
statusView.pollStatusStackView.addArrangedSubview(statusView.pollStatusDotLabel)
|
|
|
|
statusView.pollStatusStackView.addArrangedSubview(statusView.pollCountdownLabel)
|
|
|
|
statusView.pollStatusStackView.addArrangedSubview(statusView.pollVoteButton)
|
|
|
|
statusView.pollStatusStackView.addArrangedSubview(statusView.pollVoteActivityIndicatorView)
|
|
|
|
statusView.pollVoteCountLabel.setContentHuggingPriority(.defaultHigh + 2, for: .horizontal)
|
|
|
|
statusView.pollStatusDotLabel.setContentHuggingPriority(.defaultHigh + 1, for: .horizontal)
|
|
|
|
statusView.pollCountdownLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
|
|
|
statusView.pollVoteButton.setContentHuggingPriority(.defaultHigh + 3, for: .horizontal)
|
2022-02-09 13:35:19 +01:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
// action toolbar
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.actionToolbarAdaptiveMarginContainerView.contentView = statusView.actionToolbarContainer
|
|
|
|
statusView.actionToolbarAdaptiveMarginContainerView.margin = StatusView.containerLayoutMargin
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.actionToolbarContainer.configure(for: .inline)
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.containerStackView.addArrangedSubview(statusView.actionToolbarAdaptiveMarginContainerView)
|
2022-02-15 12:44:45 +01:00
|
|
|
|
|
|
|
// filterHintLabel
|
|
|
|
statusView.filterHintLabel.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
statusView.addSubview(statusView.filterHintLabel)
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
statusView.filterHintLabel.centerXAnchor.constraint(equalTo: statusView.containerStackView.centerXAnchor),
|
|
|
|
statusView.filterHintLabel.centerYAnchor.constraint(equalTo: statusView.containerStackView.centerYAnchor),
|
|
|
|
])
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
2022-02-08 12:50:18 +01:00
|
|
|
func inline(statusView: StatusView) {
|
|
|
|
base(statusView: statusView)
|
|
|
|
}
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
func plain(statusView: StatusView) {
|
|
|
|
// container: V - [ … | statusMetricView ]
|
2022-02-08 12:50:18 +01:00
|
|
|
base(statusView: statusView) // override the base style
|
2022-01-27 14:23:39 +01:00
|
|
|
|
|
|
|
// statusMetricView
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.statusMetricViewAdaptiveMarginContainerView.contentView = statusView.statusMetricView
|
|
|
|
statusView.statusMetricViewAdaptiveMarginContainerView.margin = StatusView.containerLayoutMargin
|
|
|
|
statusView.containerStackView.addArrangedSubview(statusView.statusMetricViewAdaptiveMarginContainerView)
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
UIContentSizeCategory.publisher
|
|
|
|
.sink { category in
|
|
|
|
statusView.statusMetricView.containerStackView.axis = category > .accessibilityLarge ? .vertical : .horizontal
|
|
|
|
statusView.statusMetricView.containerStackView.alignment = category > .accessibilityLarge ? .leading : .fill
|
|
|
|
}
|
|
|
|
.store(in: &statusView._disposeBag)
|
|
|
|
}
|
|
|
|
|
2022-02-08 05:36:06 +01:00
|
|
|
func report(statusView: StatusView) {
|
2022-02-08 12:50:18 +01:00
|
|
|
base(statusView: statusView) // override the base style
|
2022-02-08 05:36:06 +01:00
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.actionToolbarAdaptiveMarginContainerView.removeFromSuperview()
|
2022-02-08 05:36:06 +01:00
|
|
|
}
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
func notification(statusView: StatusView) {
|
2022-02-08 12:50:18 +01:00
|
|
|
base(statusView: statusView) // override the base style
|
2022-01-27 14:23:39 +01:00
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.headerAdaptiveMarginContainerView.removeFromSuperview()
|
|
|
|
statusView.authorAdaptiveMarginContainerView.removeFromSuperview()
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func notificationQuote(statusView: StatusView) {
|
2022-02-08 12:50:18 +01:00
|
|
|
base(statusView: statusView) // override the base style
|
2022-01-27 14:23:39 +01:00
|
|
|
|
2022-02-18 11:25:26 +01:00
|
|
|
statusView.contentAdaptiveMarginContainerView.bottomLayoutConstraint?.constant = 16 // fix bottom margin missing issue
|
|
|
|
statusView.pollAdaptiveMarginContainerView.bottomLayoutConstraint?.constant = 16 // fix bottom margin missing issue
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.actionToolbarAdaptiveMarginContainerView.removeFromSuperview()
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func composeStatusReplica(statusView: StatusView) {
|
2022-02-08 12:50:18 +01:00
|
|
|
base(statusView: statusView)
|
2022-01-27 14:23:39 +01:00
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.actionToolbarAdaptiveMarginContainerView.removeFromSuperview()
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func composeStatusAuthor(statusView: StatusView) {
|
2022-02-08 12:50:18 +01:00
|
|
|
base(statusView: statusView)
|
2022-01-27 14:23:39 +01:00
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.contentAdaptiveMarginContainerView.removeFromSuperview()
|
2022-01-29 12:51:40 +01:00
|
|
|
statusView.spoilerOverlayView.removeFromSuperview()
|
2022-01-27 14:23:39 +01:00
|
|
|
statusView.mediaContainerView.removeFromSuperview()
|
2022-02-18 10:49:20 +01:00
|
|
|
statusView.pollAdaptiveMarginContainerView.removeFromSuperview()
|
|
|
|
statusView.actionToolbarAdaptiveMarginContainerView.removeFromSuperview()
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extension StatusView {
|
2022-02-18 10:49:20 +01:00
|
|
|
func setHeaderDisplay(isDisplay: Bool = true) {
|
|
|
|
headerAdaptiveMarginContainerView.isHidden = !isDisplay
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
func setContentSensitiveeToggleButtonDisplay(isDisplay: Bool = true) {
|
2022-10-31 17:01:14 +01:00
|
|
|
authorView.contentSensitiveeToggleButton.isHidden = !isDisplay
|
2022-02-11 13:21:28 +01:00
|
|
|
}
|
|
|
|
|
2022-02-08 12:50:18 +01:00
|
|
|
func setSpoilerOverlayViewHidden(isHidden: Bool) {
|
2022-01-29 10:02:30 +01:00
|
|
|
spoilerOverlayView.isHidden = isHidden
|
|
|
|
spoilerOverlayView.setComponentHidden(isHidden)
|
|
|
|
}
|
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
func setMediaDisplay(isDisplay: Bool = true) {
|
|
|
|
mediaContainerView.isHidden = !isDisplay
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
func setPollDisplay(isDisplay: Bool = true) {
|
|
|
|
pollAdaptiveMarginContainerView.isHidden = !isDisplay
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
func setFilterHintLabelDisplay(isDisplay: Bool = true) {
|
|
|
|
filterHintLabel.isHidden = !isDisplay
|
2022-01-29 10:02:30 +01:00
|
|
|
}
|
2022-11-12 03:35:18 +01:00
|
|
|
|
2022-11-27 06:47:49 +01:00
|
|
|
func setStatusCardControlDisplay(isDisplay: Bool = true) {
|
|
|
|
statusCardControl.isHidden = !isDisplay
|
2022-11-12 03:35:18 +01:00
|
|
|
}
|
2022-01-29 10:02:30 +01:00
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
// container width
|
2022-01-27 14:23:39 +01:00
|
|
|
public var contentMaxLayoutWidth: CGFloat {
|
2022-02-18 10:49:20 +01:00
|
|
|
return frame.width
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
2022-02-18 10:49:20 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-11-03 19:59:58 +01:00
|
|
|
extension StatusView {
|
|
|
|
public override var accessibilityCustomActions: [UIAccessibilityCustomAction]? {
|
|
|
|
get { contentMetaText.textView.accessibilityCustomActions }
|
|
|
|
set { }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-18 10:49:20 +01:00
|
|
|
// MARK: - AdaptiveContainerView
|
|
|
|
extension StatusView: AdaptiveContainerView {
|
|
|
|
public func updateContainerViewComponentsLayoutMarginsRelativeArrangementBehavior(isEnabled: Bool) {
|
|
|
|
let margin = isEnabled ? StatusView.containerLayoutMargin : .zero
|
|
|
|
headerAdaptiveMarginContainerView.margin = margin
|
|
|
|
authorAdaptiveMarginContainerView.margin = margin
|
|
|
|
contentAdaptiveMarginContainerView.margin = margin
|
|
|
|
pollAdaptiveMarginContainerView.margin = margin
|
|
|
|
actionToolbarAdaptiveMarginContainerView.margin = margin
|
|
|
|
statusMetricViewAdaptiveMarginContainerView.margin = margin
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - UITextViewDelegate
|
|
|
|
extension StatusView: UITextViewDelegate {
|
|
|
|
|
|
|
|
public func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
|
|
|
|
switch textView {
|
|
|
|
case contentMetaText.textView:
|
|
|
|
return false
|
|
|
|
default:
|
|
|
|
assertionFailure()
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
|
|
|
|
switch textView {
|
|
|
|
case contentMetaText.textView:
|
|
|
|
return false
|
|
|
|
default:
|
|
|
|
assertionFailure()
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - MetaTextViewDelegate
|
|
|
|
extension StatusView: MetaTextViewDelegate {
|
|
|
|
public func metaTextView(_ metaTextView: MetaTextView, didSelectMeta meta: Meta) {
|
2022-04-11 06:27:26 +02:00
|
|
|
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): meta: \(String(describing: meta))")
|
2022-01-27 14:23:39 +01:00
|
|
|
switch metaTextView {
|
|
|
|
case contentMetaText.textView:
|
|
|
|
delegate?.statusView(self, metaText: contentMetaText, didSelectMeta: meta)
|
|
|
|
default:
|
|
|
|
assertionFailure()
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - MediaGridContainerViewDelegate
|
|
|
|
extension StatusView: MediaGridContainerViewDelegate {
|
|
|
|
public func mediaGridContainerView(_ container: MediaGridContainerView, didTapMediaView mediaView: MediaView, at index: Int) {
|
|
|
|
delegate?.statusView(self, mediaGridContainerView: container, mediaView: mediaView, didSelectMediaViewAt: index)
|
|
|
|
}
|
|
|
|
|
2022-02-09 13:35:19 +01:00
|
|
|
public func mediaGridContainerView(_ container: MediaGridContainerView, mediaSensitiveButtonDidPressed button: UIButton) {
|
|
|
|
delegate?.statusView(self, mediaGridContainerView: container, mediaSensitiveButtonDidPressed: button)
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - UITableViewDelegate
|
|
|
|
extension StatusView: UITableViewDelegate {
|
|
|
|
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
|
|
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): select \(indexPath.debugDescription)")
|
|
|
|
|
|
|
|
switch tableView {
|
|
|
|
case pollTableView:
|
|
|
|
delegate?.statusView(self, pollTableView: tableView, didSelectRowAt: indexPath)
|
|
|
|
default:
|
|
|
|
assertionFailure()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: ActionToolbarContainerDelegate
|
|
|
|
extension StatusView: ActionToolbarContainerDelegate {
|
|
|
|
public func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, buttonDidPressed button: UIButton, action: ActionToolbarContainer.Action) {
|
|
|
|
delegate?.statusView(self, actionToolbarContainer: actionToolbarContainer, buttonDidPressed: button, action: action)
|
|
|
|
}
|
2022-10-31 17:40:18 +01:00
|
|
|
|
|
|
|
public func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, showReblogs action: UIAccessibilityCustomAction) {
|
|
|
|
delegate?.statusView(self, statusMetricView: statusMetricView, reblogButtonDidPressed: statusMetricView.reblogButton)
|
|
|
|
}
|
|
|
|
|
|
|
|
public func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, showFavorites action: UIAccessibilityCustomAction) {
|
|
|
|
delegate?.statusView(self, statusMetricView: statusMetricView, favoriteButtonDidPressed: statusMetricView.favoriteButton)
|
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
|
2022-05-17 16:09:43 +02:00
|
|
|
// MARK: - StatusMetricViewDelegate
|
|
|
|
extension StatusView: StatusMetricViewDelegate {
|
|
|
|
func statusMetricView(_ statusMetricView: StatusMetricView, reblogButtonDidPressed button: UIButton) {
|
|
|
|
delegate?.statusView(self, statusMetricView: statusMetricView, reblogButtonDidPressed: button)
|
|
|
|
}
|
|
|
|
|
|
|
|
func statusMetricView(_ statusMetricView: StatusMetricView, favoriteButtonDidPressed button: UIButton) {
|
|
|
|
delegate?.statusView(self, statusMetricView: statusMetricView, favoriteButtonDidPressed: button)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
// MARK: - MastodonMenuDelegate
|
|
|
|
extension StatusView: MastodonMenuDelegate {
|
|
|
|
public func menuAction(_ action: MastodonMenu.Action) {
|
|
|
|
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)")
|
2022-10-31 17:01:14 +01:00
|
|
|
delegate?.statusView(self, menuButton: authorView.menuButton, didSelectAction: action)
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct StatusView_Preview: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
UIViewPreview {
|
|
|
|
let statusView = StatusView()
|
|
|
|
statusView.setup(style: .inline)
|
|
|
|
configureStub(statusView: statusView)
|
|
|
|
return statusView
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static func configureStub(statusView: StatusView) {
|
|
|
|
// statusView.viewModel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|