Cleanup TuskerNavigationDelegate

This commit is contained in:
Shadowfacts 2023-02-06 18:10:38 -05:00
parent dac1e1fe3f
commit 9f0176350c
6 changed files with 14 additions and 37 deletions

View File

@ -12,8 +12,6 @@ import Pachyderm
protocol TuskerNavigationDelegate: UIViewController, ToastableViewController { protocol TuskerNavigationDelegate: UIViewController, ToastableViewController {
var apiController: MastodonController! { get } var apiController: MastodonController! { get }
func conversation(mainStatusID: String, state: CollapseState) -> ConversationViewController
} }
extension TuskerNavigationDelegate { extension TuskerNavigationDelegate {
@ -82,16 +80,12 @@ extension TuskerNavigationDelegate {
} }
} }
func conversation(mainStatusID: String, state: CollapseState) -> ConversationViewController {
return ConversationViewController(for: mainStatusID, state: state, mastodonController: apiController)
}
func selected(status statusID: String) { func selected(status statusID: String) {
self.selected(status: statusID, state: .unknown) self.selected(status: statusID, state: .unknown)
} }
func selected(status statusID: String, state: CollapseState) { func selected(status statusID: String, state: CollapseState) {
show(conversation(mainStatusID: statusID, state: state), sender: self) show(ConversationViewController(for: statusID, state: state, mastodonController: apiController), sender: self)
} }
func compose(editing draft: Draft, animated: Bool = true) { func compose(editing draft: Draft, animated: Bool = true) {
@ -119,15 +113,11 @@ extension TuskerNavigationDelegate {
compose(editing: draft, animated: animated) compose(editing: draft, animated: animated)
} }
func loadingLargeImage(url: URL, cache: ImageCache, description: String?, animatingFrom sourceView: UIImageView) -> LoadingLargeImageViewController { func showLoadingLargeImage(url: URL, cache: ImageCache, description: String?, animatingFrom sourceView: UIImageView) {
let vc = LoadingLargeImageViewController(url: url, cache: cache, imageDescription: description) let vc = LoadingLargeImageViewController(url: url, cache: cache, imageDescription: description)
vc.animationSourceView = sourceView vc.animationSourceView = sourceView
vc.transitioningDelegate = self vc.transitioningDelegate = self
return vc present(vc, animated: true)
}
func showLoadingLargeImage(url: URL, cache: ImageCache, description: String?, animatingFrom sourceView: UIImageView) {
present(loadingLargeImage(url: url, cache: cache, description: description, animatingFrom: sourceView), animated: true)
} }
func gallery(attachments: [Attachment], sourceViews: [UIImageView?], startIndex: Int) -> GalleryViewController { func gallery(attachments: [Attachment], sourceViews: [UIImageView?], startIndex: Int) -> GalleryViewController {
@ -183,16 +173,6 @@ extension TuskerNavigationDelegate {
present(vc, animated: true) present(vc, animated: true)
} }
func showFollowedByList(accountIDs: [String]) {
let vc = AccountListViewController(accountIDs: accountIDs, mastodonController: apiController)
vc.title = NSLocalizedString("Followed By", comment: "followed by accounts list title")
show(vc, sender: self)
}
func statusActionAccountList(action: StatusActionAccountListViewController.ActionType, statusID: String, statusState state: CollapseState, accountIDs: [String]?) -> StatusActionAccountListViewController {
return StatusActionAccountListViewController(actionType: action, statusID: statusID, statusState: state, accountIDs: accountIDs, mastodonController: apiController)
}
} }
enum PopoverSource { enum PopoverSource {

View File

@ -263,7 +263,7 @@ extension ActionNotificationGroupTableViewCell: SelectableTableViewCell {
default: default:
fatalError() fatalError()
} }
let vc = delegate.statusActionAccountList(action: action, statusID: statusID, statusState: .unknown, accountIDs: accountIDs) let vc = StatusActionAccountListViewController(actionType: action, statusID: statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: mastodonController)
vc.showInacurateCountWarning = false vc.showInacurateCountWarning = false
delegate.show(vc) delegate.show(vc)
} }
@ -272,9 +272,6 @@ extension ActionNotificationGroupTableViewCell: SelectableTableViewCell {
extension ActionNotificationGroupTableViewCell: MenuPreviewProvider { extension ActionNotificationGroupTableViewCell: MenuPreviewProvider {
func getPreviewProviders(for location: CGPoint, sourceViewController: UIViewController) -> PreviewProviders? { func getPreviewProviders(for location: CGPoint, sourceViewController: UIViewController) -> PreviewProviders? {
return (content: { return (content: {
guard let delegate = self.delegate else {
return nil
}
let notifications = self.group.notifications let notifications = self.group.notifications
let accountIDs = notifications.map { $0.account.id } let accountIDs = notifications.map { $0.account.id }
let action: StatusActionAccountListViewController.ActionType let action: StatusActionAccountListViewController.ActionType
@ -286,7 +283,7 @@ extension ActionNotificationGroupTableViewCell: MenuPreviewProvider {
default: default:
fatalError() fatalError()
} }
let vc = delegate.statusActionAccountList(action: action, statusID: self.statusID, statusState: .unknown, accountIDs: accountIDs) let vc = StatusActionAccountListViewController(actionType: action, statusID: self.statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: self.mastodonController)
vc.showInacurateCountWarning = false vc.showInacurateCountWarning = false
return vc return vc
}, actions: { }, actions: {

View File

@ -213,7 +213,9 @@ extension FollowNotificationGroupTableViewCell: SelectableTableViewCell {
case 1: case 1:
delegate?.selected(account: accountIDs.first!) delegate?.selected(account: accountIDs.first!)
default: default:
delegate?.showFollowedByList(accountIDs: accountIDs) let vc = AccountListViewController(accountIDs: accountIDs, mastodonController: mastodonController)
vc.title = NSLocalizedString("Followed By", comment: "followed by accounts list title")
delegate?.show(vc)
} }
} }
} }

View File

@ -120,8 +120,7 @@ extension PollFinishedTableViewCell: SelectableTableViewCell {
let status = notification?.status else { let status = notification?.status else {
return return
} }
let vc = delegate.conversation(mainStatusID: status.id, state: .unknown) delegate.selected(status: status.id)
delegate.show(vc)
} }
} }
@ -133,7 +132,7 @@ extension PollFinishedTableViewCell: MenuPreviewProvider {
return nil return nil
} }
return (content: { return (content: {
delegate.conversation(mainStatusID: statusID, state: .unknown) ConversationViewController(for: statusID, state: .unknown, mastodonController: delegate.apiController)
}, actions: { }, actions: {
delegate.actionsForStatus(status, source: .view(self)) delegate.actionsForStatus(status, source: .view(self))
}) })

