mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Allow registration on matrix.org using a custom helper URL. (#3282)
This commit is contained in:
+8
-2
@@ -8,6 +8,10 @@
|
||||
import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct AuthenticationStartScreenParameters {
|
||||
let webRegistrationEnabled: Bool
|
||||
}
|
||||
|
||||
final class AuthenticationStartScreenCoordinator: CoordinatorProtocol {
|
||||
private var viewModel: AuthenticationStartScreenViewModelProtocol
|
||||
private let actionsSubject: PassthroughSubject<AuthenticationStartScreenCoordinatorAction, Never> = .init()
|
||||
@@ -17,8 +21,8 @@ final class AuthenticationStartScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init() {
|
||||
viewModel = AuthenticationStartScreenViewModel()
|
||||
init(parameters: AuthenticationStartScreenParameters) {
|
||||
viewModel = AuthenticationStartScreenViewModel(webRegistrationEnabled: parameters.webRegistrationEnabled)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
@@ -33,6 +37,8 @@ final class AuthenticationStartScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.send(.loginManually)
|
||||
case .loginWithQR:
|
||||
actionsSubject.send(.loginWithQR)
|
||||
case .register:
|
||||
actionsSubject.send(.register)
|
||||
case .reportProblem:
|
||||
actionsSubject.send(.reportProblem)
|
||||
}
|
||||
|
||||
+5
-1
@@ -12,21 +12,25 @@ import SwiftUI
|
||||
enum AuthenticationStartScreenCoordinatorAction {
|
||||
case loginManually
|
||||
case loginWithQR
|
||||
case register
|
||||
case reportProblem
|
||||
}
|
||||
|
||||
enum AuthenticationStartScreenViewModelAction {
|
||||
case loginManually
|
||||
case loginWithQR
|
||||
case register
|
||||
case reportProblem
|
||||
}
|
||||
|
||||
struct AuthenticationStartScreenViewState: BindableState {
|
||||
var isQRCodeLoginEnabled = false
|
||||
let isWebRegistrationEnabled: Bool
|
||||
let isQRCodeLoginEnabled: Bool
|
||||
}
|
||||
|
||||
enum AuthenticationStartScreenViewAction {
|
||||
case loginManually
|
||||
case loginWithQR
|
||||
case register
|
||||
case reportProblem
|
||||
}
|
||||
|
||||
+5
-3
@@ -17,9 +17,9 @@ class AuthenticationStartScreenViewModel: AuthenticationStartScreenViewModelType
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init() {
|
||||
super.init(initialViewState: AuthenticationStartScreenViewState())
|
||||
state.isQRCodeLoginEnabled = !ProcessInfo.processInfo.isiOSAppOnMac && AppSettings.isDevelopmentBuild
|
||||
init(webRegistrationEnabled: Bool) {
|
||||
super.init(initialViewState: AuthenticationStartScreenViewState(isWebRegistrationEnabled: webRegistrationEnabled,
|
||||
isQRCodeLoginEnabled: !ProcessInfo.processInfo.isiOSAppOnMac && AppSettings.isDevelopmentBuild))
|
||||
}
|
||||
|
||||
override func process(viewAction: AuthenticationStartScreenViewAction) {
|
||||
@@ -28,6 +28,8 @@ class AuthenticationStartScreenViewModel: AuthenticationStartScreenViewModelType
|
||||
actionsSubject.send(.loginManually)
|
||||
case .loginWithQR:
|
||||
actionsSubject.send(.loginWithQR)
|
||||
case .register:
|
||||
actionsSubject.send(.register)
|
||||
case .reportProblem:
|
||||
actionsSubject.send(.reportProblem)
|
||||
}
|
||||
|
||||
+9
-1
@@ -99,6 +99,14 @@ struct AuthenticationStartScreen: View {
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
.accessibilityIdentifier(A11yIdentifiers.authenticationStartScreen.signIn)
|
||||
|
||||
if context.viewState.isWebRegistrationEnabled {
|
||||
Button { context.send(viewAction: .register) } label: {
|
||||
Text(L10n.screenCreateAccountTitle)
|
||||
.padding(14)
|
||||
}
|
||||
.buttonStyle(.compound(.plain))
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, verticalSizeClass == .compact ? 128 : 24)
|
||||
.readableFrame()
|
||||
@@ -108,7 +116,7 @@ struct AuthenticationStartScreen: View {
|
||||
// MARK: - Previews
|
||||
|
||||
struct AuthenticationStartScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = AuthenticationStartScreenViewModel()
|
||||
static let viewModel = AuthenticationStartScreenViewModel(webRegistrationEnabled: true)
|
||||
|
||||
static var previews: some View {
|
||||
AuthenticationStartScreen(context: viewModel.context)
|
||||
|
||||
Reference in New Issue
Block a user