Files
letro-ios/ElementX/Sources/Screens/SecureBackup/SecureBackupRecoveryKeyScreen/SecureBackupRecoveryKeyScreenModels.swift
Mauro 6160c44d67 Update copyright holding and dates (#4640)
* Update copyright holding and dates

* compound IDE Macros updated

* update copyright

* update copyrights done

* update templates and README
2025-10-21 14:34:56 +02:00

88 lines
2.6 KiB
Swift

//
// Copyright 2025 Element Creations Ltd.
// Copyright 2022-2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Foundation
enum SecureBackupRecoveryKeyScreenViewModelAction {
case done(mode: SecureBackupRecoveryKeyScreenViewMode)
case cancel
}
enum SecureBackupRecoveryKeyScreenViewMode {
case setupRecovery
case changeRecovery
case fixRecovery
case unknown
}
struct SecureBackupRecoveryKeyScreenViewState: BindableState {
/// Whether the screen is presented modally or within a navigation stack.
var isModallyPresented: Bool
let mode: SecureBackupRecoveryKeyScreenViewMode
var recoveryKey: String?
var isGeneratingKey = false
var doneButtonEnabled = false
var bindings: SecureBackupRecoveryKeyScreenViewBindings
var title: String {
switch mode {
case .setupRecovery:
return recoveryKey == nil ? L10n.screenRecoveryKeySetupTitle : L10n.screenRecoveryKeySaveTitle
case .changeRecovery:
return recoveryKey == nil ? L10n.screenRecoveryKeyChangeTitle : L10n.screenRecoveryKeySaveTitle
case .fixRecovery:
return L10n.screenRecoveryKeyConfirmTitle
default:
return L10n.errorUnknown
}
}
var subtitle: String? {
switch mode {
case .setupRecovery:
return recoveryKey == nil ? L10n.screenRecoveryKeySetupDescription : L10n.screenRecoveryKeySaveDescription
case .changeRecovery:
return recoveryKey == nil ? L10n.screenRecoveryKeyChangeDescription : L10n.screenRecoveryKeySaveDescription
case .fixRecovery:
return L10n.screenRecoveryKeyConfirmDescription
default:
return nil
}
}
var recoveryKeySubtitle: String? {
switch mode {
case .setupRecovery:
return recoveryKey == nil ? L10n.screenRecoveryKeySetupGenerateKeyDescription : L10n.screenRecoveryKeySaveKeyDescription
case .changeRecovery:
return recoveryKey == nil ? L10n.screenRecoveryKeyChangeGenerateKeyDescription : L10n.screenRecoveryKeySaveKeyDescription
case .fixRecovery:
return L10n.screenRecoveryKeyConfirmKeyDescription
default:
return nil
}
}
}
struct SecureBackupRecoveryKeyScreenViewBindings {
var confirmationRecoveryKey = ""
var alertInfo: AlertInfo<UUID>?
}
enum SecureBackupRecoveryKeyScreenViewAction {
case generateKey
case copyKey
case keySaved
case confirmKey
case done
case cancel
}