mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Have the UserIndicatorController use a separate window, switch to using one single instance throughout the application
This commit is contained in:
committed by
Stefan Ceriu
parent
1102beb3dd
commit
4b26a798dc
@@ -29,7 +29,6 @@ enum AppLockFlowCoordinatorAction: Equatable {
|
||||
/// Coordinates the display of any screens shown when the app is locked.
|
||||
class AppLockFlowCoordinator: CoordinatorProtocol {
|
||||
let appLockService: AppLockServiceProtocol
|
||||
let userIndicatorController: UserIndicatorController
|
||||
let navigationCoordinator: NavigationRootCoordinator
|
||||
|
||||
/// A task used to await biometric unlock before showing the PIN screen.
|
||||
@@ -41,18 +40,17 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(appLockService: AppLockServiceProtocol, userIndicatorController: UserIndicatorController, navigationCoordinator: NavigationRootCoordinator) {
|
||||
init(appLockService: AppLockServiceProtocol, navigationCoordinator: NavigationRootCoordinator) {
|
||||
self.appLockService = appLockService
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.navigationCoordinator = navigationCoordinator
|
||||
|
||||
// Set the initial background state.
|
||||
showPlaceholder()
|
||||
|
||||
appLockService.disabledPublisher
|
||||
.sink { [weak self] _ in
|
||||
.sink {
|
||||
// When the service is disabled via a force logout, we need to remove the activity indicator.
|
||||
self?.userIndicatorController.retractAllIndicators()
|
||||
ServiceLocator.shared.userIndicatorController.retractAllIndicators()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
@@ -70,7 +68,7 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(userIndicatorController.toPresentable())
|
||||
AnyView(navigationCoordinator.toPresentable())
|
||||
}
|
||||
|
||||
// MARK: - App unlock
|
||||
@@ -131,7 +129,7 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
|
||||
case .appUnlocked:
|
||||
actionsSubject.send(.unlockApp)
|
||||
case .forceLogout:
|
||||
userIndicatorController.submitIndicator(UserIndicator(type: .modal, title: L10n.commonSigningOut, persistent: true))
|
||||
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(type: .modal, title: L10n.commonSigningOut, persistent: true))
|
||||
actionsSubject.send(.forceLogout)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,8 +486,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
let navigationCoordinator = NavigationStackCoordinator()
|
||||
let userIndicatorController = UserIndicatorController(rootCoordinator: navigationCoordinator)
|
||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||
let parameters = ReportContentScreenCoordinatorParameters(eventID: eventID,
|
||||
senderID: senderID,
|
||||
roomProxy: roomProxy,
|
||||
@@ -509,15 +508,14 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
navigationCoordinator.setRootCoordinator(coordinator)
|
||||
navigationStackCoordinator.setSheetCoordinator(userIndicatorController) { [weak self] in
|
||||
navigationStackCoordinator.setRootCoordinator(coordinator)
|
||||
navigationStackCoordinator.setSheetCoordinator(navigationStackCoordinator) { [weak self] in
|
||||
self?.stateMachine.tryEvent(.dismissReportContent)
|
||||
}
|
||||
}
|
||||
|
||||
private func presentMediaUploadPickerWithSource(_ source: MediaPickerScreenSource) {
|
||||
let stackCoordinator = NavigationStackCoordinator()
|
||||
let userIndicatorController = UserIndicatorController(rootCoordinator: stackCoordinator)
|
||||
|
||||
let mediaPickerCoordinator = MediaPickerScreenCoordinator(userIndicatorController: userIndicatorController, source: source) { [weak self] action in
|
||||
switch action {
|
||||
@@ -530,7 +528,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
stackCoordinator.setRootCoordinator(mediaPickerCoordinator)
|
||||
|
||||
navigationStackCoordinator.setSheetCoordinator(userIndicatorController) { [weak self] in
|
||||
navigationStackCoordinator.setSheetCoordinator(stackCoordinator) { [weak self] in
|
||||
if case .mediaUploadPicker = self?.stateMachine.state {
|
||||
self?.stateMachine.tryEvent(.dismissMediaUploadPicker)
|
||||
}
|
||||
@@ -543,7 +541,6 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
|
||||
let stackCoordinator = NavigationStackCoordinator()
|
||||
let userIndicatorController = UserIndicatorController(rootCoordinator: stackCoordinator)
|
||||
|
||||
let parameters = MediaUploadPreviewScreenCoordinatorParameters(userIndicatorController: userIndicatorController,
|
||||
roomProxy: roomProxy,
|
||||
@@ -565,8 +562,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
.store(in: &cancellables)
|
||||
|
||||
stackCoordinator.setRootCoordinator(mediaUploadPreviewScreenCoordinator)
|
||||
|
||||
navigationStackCoordinator.setSheetCoordinator(userIndicatorController) { [weak self] in
|
||||
|
||||
navigationStackCoordinator.setSheetCoordinator(stackCoordinator) { [weak self] in
|
||||
self?.stateMachine.tryEvent(.dismissMediaUploadPreview)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,13 +34,13 @@ struct SettingsFlowCoordinatorParameters {
|
||||
let secureBackupController: SecureBackupControllerProtocol
|
||||
let appSettings: AppSettings
|
||||
let navigationSplitCoordinator: NavigationSplitCoordinator
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
}
|
||||
|
||||
class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private let parameters: SettingsFlowCoordinatorParameters
|
||||
|
||||
private var navigationStackCoordinator: NavigationStackCoordinator!
|
||||
private var userIndicatorController: UserIndicatorControllerProtocol!
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
@@ -79,10 +79,8 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private func presentSettingsScreen(animated: Bool) {
|
||||
navigationStackCoordinator = NavigationStackCoordinator()
|
||||
|
||||
userIndicatorController = UserIndicatorController(rootCoordinator: navigationStackCoordinator)
|
||||
|
||||
let parameters = SettingsScreenCoordinatorParameters(navigationStackCoordinator: navigationStackCoordinator,
|
||||
userIndicatorController: userIndicatorController,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
userSession: parameters.userSession,
|
||||
appLockService: parameters.appLockService,
|
||||
bugReportService: parameters.bugReportService,
|
||||
@@ -117,11 +115,10 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
navigationStackCoordinator.setRootCoordinator(settingsScreenCoordinator, animated: animated)
|
||||
|
||||
self.parameters.navigationSplitCoordinator.setSheetCoordinator(userIndicatorController) { [weak self] in
|
||||
self.parameters.navigationSplitCoordinator.setSheetCoordinator(navigationStackCoordinator) { [weak self] in
|
||||
guard let self else { return }
|
||||
|
||||
navigationStackCoordinator = nil
|
||||
userIndicatorController = nil
|
||||
actionsSubject.send(.dismissedSettings)
|
||||
}
|
||||
|
||||
@@ -132,7 +129,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
let coordinator = SecureBackupScreenCoordinator(parameters: .init(appSettings: parameters.appSettings,
|
||||
secureBackupController: parameters.userSession.clientProxy.secureBackupController,
|
||||
navigationStackCoordinator: navigationStackCoordinator,
|
||||
userIndicatorController: userIndicatorController))
|
||||
userIndicatorController: parameters.userIndicatorController))
|
||||
|
||||
navigationStackCoordinator.push(coordinator, animated: animated)
|
||||
}
|
||||
|
||||
@@ -86,7 +86,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
notificationSettings: userSession.clientProxy.notificationSettings,
|
||||
secureBackupController: userSession.clientProxy.secureBackupController,
|
||||
appSettings: appSettings,
|
||||
navigationSplitCoordinator: navigationSplitCoordinator))
|
||||
navigationSplitCoordinator: navigationSplitCoordinator,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController))
|
||||
|
||||
setupStateMachine()
|
||||
|
||||
@@ -436,10 +437,13 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
private func presentStartChat(animated: Bool) {
|
||||
let startChatNavigationStackCoordinator = NavigationStackCoordinator()
|
||||
|
||||
let userIndicatorController = UserIndicatorController(rootCoordinator: startChatNavigationStackCoordinator)
|
||||
|
||||
let userDiscoveryService = UserDiscoveryService(clientProxy: userSession.clientProxy)
|
||||
let parameters = StartChatScreenCoordinatorParameters(userSession: userSession, userIndicatorController: userIndicatorController, navigationStackCoordinator: startChatNavigationStackCoordinator, userDiscoveryService: userDiscoveryService)
|
||||
let parameters = StartChatScreenCoordinatorParameters(userSession: userSession,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
navigationStackCoordinator: startChatNavigationStackCoordinator,
|
||||
userDiscoveryService: userDiscoveryService)
|
||||
|
||||
let coordinator = StartChatScreenCoordinator(parameters: parameters)
|
||||
coordinator.actions.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
@@ -454,8 +458,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
.store(in: &cancellables)
|
||||
|
||||
startChatNavigationStackCoordinator.setRootCoordinator(coordinator)
|
||||
|
||||
navigationSplitCoordinator.setSheetCoordinator(userIndicatorController, animated: animated) { [weak self] in
|
||||
|
||||
navigationSplitCoordinator.setSheetCoordinator(startChatNavigationStackCoordinator, animated: animated) { [weak self] in
|
||||
self?.stateMachine.processEvent(.dismissedStartChatScreen)
|
||||
}
|
||||
}
|
||||
@@ -465,22 +469,20 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private func presentFeedbackScreen(animated: Bool, for image: UIImage? = nil) {
|
||||
let feedbackNavigationStackCoordinator = NavigationStackCoordinator()
|
||||
|
||||
let userIndicatorController = UserIndicatorController(rootCoordinator: feedbackNavigationStackCoordinator)
|
||||
|
||||
let parameters = BugReportScreenCoordinatorParameters(bugReportService: bugReportService,
|
||||
userID: userSession.userID,
|
||||
deviceID: userSession.deviceID,
|
||||
userIndicatorController: userIndicatorController,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
screenshot: image,
|
||||
isModallyPresented: true)
|
||||
let coordinator = BugReportScreenCoordinator(parameters: parameters)
|
||||
coordinator.completion = { [weak self] _ in
|
||||
self?.navigationSplitCoordinator.setSheetCoordinator(nil)
|
||||
}
|
||||
|
||||
|
||||
feedbackNavigationStackCoordinator.setRootCoordinator(coordinator)
|
||||
|
||||
navigationSplitCoordinator.setSheetCoordinator(userIndicatorController, animated: animated) { [weak self] in
|
||||
navigationSplitCoordinator.setSheetCoordinator(feedbackNavigationStackCoordinator, animated: animated) { [weak self] in
|
||||
self?.stateMachine.processEvent(.dismissedFeedbackScreen)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user