View File

@ -109,8 +109,7 @@ extension StatusUpdatedNotificationTableViewCell: SelectableTableViewCell {
let status = notification?.status else { let status = notification?.status else {
return return
} }
let vc = delegate.conversation(mainStatusID: status.id, state: .unknown) delegate.selected(status: status.id)
delegate.show(vc)
} }
} }
@ -122,7 +121,7 @@ extension StatusUpdatedNotificationTableViewCell: MenuPreviewProvider {
return nil return nil
} }
return (content: { return (content: {
delegate.conversation(mainStatusID: statusID, state: .unknown) ConversationViewController(for: statusID, state: .unknown, mastodonController: delegate.apiController)
}, actions: { }, actions: {
delegate.actionsForStatus(status, source: .view(self)) delegate.actionsForStatus(status, source: .view(self))
}) })

View File

@ -410,7 +410,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
guard let delegate else { guard let delegate else {
return return
} }
let vc = delegate.statusActionAccountList(action: .favorite, statusID: statusID, statusState: statusState.copy(), accountIDs: nil) let vc = StatusActionAccountListViewController(actionType: .favorite, statusID: statusID, statusState: statusState.copy(), accountIDs: nil, mastodonController: mastodonController)
// TODO: only show warning if the instance isn't the logged in one // TODO: only show warning if the instance isn't the logged in one
vc.showInacurateCountWarning = true vc.showInacurateCountWarning = true
delegate.show(vc) delegate.show(vc)
@ -420,7 +420,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
guard let delegate else { guard let delegate else {
return return
} }
let vc = delegate.statusActionAccountList(action: .reblog, statusID: statusID, statusState: statusState.copy(), accountIDs: nil) let vc = StatusActionAccountListViewController(actionType: .favorite, statusID: statusID, statusState: statusState.copy(), accountIDs: nil, mastodonController: mastodonController)
vc.showInacurateCountWarning = true vc.showInacurateCountWarning = true
delegate.show(vc) delegate.show(vc)
} }