Cleanup TuskerNavigationDelegate
This commit is contained in:
parent
dac1e1fe3f
commit
9f0176350c
|
@ -12,8 +12,6 @@ import Pachyderm
|
|||
|
||||
protocol TuskerNavigationDelegate: UIViewController, ToastableViewController {
|
||||
var apiController: MastodonController! { get }
|
||||
|
||||
func conversation(mainStatusID: String, state: CollapseState) -> ConversationViewController
|
||||
}
|
||||
|
||||
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) {
|
||||
self.selected(status: statusID, state: .unknown)
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -119,15 +113,11 @@ extension TuskerNavigationDelegate {
|
|||
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)
|
||||
vc.animationSourceView = sourceView
|
||||
vc.transitioningDelegate = self
|
||||
return vc
|
||||
}
|
||||
|
||||
func showLoadingLargeImage(url: URL, cache: ImageCache, description: String?, animatingFrom sourceView: UIImageView) {
|
||||
present(loadingLargeImage(url: url, cache: cache, description: description, animatingFrom: sourceView), animated: true)
|
||||
present(vc, animated: true)
|
||||
}
|
||||
|
||||
func gallery(attachments: [Attachment], sourceViews: [UIImageView?], startIndex: Int) -> GalleryViewController {
|
||||
|
@ -183,16 +173,6 @@ extension TuskerNavigationDelegate {
|
|||
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 {
|
||||
|
|
|
@ -263,7 +263,7 @@ extension ActionNotificationGroupTableViewCell: SelectableTableViewCell {
|
|||
default:
|
||||
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
|
||||
delegate.show(vc)
|
||||
}
|
||||
|
@ -272,9 +272,6 @@ extension ActionNotificationGroupTableViewCell: SelectableTableViewCell {
|
|||
extension ActionNotificationGroupTableViewCell: MenuPreviewProvider {
|
||||
func getPreviewProviders(for location: CGPoint, sourceViewController: UIViewController) -> PreviewProviders? {
|
||||
return (content: {
|
||||
guard let delegate = self.delegate else {
|
||||
return nil
|
||||
}
|
||||
let notifications = self.group.notifications
|
||||
let accountIDs = notifications.map { $0.account.id }
|
||||
let action: StatusActionAccountListViewController.ActionType
|
||||
|
@ -286,7 +283,7 @@ extension ActionNotificationGroupTableViewCell: MenuPreviewProvider {
|
|||
default:
|
||||
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
|
||||
return vc
|
||||
}, actions: {
|
||||
|
|
|
@ -213,7 +213,9 @@ extension FollowNotificationGroupTableViewCell: SelectableTableViewCell {
|
|||
case 1:
|
||||
delegate?.selected(account: accountIDs.first!)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,8 +120,7 @@ extension PollFinishedTableViewCell: SelectableTableViewCell {
|
|||
let status = notification?.status else {
|
||||
return
|
||||
}
|
||||
let vc = delegate.conversation(mainStatusID: status.id, state: .unknown)
|
||||
delegate.show(vc)
|
||||
delegate.selected(status: status.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,7 +132,7 @@ extension PollFinishedTableViewCell: MenuPreviewProvider {
|
|||
return nil
|
||||
}
|
||||
return (content: {
|
||||
delegate.conversation(mainStatusID: statusID, state: .unknown)
|
||||
ConversationViewController(for: statusID, state: .unknown, mastodonController: delegate.apiController)
|
||||
}, actions: {
|
||||
delegate.actionsForStatus(status, source: .view(self))
|
||||
})
|
||||
|
|
|
@ -109,8 +109,7 @@ extension StatusUpdatedNotificationTableViewCell: SelectableTableViewCell {
|
|||
let status = notification?.status else {
|
||||
return
|
||||
}
|
||||
let vc = delegate.conversation(mainStatusID: status.id, state: .unknown)
|
||||
delegate.show(vc)
|
||||
delegate.selected(status: status.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +121,7 @@ extension StatusUpdatedNotificationTableViewCell: MenuPreviewProvider {
|
|||
return nil
|
||||
}
|
||||
return (content: {
|
||||
delegate.conversation(mainStatusID: statusID, state: .unknown)
|
||||
ConversationViewController(for: statusID, state: .unknown, mastodonController: delegate.apiController)
|
||||
}, actions: {
|
||||
delegate.actionsForStatus(status, source: .view(self))
|
||||
})
|
||||
|
|
|
@ -410,7 +410,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
|
|||
guard let delegate else {
|
||||
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
|
||||
vc.showInacurateCountWarning = true
|
||||
delegate.show(vc)
|
||||
|
@ -420,7 +420,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
|
|||
guard let delegate else {
|
||||
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
|
||||
delegate.show(vc)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue