-
-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff48cc2
commit f3c035c
Showing
7 changed files
with
128 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
... Filtering/Requests/Account Notifications/AccountNotificationTimelineViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright © 2024 Mastodon gGmbH. All rights reserved. | ||
|
||
import UIKit | ||
import MastodonCore | ||
import MastodonSDK | ||
|
||
protocol AccountNotificationTimelineViewControllerDelegate: AnyObject { | ||
func acceptRequest(_ viewController: AccountNotificationTimelineViewController, request: Mastodon.Entity.NotificationRequest, completion: @escaping (() -> Void)) | ||
func dismissRequest(_ viewController: AccountNotificationTimelineViewController, request: Mastodon.Entity.NotificationRequest, completion: @escaping (() -> Void)) | ||
} | ||
|
||
class AccountNotificationTimelineViewController: NotificationTimelineViewController { | ||
|
||
let request: Mastodon.Entity.NotificationRequest | ||
weak var delegate: AccountNotificationTimelineViewControllerDelegate? | ||
|
||
init(viewModel: NotificationTimelineViewModel, context: AppContext, coordinator: SceneCoordinator, notificationRequest: Mastodon.Entity.NotificationRequest) { | ||
self.request = notificationRequest | ||
|
||
super.init(viewModel: viewModel, context: context, coordinator: coordinator) | ||
|
||
navigationItem.rightBarButtonItem = UIBarButtonItem(title: nil, image: UIImage(systemName: "ellipsis.circle"), target: nil, action: nil, menu: menu()) | ||
} | ||
|
||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } | ||
|
||
// MARK: - Actions | ||
|
||
//TODO: Localization | ||
func menu() -> UIMenu { | ||
let menu = UIMenu(children: [ | ||
UIAction(title: "Accept", image: UIImage(systemName: "checkmark")) { [weak self] _ in | ||
guard let self else { return } | ||
|
||
coordinator.showLoading() | ||
self.delegate?.acceptRequest(self, request: request) { | ||
self.navigationController?.popViewController(animated: true) | ||
} | ||
coordinator.hideLoading() | ||
}, | ||
UIAction(title: "Dismiss", image: UIImage(systemName: "speaker.slash")) { [weak self] _ in | ||
guard let self else { return } | ||
|
||
coordinator.showLoading() | ||
self.delegate?.dismissRequest(self, request: request) { | ||
self.navigationController?.popViewController(animated: true) | ||
} | ||
coordinator.hideLoading() | ||
} | ||
]) | ||
|
||
return menu | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters