Remove all uses of the ServiceLocator from within Coordinators and View Models.

It is still used for mocks in tests, previews etc, and still used in the AppCoordinator.
This commit is contained in:
Doug
2025-08-27 16:05:49 +01:00
committed by Doug
parent dfb2425240
commit cb7d11fd13
23 changed files with 138 additions and 69 deletions
@@ -19,10 +19,10 @@ class OIDCAccountSettingsPresenter: NSObject {
private let presentationAnchor: UIWindow
private let oidcRedirectURL: URL
init(accountURL: URL, presentationAnchor: UIWindow) {
init(accountURL: URL, presentationAnchor: UIWindow, appSettings: AppSettings) {
self.accountURL = accountURL
self.presentationAnchor = presentationAnchor
oidcRedirectURL = ServiceLocator.shared.settings.oidcRedirectURL
oidcRedirectURL = appSettings.oidcRedirectURL
super.init()
}
@@ -22,9 +22,9 @@ final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
actionsSubject.eraseToAnyPublisher()
}
init() {
viewModel = DeveloperOptionsScreenViewModel(developerOptions: ServiceLocator.shared.settings,
elementCallBaseURL: ServiceLocator.shared.settings.elementCallBaseURL)
init(appSettings: AppSettings) {
viewModel = DeveloperOptionsScreenViewModel(developerOptions: appSettings,
elementCallBaseURL: appSettings.elementCallBaseURL)
viewModel.actions
.sink { [weak self] action in
@@ -13,6 +13,7 @@ struct NotificationSettingsScreenCoordinatorParameters {
let userSession: UserSessionProtocol
let userNotificationCenter: UserNotificationCenterProtocol
let isModallyPresented: Bool
let appSettings: AppSettings
}
enum NotificationSettingsScreenCoordinatorAction {
@@ -36,7 +37,7 @@ final class NotificationSettingsScreenCoordinator: CoordinatorProtocol {
init(parameters: NotificationSettingsScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = NotificationSettingsScreenViewModel(appSettings: ServiceLocator.shared.settings,
viewModel = NotificationSettingsScreenViewModel(appSettings: parameters.appSettings,
userNotificationCenter: parameters.userNotificationCenter,
notificationSettingsProxy: parameters.userSession.clientProxy.notificationSettings,
isModallyPresented: parameters.isModallyPresented)