mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-18 23:48:29 +02:00
Implement actions for a thread
This commit is contained in:
@@ -22,6 +22,11 @@ class ThreadViewController: RoomViewController {
|
||||
|
||||
private(set) var threadId: String!
|
||||
|
||||
private var permalink: String? {
|
||||
guard let threadId = threadId else { return nil }
|
||||
return MXTools.permalink(toEvent: threadId, inRoom: roomDataSource.roomId)
|
||||
}
|
||||
|
||||
class func instantiate(withThreadId threadId: String,
|
||||
configuration: RoomDisplayConfiguration) -> ThreadViewController {
|
||||
let threadVC = ThreadViewController.instantiate(with: configuration)
|
||||
@@ -44,4 +49,70 @@ class ThreadViewController: RoomViewController {
|
||||
threadTitleView.mode = .specificThread(threadId: threadId)
|
||||
}
|
||||
|
||||
override func onButtonPressed(_ sender: Any) {
|
||||
if let sender = sender as? UIBarButtonItem, sender == navigationItem.rightBarButtonItem {
|
||||
showThreadActions()
|
||||
return
|
||||
}
|
||||
super.onButtonPressed(sender)
|
||||
}
|
||||
|
||||
private func showThreadActions() {
|
||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
|
||||
let viewInRoomAction = UIAlertAction(title: VectorL10n.roomEventActionViewInRoom,
|
||||
style: .default,
|
||||
handler: { [weak self] action in
|
||||
guard let self = self else { return }
|
||||
self.delegate?.roomViewController(self,
|
||||
showRoomWithId: self.roomDataSource.roomId,
|
||||
eventId: self.threadId)
|
||||
})
|
||||
alertController.addAction(viewInRoomAction)
|
||||
|
||||
let copyLinkAction = UIAlertAction(title: VectorL10n.threadCopyLinkToThread,
|
||||
style: .default,
|
||||
handler: { [weak self] action in
|
||||
guard let self = self else { return }
|
||||
self.copyPermalink()
|
||||
})
|
||||
alertController.addAction(copyLinkAction)
|
||||
|
||||
let shareAction = UIAlertAction(title: VectorL10n.roomEventActionShare,
|
||||
style: .default,
|
||||
handler: { [weak self] action in
|
||||
guard let self = self else { return }
|
||||
self.sharePermalink()
|
||||
})
|
||||
alertController.addAction(shareAction)
|
||||
|
||||
alertController.addAction(UIAlertAction(title: VectorL10n.cancel,
|
||||
style: .cancel,
|
||||
handler: nil))
|
||||
|
||||
alertController.popoverPresentationController?.barButtonItem = navigationItem.rightBarButtonItem
|
||||
|
||||
self.present(alertController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
private func copyPermalink() {
|
||||
guard let permalink = permalink else {
|
||||
return
|
||||
}
|
||||
|
||||
MXKPasteboardManager.shared.pasteboard.string = permalink
|
||||
}
|
||||
|
||||
private func sharePermalink() {
|
||||
guard let permalink = permalink else {
|
||||
return
|
||||
}
|
||||
|
||||
let activityVC = UIActivityViewController(activityItems: [permalink],
|
||||
applicationActivities: nil)
|
||||
activityVC.modalTransitionStyle = .coverVertical
|
||||
activityVC.popoverPresentationController?.barButtonItem = navigationItem.rightBarButtonItem
|
||||
present(activityVC, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user