mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Add space management to the flows. (#4978)
* Add the menu entries to add/remove rooms to/from a space. * Add a user indicator to SpaceAddRoomsScreen. * Reset the SpaceRoomListProxy after adding/removing any children. * Calm the animations down a bit when entering EditMode on the SpaceScreen.
This commit is contained in:
@@ -52,6 +52,8 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
|
||||
case joinSpace
|
||||
/// The root screen for this flow.
|
||||
case space
|
||||
/// The user is adding rooms to the space.
|
||||
case addingRooms
|
||||
/// A child (space) flow is in progress.
|
||||
case presentingChild(childSpaceID: String, previousState: State)
|
||||
/// A room flow is in progress
|
||||
@@ -77,6 +79,11 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
|
||||
/// The space screen left the space.
|
||||
case leftSpace
|
||||
|
||||
/// Allow the user to add existing rooms to this space.
|
||||
case addRooms
|
||||
/// The user finished adding rooms to this space.
|
||||
case dismissedAddRooms
|
||||
|
||||
/// Request the presentation of a child space flow.
|
||||
///
|
||||
/// The space's `SpaceRoomListProxyProtocol` must be provided in the `userInfo`.
|
||||
@@ -145,6 +152,9 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
|
||||
} else {
|
||||
navigationStackCoordinator.setRootCoordinator(nil, animated: animated)
|
||||
}
|
||||
case .addingRooms:
|
||||
navigationStackCoordinator.setSheetCoordinator(nil)
|
||||
clearRoute(animated: animated) // Re-run with the state machine back in the .space state.
|
||||
case .presentingChild:
|
||||
childSpaceFlowCoordinator?.clearRoute(animated: animated)
|
||||
clearRoute(animated: animated) // Re-run with the state machine back in the .space state.
|
||||
@@ -182,6 +192,11 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
|
||||
self?.clearRoute(animated: true)
|
||||
}
|
||||
|
||||
stateMachine.addRoutes(event: .addRooms, transitions: [.space => .addingRooms]) { [weak self] _ in
|
||||
self?.presentSpaceAddRoomsScreen()
|
||||
}
|
||||
stateMachine.addRoutes(event: .dismissedAddRooms, transitions: [.addingRooms => .space])
|
||||
|
||||
stateMachine.addRouteMapping { event, fromState, userInfo in
|
||||
guard event == .startChildFlow else { return nil }
|
||||
guard let childEntryPoint = userInfo as? SpaceFlowCoordinatorEntryPoint else { fatalError("An entry point must be provided.") }
|
||||
@@ -306,6 +321,8 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
|
||||
stateMachine.tryEvent(.startSettingsFlow, userInfo: roomProxy)
|
||||
case .displayRolesAndPermissions(let roomProxy):
|
||||
stateMachine.tryEvent(.startRolesAndPermissionsFlow, userInfo: roomProxy)
|
||||
case .addExistingChildren:
|
||||
stateMachine.tryEvent(.addRooms)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
@@ -371,6 +388,31 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
|
||||
presentSpace()
|
||||
}
|
||||
|
||||
private func presentSpaceAddRoomsScreen() {
|
||||
guard case let .space(spaceRoomListProxy) = entryPoint else { fatalError("Attempting to show a space with the wrong entry point.") }
|
||||
|
||||
let stackCoordinator = NavigationStackCoordinator()
|
||||
let parameters = SpaceAddRoomsScreenCoordinatorParameters(spaceRoomListProxy: spaceRoomListProxy,
|
||||
userSession: flowParameters.userSession,
|
||||
roomSummaryProvider: flowParameters.userSession.clientProxy.alternateRoomSummaryProvider,
|
||||
userIndicatorController: flowParameters.userIndicatorController)
|
||||
let coordinator = SpaceAddRoomsScreenCoordinator(parameters: parameters)
|
||||
coordinator.actions
|
||||
.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
switch action {
|
||||
case .dismiss:
|
||||
navigationStackCoordinator.setSheetCoordinator(nil)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
stackCoordinator.setRootCoordinator(coordinator)
|
||||
navigationStackCoordinator.setSheetCoordinator(stackCoordinator) { [weak self] in
|
||||
self?.stateMachine.tryEvent(.dismissedAddRooms)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Other flows
|
||||
|
||||
private func startChildFlow(with entryPoint: SpaceFlowCoordinatorEntryPoint) {
|
||||
|
||||
Reference in New Issue
Block a user