From 8723921cec68cf353e7ca7011996a7e5274daf9b Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 6 Sep 2019 17:56:45 -0400 Subject: [PATCH] Add context menu for status action notifications --- Tusker/Screens/Utilities/Previewing.swift | 7 +++++++ .../ActionNotificationGroupTableViewCell.swift | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Utilities/Previewing.swift b/Tusker/Screens/Utilities/Previewing.swift index 1bd95e2e95..ff15df8c82 100644 --- a/Tusker/Screens/Utilities/Previewing.swift +++ b/Tusker/Screens/Utilities/Previewing.swift @@ -69,6 +69,13 @@ extension MenuPreviewProvider { ] } + func actionsForNotificationGroup(_ group: NotificationGroup) -> [UIAction] { +// let notifications = group.notificationIDs.compactMap(MastodonCache.notification(for:)) + return [ + // todo: clear notifications option + ] + } + private func createAction(identifier: String, title: String, systemImageName: String, handler: @escaping UIActionHandler) -> UIAction { return UIAction(title: title, image: UIImage(systemName: systemImageName), identifier: UIAction.Identifier(identifier), discoverabilityTitle: nil, attributes: [], state: .off, handler: handler) } diff --git a/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift b/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift index 1fbcfffbcb..4f98d00581 100644 --- a/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift +++ b/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift @@ -155,9 +155,22 @@ class ActionNotificationGroupTableViewCell: UITableViewCell { if selected { let notifications = group.notificationIDs.compactMap(MastodonCache.notification(for:)) - let accountIDs = notifications.compactMap { $0.account.id } + let accountIDs = notifications.map { $0.account.id } delegate?.showStatusActionAccountList(statusID: statusID, accountIDs: accountIDs, action: notifications.first!.kind) } } - + +} + +extension ActionNotificationGroupTableViewCell: MenuPreviewProvider { + + func getPreviewProviders(for location: CGPoint, sourceViewController: UIViewController) -> PreviewProviders? { + return (content: { + let accountIDs = self.group.notificationIDs.compactMap(MastodonCache.notification(for:)).map { $0.account.id } + return StatusActionAccountListTableViewController(statusID: self.statusID, accountIDs: accountIDs) + }, actions: { + return self.actionsForNotificationGroup(self.group) + }) + } + }