Device Verification: Display the "The other party cancelled the verification." modal

This commit is contained in:
manuroe
2019-04-11 19:38:46 +02:00
parent 8e770cdb67
commit 69dcd25c8d
8 changed files with 38 additions and 10 deletions
@@ -157,7 +157,9 @@ final class DeviceVerificationStartViewController: UIViewController {
case .loading:
self.renderLoading()
case .loaded:
self.renderLoaded()
self.renderStarted()
case .cancelled(let reason):
self.renderCancelled(reason: reason)
case .error(let error):
self.render(error: error)
}
@@ -167,13 +169,21 @@ final class DeviceVerificationStartViewController: UIViewController {
self.activityPresenter.presentActivityIndicator(on: self.view, animated: true)
}
private func renderLoaded() {
private func renderStarted() {
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
self.verifyButtonBackgroundView.isHidden = true
self.waitingPartnerLabel.isHidden = false
self.useLegacyVerificationLabel.isHidden = false
}
private func renderCancelled(reason: MXTransactionCancelCode) {
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
self.errorPresenter.presentError(from: self, title: "", message: VectorL10n.deviceVerificationCancelled, animated: true) {
self.viewModel.process(viewAction: .cancel)
}
}
private func render(error: Error) {
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
@@ -114,7 +114,10 @@ final class DeviceVerificationStartViewModel: DeviceVerificationStartViewModelTy
case MXSASTransactionStateShowSAS:
self.coordinatorDelegate?.deviceVerificationStartViewModel(self, didCompleteWithOutgoingTransaction: transaction)
case MXSASTransactionStateCancelled:
self.coordinatorDelegate?.deviceVerificationStartViewModel(self, didTransactionCancelled: transaction)
guard let reason = transaction.reasonCancelCode else {
return
}
self.update(viewState: .cancelled(reason))
default:
break
}
@@ -21,6 +21,7 @@ import Foundation
/// DeviceVerificationStartViewController view state
enum DeviceVerificationStartViewState {
case loading
case loaded
case loaded // started
case cancelled(MXTransactionCancelCode)
case error(Error)
}