mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 13:37:11 +00:00
Added error toasts on the login screen.
This commit is contained in:
parent
c35438cbb8
commit
d634995a20
@ -20,6 +20,7 @@ class AppCoordinator: AuthenticationCoordinatorDelegate, Coordinator {
|
||||
private let authenticationCoordinator: AuthenticationCoordinator!
|
||||
|
||||
private var loadingActivity: Activity?
|
||||
private var errorActivity: Activity?
|
||||
|
||||
var childCoordinators: [Coordinator] = []
|
||||
|
||||
@ -55,6 +56,7 @@ class AppCoordinator: AuthenticationCoordinatorDelegate, Coordinator {
|
||||
|
||||
func authenticationCoordinator(_ authenticationCoordinator: AuthenticationCoordinator, didFailWithError error: AuthenticationCoordinatorError) {
|
||||
hideLoadingIndicator()
|
||||
showLoginErrorToast()
|
||||
}
|
||||
|
||||
func authenticationCoordinatorDidSetupUserSession(_ authenticationCoordinator: AuthenticationCoordinator) {
|
||||
@ -91,7 +93,8 @@ class AppCoordinator: AuthenticationCoordinatorDelegate, Coordinator {
|
||||
}
|
||||
|
||||
private func showLoadingIndicator() {
|
||||
let presenter = FullscreenLoadingActivityPresenter(label: "Loading", on: self.mainNavigationController)
|
||||
let presenter = FullscreenLoadingActivityPresenter(label: "Loading",
|
||||
on: mainNavigationController)
|
||||
|
||||
let request = ActivityRequest(
|
||||
presenter: presenter,
|
||||
@ -104,4 +107,16 @@ class AppCoordinator: AuthenticationCoordinatorDelegate, Coordinator {
|
||||
private func hideLoadingIndicator() {
|
||||
loadingActivity = nil
|
||||
}
|
||||
|
||||
private func showLoginErrorToast() {
|
||||
let presenter = ToastActivityPresenter(viewState: .init(style: .success, label: "Failed logging in"),
|
||||
navigationController: mainNavigationController)
|
||||
|
||||
let request = ActivityRequest(
|
||||
presenter: presenter,
|
||||
dismissal: .timeout(3.0)
|
||||
)
|
||||
|
||||
errorActivity = ActivityCenter.shared.add(request)
|
||||
}
|
||||
}
|
||||
|
@ -97,12 +97,11 @@ class AuthenticationCoordinator: Coordinator {
|
||||
switch result {
|
||||
case .success:
|
||||
completion(.success(()))
|
||||
self.remove(childCoordinator: coordinator)
|
||||
self.navigationRouter.dismissModule()
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
}
|
||||
|
||||
self.remove(childCoordinator: coordinator)
|
||||
self.navigationRouter.dismissModule()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,10 @@ class ToastActivityPresenter: ActivityPresentable {
|
||||
self.viewState = viewState
|
||||
self.navigationController = navigationController
|
||||
}
|
||||
|
||||
|
||||
func present() {
|
||||
guard let navigationController = navigationController else {
|
||||
guard let navigationController = navigationController,
|
||||
let window = navigationController.view.window else {
|
||||
return
|
||||
}
|
||||
|
||||
@ -38,7 +39,7 @@ class ToastActivityPresenter: ActivityPresentable {
|
||||
self.view = view
|
||||
|
||||
view.translatesAutoresizingMaskIntoConstraints = false
|
||||
navigationController.view.addSubview(view)
|
||||
window.addSubview(view)
|
||||
NSLayoutConstraint.activate([
|
||||
view.centerXAnchor.constraint(equalTo: navigationController.navigationBar.centerXAnchor),
|
||||
view.topAnchor.constraint(equalTo: navigationController.navigationBar.bottomAnchor)
|
||||
|
@ -48,6 +48,7 @@ class RoundedToastView: UIView {
|
||||
private let stackView: UIStackView = {
|
||||
let stack = UIStackView()
|
||||
stack.axis = .horizontal
|
||||
stack.alignment = .center
|
||||
stack.spacing = 5
|
||||
return stack
|
||||
}()
|
||||
@ -66,6 +67,9 @@ class RoundedToastView: UIView {
|
||||
}
|
||||
|
||||
private func setup(viewState: ViewState) {
|
||||
|
||||
backgroundColor = .gray.withAlphaComponent(0.75)
|
||||
|
||||
setupLayer()
|
||||
setupStackView()
|
||||
stackView.addArrangedSubview(toastView(for: viewState.style))
|
||||
|
Loading…
x
Reference in New Issue
Block a user