Update OIDC presentation (#987)

* Present OIDC directly on the ServerConfirmationScreen.

Read the actual window from the view.

* Pop back to the confirmation screen when a user enters an MXID that needs OIDC.

* Remove OIDC error handling from the login screen.
This commit is contained in:
Doug
2023-05-30 16:51:00 +01:00
committed by GitHub
parent 03ba211e6c
commit 6b6ea118e2
24 changed files with 130 additions and 122 deletions
@@ -23,7 +23,7 @@ struct ServerConfirmationScreenCoordinatorParameters {
}
enum ServerConfirmationScreenCoordinatorAction {
case confirm
case `continue`(UIWindow?)
case changeServer
}
@@ -50,7 +50,7 @@ final class ServerConfirmationScreenCoordinator: CoordinatorProtocol {
switch action {
case .confirm:
self.actionsSubject.send(.confirm)
self.actionsSubject.send(.continue(viewModel.context.viewState.window))
case .changeServer:
self.actionsSubject.send(.changeServer)
}
@@ -14,7 +14,7 @@
// limitations under the License.
//
import Foundation
import SwiftUI
enum ServerConfirmationScreenViewModelAction {
/// The user would like to continue with the current homeserver.
@@ -28,6 +28,8 @@ struct ServerConfirmationScreenViewState: BindableState {
var homeserverAddress: String
/// The flow being attempted on the selected homeserver.
let authenticationFlow: AuthenticationFlow
/// The presentation anchor used for OIDC authentication.
var window: UIWindow?
/// The screen's title.
var title: String {
@@ -57,6 +59,8 @@ struct ServerConfirmationScreenViewState: BindableState {
}
enum ServerConfirmationScreenViewAction {
/// Updates the window used as the OIDC presentation anchor.
case updateWindow(UIWindow)
/// The user would like to continue with the current homeserver.
case confirm
/// The user would like to change to a different homeserver.
@@ -43,6 +43,9 @@ class ServerConfirmationScreenViewModel: ServerConfirmationScreenViewModelType,
override func process(viewAction: ServerConfirmationScreenViewAction) {
switch viewAction {
case .updateWindow(let window):
guard state.window != window else { return }
Task { state.window = window }
case .confirm:
actionsSubject.send(.confirm)
case .changeServer:
@@ -34,6 +34,10 @@ struct ServerConfirmationScreen: View {
.readableFrame()
.background(Color.element.background.ignoresSafeArea())
}
.introspectViewController { viewController in
guard let window = viewController.view.window else { return }
context.send(viewAction: .updateWindow(window))
}
}
/// The main content of the view to be shown in a scroll view.