Files
element-x-ios/ElementX/Sources/Screens/Authentication/StartScreen/AuthenticationStartScreenModels.swift
T
Doug 64aae09c6d Add an AccountProvider type and use it within the authentication flow. (#6103)
* Add an AccountProvider type and use it within AppSettings.

* Use the AccountProvider type within the Authentication flow too.

* Fix unit test compilation with Swift 6.4

* Make sure defaultAccountProvider takes allowOtherAccountProviders into account.

* Document a caveat on using AuthenticationService.homeserver.value.accountProvider.
2026-09-14 15:25:33 +01:00

73 lines
2.0 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 loginDirectlyWithOAuth(data: OAuthAuthorizationDataProxy, window: UIWindow)
case loginDirectlyWithPassword(loginHint: String?)
case reportProblem
case developerOptions
}
struct AuthenticationStartScreenViewState: BindableState {
/// The presentation anchor used for OAuth authentication.
var window: UIWindow?
let serverNameOrBaseURL: 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 serverNameOrBaseURL {
L10n.screenOnboardingSignInTo(serverNameOrBaseURL)
} 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 OAuth presentation anchor.
case updateWindow(UIWindow)
case developerOptions
case reportProblem
case loginWithQR
case login
case register
case continueWithClassic(ClassicAppAccount)
case otherOptions(ClassicAppAccount)
case closeOtherOptions(ClassicAppAccount)
case openClassicApp
}