     func settingsKeyBackup(_ settingsKeyBackupTableViewSection: SettingsKeyBackupTableViewSection, showError error: Error)
 }
 
+private enum BackupRows {
+    case info(text: String)
+    case createAction
+    case restoreAction(keyBackupVersion: MXKeyBackupVersion)
+    case deleteAction(keyBackupVersion: MXKeyBackupVersion)
+}
+
 @objc final class SettingsKeyBackupTableViewSection: NSObject {
 
     // MARK: - Properties


        self.viewModel.process(viewAction: .load)
    }

    @objc func numberOfRows() -> Int {
        var numberOfRows: Int

        switch self.viewState {
        case .checkingBackup:
            numberOfRows = self.numberOfCheckingBackupRows()
        case .noBackup:
            numberOfRows = self.numberOfNoBackupRows()
        case .backup:
            numberOfRows = self.numberOfBackupRows()
        case .backupAndRunning:
            numberOfRows = self.numberOfBackupAndRunningRows()
        case .backupNotTrusted:
            numberOfRows = self.numberOfBackupNotTrustedRows()
        }

        return numberOfRows
    }

    @objc func cellForRow(atRow row: Int) -> UITableViewCell {
        var cell: UITableViewCell

        switch self.viewState {
        case .checkingBackup:
            cell = self.renderCheckingBackupCell(atRow: row)

        case .noBackup:
            cell = self.renderNoBackupCell(atRow: row)

        case .backup(let keyBackupVersion, let keyBackupVersionTrust):
            cell = self.renderBackupCell(atRow: row,
                                         keyBackupVersion: keyBackupVersion,
                                         keyBackupVersionTrust: keyBackupVersionTrust)

        case .backupAndRunning(let keyBackupVersion, let keyBackupVersionTrust, let backupProgress):
            cell = self.renderBackupAndRunningCell(atRow: row,
                                                   keyBackupVersion: keyBackupVersion,
                                                   keyBackupVersionTrust: keyBackupVersionTrust,
                                                   backupProgress: backupProgress)

        case .backupNotTrusted(let keyBackupVersion, let keyBackupVersionTrust):
            cell = self.renderBackupNotTrustedCell(atRow: row,
                                                   keyBackupVersion: keyBackupVersion,
                                                   keyBackupVersionTrust: keyBackupVersionTrust)
        }

        return cell
    }

    @objc func reload() {
        self.viewModel.process(viewAction: .load)
    }

    @objc func delete(keyBackupVersion: MXKeyBackupVersion) {
        self.viewModel.process(viewAction: .delete(keyBackupVersion))
    }


    // MARK: - Pseudo TableView datasource

    private func numberOfCheckingBackupRows() -> Int {
        return 1
    }

    private func renderCheckingBackupCell(atRow row: Int) -> UITableViewCell {
        guard let delegate = self.delegate else {
            return UITableViewCell()
        }

        let cell: MXKTableViewCellWithTextView = delegate.settingsKeyBackupTableViewSection(self, textCellForRow: row)

        let info = VectorL10n.settingsKeyBackupInfo
        let checking = VectorL10n.settingsKeyBackupInfoChecking

        let strings = [info, "", checking]
        cell.mxkTextView.text = strings.joined(separator: "\n")

        return cell
    }


    private func numberOfNoBackupRows() -> Int {
        return 2
    }

    private func renderNoBackupCell(atRow row: Int) -> UITableViewCell {
        guard let delegate = self.delegate else {
            return UITableViewCell()
        }

        var cell: UITableViewCell
        switch row {
        case 0:
            let infoCell: MXKTableViewCellWithTextView = delegate.settingsKeyBackupTableViewSection(self, textCellForRow: row)

            let noBackup = VectorL10n.settingsKeyBackupInfoNone
            let info = VectorL10n.settingsKeyBackupInfo
            let signoutWarning = VectorL10n.settingsKeyBackupInfoSignoutWarning

            let strings = [noBackup, "", info, "", signoutWarning]
            infoCell.mxkTextView.text = strings.joined(separator: "\n")

            cell = infoCell

        case 1:
            cell = self.buttonCellForCreate(atRow: row)

        default:
            cell = UITableViewCell()
        }

        return cell
    }


    private func numberOfBackupRows() -> Int {
        return 5
    }

    private func renderBackupCell(atRow row: Int, keyBackupVersion: MXKeyBackupVersion, keyBackupVersionTrust: MXKeyBackupVersionTrust) -> UITableViewCell {
        guard let delegate = self.delegate else {
            return UITableViewCell()
        }

        var cell: UITableViewCell
        switch row {
        case 0:
            let infoCell: MXKTableViewCellWithTextView = delegate.settingsKeyBackupTableViewSection(self, textCellForRow: row)

            let info = VectorL10n.settingsKeyBackupInfo
            let backupStatus = VectorL10n.settingsKeyBackupInfoValid

            let strings = [info, "", backupStatus]
            infoCell.mxkTextView.text = strings.joined(separator: "\n")

            cell = infoCell

        case 1:
            let infoCell: MXKTableViewCellWithTextView = delegate.settingsKeyBackupTableViewSection(self, textCellForRow: row)

            let version = VectorL10n.settingsKeyBackupInfoVersion(keyBackupVersion.version ?? "")
            let algorithm = VectorL10n.settingsKeyBackupInfoAlgorithm(keyBackupVersion.algorithm)
            let uploadStatus = VectorL10n.settingsKeyBackupInfoProgressDone

            let strings = [version, algorithm, uploadStatus]
            infoCell.mxkTextView.text = strings.joined(separator: "\n")

            cell = infoCell

        case 2:
            let infoCell: MXKTableViewCellWithTextView = delegate.settingsKeyBackupTableViewSection(self, textCellForRow: row)

            let backupTrust = self.stringForKeyBackupTrust(keyBackupVersionTrust)
            infoCell.mxkTextView.text = backupTrust.joined(separator: "\n")

            cell = infoCell

        case 3:
            cell = self.buttonCellForRestore(keyBackupVersion: keyBackupVersion, atRow: row)

        case 4:
            cell = self.buttonCellForDelete(keyBackupVersion: keyBackupVersion, atRow: row)

        default:
            cell = UITableViewCell()
        }

        return cell
    }


    private func numberOfBackupAndRunningRows() -> Int {
        return 5
    }

    private func renderBackupAndRunningCell(atRow row: Int, keyBackupVersion: MXKeyBackupVersion, keyBackupVersionTrust: MXKeyBackupVersionTrust, backupProgress: Progress) -> UITableViewCell {
        guard let delegate = self.delegate else {
            return UITableViewCell()
        }

        var cell: UITableViewCell
        switch row {
        case 0:
            let infoCell: MXKTableViewCellWithTextView = delegate.settingsKeyBackupTableViewSection(self, textCellForRow: 0)

            let info = VectorL10n.settingsKeyBackupInfo
            let backupStatus = VectorL10n.settingsKeyBackupInfoValid

            let strings = [info, "", backupStatus]
            infoCell.mxkTextView.text = strings.joined(separator: "\n")

            cell = infoCell

        case 1:
            let infoCell: MXKTableViewCellWithTextView = delegate.settingsKeyBackupTableViewSection(self, textCellForRow: row)

            let remaining = backupProgress.totalUnitCount - backupProgress.completedUnitCount

            let version = VectorL10n.settingsKeyBackupInfoVersion(keyBackupVersion.version ?? "")
            let algorithm = VectorL10n.settingsKeyBackupInfoAlgorithm(keyBackupVersion.algorithm)
            let uploadStatus = VectorL10n.settingsKeyBackupInfoProgress(String(remaining))

            let strings = [version, algorithm, uploadStatus]
            infoCell.mxkTextView.text = strings.joined(separator: "\n")

            cell = infoCell

        case 2:
            let infoCell: MXKTableViewCellWithTextView = delegate.settingsKeyBackupTableViewSection(self, textCellForRow: row)

            let backupTrust = self.stringForKeyBackupTrust(keyBackupVersionTrust)
            infoCell.mxkTextView.text = backupTrust.joined(separator: "\n")

            cell = infoCell

        case 3:
            cell = self.buttonCellForRestore(keyBackupVersion: keyBackupVersion, atRow: row)

        case 4:
            cell = self.buttonCellForDelete(keyBackupVersion: keyBackupVersion, atRow: row)

        default:
            cell = UITableViewCell()
        }

        return cell
    }


    private func numberOfBackupNotTrustedRows() -> Int {
        return 5
    }

    private func renderBackupNotTrustedCell(atRow row: Int, keyBackupVersion: MXKeyBackupVersion, keyBackupVersionTrust: MXKeyBackupVersionTrust) -> UITableViewCell {
        guard let delegate = self.delegate else {
            return UITableViewCell()
        }

        var cell: UITableViewCell
        switch row {
        case 0:
            let infoCell: MXKTableViewCellWithTextView = delegate.settingsKeyBackupTableViewSection(self, textCellForRow: row)

            let info = VectorL10n.settingsKeyBackupInfo
            let backupStatus = VectorL10n.settingsKeyBackupInfoNotValid
            let signoutWarning = VectorL10n.settingsKeyBackupInfoSignoutWarning

            let strings = [info, "", backupStatus, "", signoutWarning]
            infoCell.mxkTextView.text = strings.joined(separator: "\n")

            cell = infoCell

        case 1:
            let infoCell: MXKTableViewCellWithTextView = delegate.settingsKeyBackupTableViewSection(self, textCellForRow: row)

            let version = VectorL10n.settingsKeyBackupInfoVersion(keyBackupVersion.version ?? "")
            let algorithm = VectorL10n.settingsKeyBackupInfoAlgorithm(keyBackupVersion.algorithm)

            let strings = [version, algorithm]
            infoCell.mxkTextView.text = strings.joined(separator: "\n")

            cell = infoCell

        case 2:
            let infoCell: MXKTableViewCellWithTextView = delegate.settingsKeyBackupTableViewSection(self, textCellForRow: row)

            let backupTrust = self.stringForKeyBackupTrust(keyBackupVersionTrust)
            infoCell.mxkTextView.text = backupTrust.joined(separator: "\n")

            cell = infoCell

        case 3:
            cell = self.buttonCellForRestore(keyBackupVersion: keyBackupVersion, atRow: row, title: VectorL10n.settingsKeyBackupButtonUse)

        case 4:
            cell = self.buttonCellForDelete(keyBackupVersion: keyBackupVersion, atRow: row)

        default:
            cell = UITableViewCell()
        }

        return cell
    }


    // MARK: - Data Computing

    private func stringForKeyBackupTrust(_ keyBackupVersionTrust: MXKeyBackupVersionTrust) -> [String] {


    private var viewModel: SettingsKeyBackupViewModelType!

    // Need to know the state to make `cellForRow` deliver cells accordingly
    private var viewState: SettingsKeyBackupViewState = .checkingBackup {
        didSet {
            self.updateBackupRows()
        }
    }

    private var userDevice: MXDeviceInfo
    
    private var backupRows: [BackupRows] = []

    // MARK: - Public

