From 2876bcced63d4d66c0edff0df20a65335b535ac3 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Sun, 30 Jun 2024 12:41:39 +0200 Subject: [PATCH] Coordinate to Profile if there's an account (IOS-284) --- ...taSourceProvider+StatusTableViewCellDelegate.swift | 11 +++++++++++ .../NotificationView/NotificationView.swift | 5 +++-- .../TableviewCell/StatusTableViewCellDelegate.swift | 5 +++++ .../Sources/MastodonUI/View/Content/StatusView.swift | 5 ++--- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift b/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift index 1ad23a3aa..438149890 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift @@ -144,6 +144,17 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & AuthConte } } + func tableViewCell( + _ cell: UITableViewCell, + statusView: StatusView, + cardControl: StatusCardControl, + didTapProfile account: Mastodon.Entity.Account + ) { + Task { + await DataSourceFacade.coordinateToProfileScene(provider:self, account: account) + } + } + func tableViewCell( _ cell: UITableViewCell, statusView: StatusView, diff --git a/Mastodon/Scene/Notification/NotificationView/NotificationView.swift b/Mastodon/Scene/Notification/NotificationView/NotificationView.swift index a947db916..341dd6e72 100644 --- a/Mastodon/Scene/Notification/NotificationView/NotificationView.swift +++ b/Mastodon/Scene/Notification/NotificationView/NotificationView.swift @@ -491,8 +491,9 @@ extension NotificationView { // MARK: - StatusViewDelegate extension NotificationView: StatusViewDelegate { - public func statusView(_ statusView: StatusView, didTapCardWithURL url: URL) { - assertionFailure() + public func statusView(_ statusView: StatusView, didTapCardWithURL url: URL) { assertionFailure() } + public func statusView(_ statusView: StatusView, cardControl: StatusCardControl, didTapProfile account: Mastodon.Entity.Account) { + // no op } public func statusView(_ statusView: StatusView, headerDidPressed header: UIView) { diff --git a/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCellDelegate.swift b/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCellDelegate.swift index d00e85486..2def593d5 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCellDelegate.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCellDelegate.swift @@ -40,6 +40,7 @@ protocol StatusTableViewCellDelegate: AnyObject, AutoGenerateProtocolDelegate { func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, statusMetricView: StatusMetricView, favoriteButtonDidPressed button: UIButton) func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, statusMetricView: StatusMetricView, showEditHistory button: UIButton) func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, cardControl: StatusCardControl, didTapURL url: URL) + func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, cardControl: StatusCardControl, didTapProfile account: Mastodon.Entity.Account) func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, cardControlMenu: StatusCardControl) -> [LabeledAction]? func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, accessibilityActivate: Void) // sourcery:end @@ -114,6 +115,10 @@ extension StatusViewDelegate where Self: StatusViewContainerTableViewCell { delegate?.tableViewCell(self, statusView: statusView, cardControl: cardControl, didTapURL: url) } + func statusView(_ statusView: StatusView, cardControl: StatusCardControl, didTapProfile account: Mastodon.Entity.Account) { + delegate?.tableViewCell(self, statusView: statusView, cardControl: cardControl, didTapProfile: account) + } + func statusView(_ statusView: StatusView, cardControlMenu: StatusCardControl) -> [LabeledAction]? { return delegate?.tableViewCell(self, statusView: statusView, cardControlMenu: cardControlMenu) } diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift index ead8d38e2..69c47f96f 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift @@ -35,6 +35,7 @@ public protocol StatusViewDelegate: AnyObject { func statusView(_ statusView: StatusView, statusMetricView: StatusMetricView, favoriteButtonDidPressed button: UIButton) func statusView(_ statusView: StatusView, statusMetricView: StatusMetricView, showEditHistory button: UIButton) func statusView(_ statusView: StatusView, cardControl: StatusCardControl, didTapURL url: URL) + func statusView(_ statusView: StatusView, cardControl: StatusCardControl, didTapProfile account: Mastodon.Entity.Account) func statusView(_ statusView: StatusView, cardControlMenu: StatusCardControl) -> [LabeledAction]? // a11y @@ -792,9 +793,7 @@ extension StatusView: MastodonMenuDelegate { // MARK: StatusCardControlDelegate extension StatusView: StatusCardControlDelegate { public func statusCardControl(_ statusCardControl: StatusCardControl, didTapAuthor author: Mastodon.Entity.Account) { - - //TODO: Profile to Author-profile - print("Show \(author.displayName)") + delegate?.statusView(self, cardControl: statusCardControl, didTapProfile: author) } public func statusCardControl(_ statusCardControl: StatusCardControl, didTapURL url: URL) {