Files
letro-ios/ElementX/Sources/Screens/Authentication/StartScreen/AuthenticationStartScreenModels.swift
Doug 252e2f75df Verify Element X with an existing Element Classic account. (#5374)
* Read and import the secrets from ClassicAppAccounts.

* Record snapshots.

* Add some documentation, tidy up tests and fix the dismissal of the backup instructions.

* Workaround flakey tests (the fulfilments weren't always firing).

* Allow a custom Classic App deep link URL to be configured.
2026-04-13 15:30:09 +01:00

70 lines
1.9 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 SwiftUI
enum AuthenticationStartScreenViewModelAction: Equatable {
case loginWithQR
case login
case register
case reportProblem
case loginDirectlyWithOIDC(data: OIDCAuthorizationDataProxy, window: UIWindow)
case loginDirectlyWithPassword(loginHint: String?)
}
struct AuthenticationStartScreenViewState: BindableState {
/// The presentation anchor used for OIDC authentication.
var window: UIWindow?
let serverName: String?
let showCreateAccountButton: Bool
let showQRCodeLoginButton: Bool
enum ClassicAppMode { case welcomeBack(ClassicAppAccount), otherOptions(ClassicAppAccount) }
var classicAppMode: ClassicAppMode?
let hideBrandChrome: Bool
var bindings = AuthenticationStartScreenViewStateBindings()
var loginButtonTitle: String {
if let serverName {
L10n.screenOnboardingSignInTo(serverName)
} else if showQRCodeLoginButton {
L10n.screenOnboardingSignInManually
} else {
L10n.actionContinue
}
}
}
struct AuthenticationStartScreenViewStateBindings {
var alertInfo: AlertInfo<AuthenticationStartScreenAlertType>?
var showClassicAppBackupInstructions = false
}
enum AuthenticationStartScreenAlertType {
case genericError
}
enum AuthenticationStartScreenViewAction {
/// Updates the window used as the OIDC presentation anchor.
case updateWindow(UIWindow)
case loginWithQR
case login
case register
case reportProblem
case continueWithClassic(ClassicAppAccount)
case otherOptions(ClassicAppAccount)
case closeOtherOptions(ClassicAppAccount)
case openClassicApp
}