Device Verification: Plug the legacy verification modal

This commit is contained in:
manuroe
2019-04-16 15:00:57 +02:00
parent 645736e12d
commit 82927fa7a7
5 changed files with 41 additions and 5 deletions
@@ -158,6 +158,8 @@ final class DeviceVerificationStartViewController: UIViewController {
self.renderLoading()
case .loaded:
self.renderStarted()
case .verifyUsingLegacy(let session, let deviceInfo):
self.renderVerifyUsingLegacy(session: session, deviceInfo: deviceInfo)
case .cancelled(let reason):
self.renderCancelled(reason: reason)
case .error(let error):
@@ -177,6 +179,24 @@ final class DeviceVerificationStartViewController: UIViewController {
self.useLegacyVerificationLabel.isHidden = false
}
private func renderVerifyUsingLegacy(session: MXSession, deviceInfo: MXDeviceInfo) {
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
guard let encryptionInfoView = EncryptionInfoView(deviceInfo: deviceInfo, andMatrixSession: session) else {
return
}
encryptionInfoView.delegate = self
// Skip the intro page
encryptionInfoView.onButtonPressed(encryptionInfoView.verifyButton)
// Display the legacy verification view in full screen
// TODO: Do not reuse the legacy EncryptionInfoView and create a screen from scratch
self.view.vc_addSubViewMatchingParent(encryptionInfoView)
self.navigationController?.isNavigationBarHidden = true
}
private func renderCancelled(reason: MXTransactionCancelCode) {
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
@@ -198,7 +218,7 @@ final class DeviceVerificationStartViewController: UIViewController {
}
@IBAction private func useLegacyVerificationButtonAction(_ sender: Any) {
self.viewModel.process(viewAction: .useLegacyVerification)
self.viewModel.process(viewAction: .verifyUsingLegacy)
}
private func cancelButtonAction() {
@@ -214,3 +234,14 @@ extension DeviceVerificationStartViewController: DeviceVerificationStartViewMode
self.render(viewState: viewSate)
}
}
// MARK: - DeviceVerificationStartViewModelViewDelegate
extension DeviceVerificationStartViewController: MXKEncryptionInfoViewDelegate {
func encryptionInfoView(_ encryptionInfoView: MXKEncryptionInfoView!, didDeviceInfoVerifiedChange deviceInfo: MXDeviceInfo!) {
self.viewModel.process(viewAction: .verifiedUsingLegacy)
}
func encryptionInfoViewDidClose(_ encryptionInfoView: MXKEncryptionInfoView!) {
self.viewModel.process(viewAction: .cancel)
}
}