Implement toast messages when links are copied

This commit is contained in:
ismailgulek
2022-01-06 02:41:57 +03:00
parent c28af1644d
commit 471c69bdaa
6 changed files with 42 additions and 21 deletions
@@ -158,6 +158,8 @@ final class ThreadListViewController: UIViewController {
renderShowingLongPressActions()
case .share(let string):
renderShare(string)
case .toastForCopyLink:
toastForCopyLink()
case .error(let error):
render(error: error)
}
@@ -256,6 +258,11 @@ final class ThreadListViewController: UIViewController {
present(activityVC, animated: true, completion: nil)
}
private func toastForCopyLink() {
view.vc_toast(message: VectorL10n.roomEventCopyLinkInfo,
image: Asset.Images.linkIcon.image)
}
private func render(error: Error) {
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
self.errorPresenter.presentError(from: self, forError: error, animated: true, handler: nil)
@@ -295,6 +295,7 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
}
if let permalink = MXTools.permalink(toEvent: thread.id, inRoom: thread.roomId) {
MXKPasteboardManager.shared.pasteboard.string = permalink
viewState = .toastForCopyLink
}
longPressedThread = nil
}
@@ -27,5 +27,6 @@ enum ThreadListViewState {
case showingFilterTypes
case showingLongPressActions
case share(_ string: String)
case toastForCopyLink
case error(Error)
}