547 refactored userNotification into userIndicator

This commit is contained in:
Mauro Romito
2023-02-14 11:09:55 +01:00
committed by Mauro
parent b2d99e27a5
commit d7f80807df
21 changed files with 149 additions and 148 deletions
@@ -73,7 +73,7 @@ class AuthenticationCoordinator: CoordinatorProtocol {
private func showServerSelectionScreen() {
let parameters = ServerSelectionCoordinatorParameters(authenticationService: authenticationService,
userNotificationController: ServiceLocator.shared.userNotificationController,
userIndicatorController: ServiceLocator.shared.userIndicatorController,
isModallyPresented: false)
let coordinator = ServerSelectionCoordinator(parameters: parameters)
@@ -123,13 +123,13 @@ class AuthenticationCoordinator: CoordinatorProtocol {
static let loadingIndicatorIdentifier = "AuthenticationCoordinatorLoading"
private func startLoading() {
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(id: Self.loadingIndicatorIdentifier,
type: .modal,
title: ElementL10n.loading,
persistent: true))
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
type: .modal,
title: ElementL10n.loading,
persistent: true))
}
private func stopLoading() {
ServiceLocator.shared.userNotificationController.retractNotificationWithId(Self.loadingIndicatorIdentifier)
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
}
}
@@ -92,10 +92,10 @@ final class LoginCoordinator: CoordinatorProtocol {
static let loadingIndicatorIdentifier = "LoginCoordinatorLoading"
private func startLoading(isInteractionBlocking: Bool) {
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(id: Self.loadingIndicatorIdentifier,
type: .modal,
title: ElementL10n.loading,
persistent: true))
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
type: .modal,
title: ElementL10n.loading,
persistent: true))
if !isInteractionBlocking {
viewModel.update(isLoading: true)
@@ -104,15 +104,15 @@ final class LoginCoordinator: CoordinatorProtocol {
private func stopLoading() {
viewModel.update(isLoading: false)
ServiceLocator.shared.userNotificationController.retractNotificationWithId(Self.loadingIndicatorIdentifier)
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
}
private func indicateSuccess() {
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(title: ElementL10n.dialogTitleSuccess))
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(title: ElementL10n.dialogTitleSuccess))
}
private func indicateFailure() {
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(title: ElementL10n.dialogTitleError))
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(title: ElementL10n.dialogTitleError))
}
/// Processes an error to either update the flow or display it to the user.
@@ -200,7 +200,7 @@ final class LoginCoordinator: CoordinatorProtocol {
/// Presents the server selection screen as a modal.
private func presentServerSelectionScreen() {
let parameters = ServerSelectionCoordinatorParameters(authenticationService: authenticationService,
userNotificationController: ServiceLocator.shared.userNotificationController,
userIndicatorController: ServiceLocator.shared.userIndicatorController,
isModallyPresented: false)
let coordinator = ServerSelectionCoordinator(parameters: parameters)
@@ -19,7 +19,7 @@ import SwiftUI
struct ServerSelectionCoordinatorParameters {
/// The service used to authenticate the user.
let authenticationService: AuthenticationServiceProxyProtocol
let userNotificationController: UserNotificationControllerProtocol
let userIndicatorController: UserIndicatorControllerProtocol
/// Whether the screen is presented modally or within a navigation stack.
let isModallyPresented: Bool
}
@@ -31,7 +31,7 @@ enum ServerSelectionCoordinatorAction {
final class ServerSelectionCoordinator: CoordinatorProtocol {
private let parameters: ServerSelectionCoordinatorParameters
private let userNotificationController: UserNotificationControllerProtocol
private let userIndicatorController: UserIndicatorControllerProtocol
private var viewModel: ServerSelectionViewModelProtocol
private var authenticationService: AuthenticationServiceProxyProtocol { parameters.authenticationService }
@@ -41,7 +41,7 @@ final class ServerSelectionCoordinator: CoordinatorProtocol {
self.parameters = parameters
viewModel = ServerSelectionViewModel(homeserverAddress: parameters.authenticationService.homeserver.address,
isModallyPresented: parameters.isModallyPresented)
userNotificationController = parameters.userNotificationController
userIndicatorController = parameters.userIndicatorController
}
// MARK: - Public
@@ -70,13 +70,13 @@ final class ServerSelectionCoordinator: CoordinatorProtocol {
// MARK: - Private
private func startLoading(label: String = ElementL10n.loading) {
userNotificationController.submitNotification(UserNotification(type: .modal,
title: label,
persistent: true))
userIndicatorController.submitIndicator(UserIndicator(type: .modal,
title: label,
persistent: true))
}
private func stopLoading() {
userNotificationController.retractAllNotifications()
userIndicatorController.retractAllIndicators()
}
/// Updates the login flow using the supplied homeserver address, or shows an error when this isn't possible.
@@ -99,15 +99,15 @@ final class SoftLogoutCoordinator: CoordinatorProtocol {
/// Show an activity indicator whilst loading.
@MainActor private func startLoading() {
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(id: Self.loadingIndicatorIdentifier,
type: .modal,
title: ElementL10n.loading,
persistent: true))
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
type: .modal,
title: ElementL10n.loading,
persistent: true))
}
/// Hide the currently displayed activity indicator.
@MainActor private func stopLoading() {
ServiceLocator.shared.userNotificationController.retractNotificationWithId(Self.loadingIndicatorIdentifier)
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
}
/// Shows the forgot password screen.
@@ -23,7 +23,7 @@ enum BugReportCoordinatorResult {
struct BugReportCoordinatorParameters {
let bugReportService: BugReportServiceProtocol
weak var userNotificationController: UserNotificationControllerProtocol?
weak var userIndicatorController: UserIndicatorControllerProtocol?
let screenshot: UIImage?
let isModallyPresented: Bool
}
@@ -76,20 +76,20 @@ final class BugReportCoordinator: CoordinatorProtocol {
static let loadingIndicatorIdentifier = "BugReportLoading"
private func startLoading(label: String = ElementL10n.loading, progressPublisher: ProgressPublisher) {
parameters.userNotificationController?.submitNotification(
UserNotification(id: Self.loadingIndicatorIdentifier,
type: .modal,
title: label,
persistent: true,
progressPublisher: progressPublisher)
parameters.userIndicatorController?.submitIndicator(
UserIndicator(id: Self.loadingIndicatorIdentifier,
type: .modal,
title: label,
persistent: true,
progressPublisher: progressPublisher)
)
}
private func stopLoading() {
parameters.userNotificationController?.retractNotificationWithId(Self.loadingIndicatorIdentifier)
parameters.userIndicatorController?.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
}
private func showError(label: String) {
parameters.userNotificationController?.submitNotification(UserNotification(title: label))
parameters.userIndicatorController?.submitIndicator(UserIndicator(title: label))
}
}
@@ -68,9 +68,9 @@ class RoomDetailsViewModel: RoomDetailsViewModelType, RoomDetailsViewModelProtoc
private func copyRoomLink() {
if let roomLink = state.permalink {
UIPasteboard.general.url = roomLink
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(title: ElementL10n.linkCopiedToClipboard))
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(title: ElementL10n.linkCopiedToClipboard))
} else {
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(title: ElementL10n.unknownError))
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(title: ElementL10n.unknownError))
}
}
}
@@ -194,10 +194,10 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
title: ElementL10n.dialogTitleError,
message: message)
case .toast(let message):
ServiceLocator.shared.userNotificationController.submitNotification(UserNotification(id: Constants.toastErrorID,
type: .toast,
title: message,
iconName: "xmark"))
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(id: Constants.toastErrorID,
type: .toast,
title: message,
iconName: "xmark"))
}
}
@@ -18,7 +18,7 @@ import SwiftUI
struct SettingsScreenCoordinatorParameters {
weak var navigationStackCoordinator: NavigationStackCoordinator?
weak var userNotificationController: UserNotificationControllerProtocol?
weak var userIndicatorController: UserIndicatorControllerProtocol?
let userSession: UserSessionProtocol
let bugReportService: BugReportServiceProtocol
}
@@ -76,7 +76,7 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
private func presentBugReportScreen() {
let params = BugReportCoordinatorParameters(bugReportService: parameters.bugReportService,
userNotificationController: parameters.userNotificationController,
userIndicatorController: parameters.userIndicatorController,
screenshot: nil,
isModallyPresented: false)
let coordinator = BugReportCoordinator(parameters: params)
@@ -112,6 +112,6 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
}
private func showSuccess(label: String) {
parameters.userNotificationController?.submitNotification(UserNotification(title: label))
parameters.userIndicatorController?.submitIndicator(UserIndicator(title: label))
}
}