Joining a space from the room flow. (#4563)

* Add the More menu to SpaceScreen.

And a simple way to leave a space for testing.

* Start a space flow when accepting a space invite from the room flow.

* Minimise the tab bar on iOS 26 when scrolling down.

* Enable spaces by default!
This commit is contained in:
Doug
2025-10-02 10:58:38 +01:00
committed by GitHub
parent 3215f8c269
commit 621b72f162
13 changed files with 128 additions and 29 deletions
@@ -469,6 +469,8 @@ class ChatsFlowCoordinator: FlowCoordinatorProtocol {
actionsSubject.send(.showCallScreen(roomProxy: roomProxy))
case .verifyUser(let userID):
actionsSubject.send(.sessionVerification(.userInitiator(userID: userID)))
case .continueWithSpaceFlow(let spaceRoomListProxy):
stateMachine.processEvent(.startSpaceFlow, userInfo: .init(animated: false, spaceRoomListProxy: spaceRoomListProxy))
case .finished:
stateMachine.processEvent(.deselectRoom)
}
@@ -13,6 +13,9 @@ import UserNotifications
enum RoomFlowCoordinatorAction: Equatable {
case presentCallScreen(roomProxy: JoinedRoomProxyProtocol)
case verifyUser(userID: String)
/// The requested room was actually a space. The room flow has been dismissed
/// and a space flow should be started to continue.
case continueWithSpaceFlow(SpaceRoomListProxyProtocol)
case finished
static func == (lhs: RoomFlowCoordinatorAction, rhs: RoomFlowCoordinatorAction) -> Bool {
@@ -385,6 +388,11 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
presentJoinRoomScreen(via: via, animated: true)
case (_, .dismissJoinRoomScreen, .complete):
dismissFlow(animated: animated)
case (_, .joinedSpace, .complete):
guard let spaceRoomListProxy = (context.userInfo as? EventUserInfo)?.spaceRoomListProxy else {
fatalError("The space room list proxy is required to present a space.")
}
dismissFlow(animated: animated, continuingWith: spaceRoomListProxy)
case (.joinRoomScreen, .presentDeclineAndBlockScreen(let userID), .declineAndBlockScreen):
presentDeclineAndBlockScreen(userID: userID)
@@ -720,8 +728,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.tryEvent(.dismissFlow, userInfo: EventUserInfo(animated: animated))
}
}
case .joined(.space):
#warning("The space flow should be shown here.")
case .joined(.space(let spaceRoomListProxy)):
stateMachine.tryEvent(.joinedSpace, userInfo: EventUserInfo(animated: true, spaceRoomListProxy: spaceRoomListProxy))
case .cancelled:
stateMachine.tryEvent(.dismissJoinRoomScreen)
case .presentDeclineAndBlock(let userID):
@@ -745,7 +753,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
}
}
private func dismissFlow(animated: Bool) {
private func dismissFlow(animated: Bool, continuingWith spaceRoomListProxy: SpaceRoomListProxyProtocol? = nil) {
childRoomFlowCoordinator?.clearRoute(animated: animated)
if isChildFlow {
@@ -757,12 +765,21 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
}
} else {
navigationStackCoordinator.popToRoot(animated: false)
navigationStackCoordinator.setRootCoordinator(nil, animated: false)
// Leave the root alone when it is about to be replaced by the space flow, otherwise when running on
// iPhone the compact module diffs call the dismissal callback and we present a blank space flow 🙈
if spaceRoomListProxy == nil {
navigationStackCoordinator.setRootCoordinator(nil, animated: false)
}
}
timelineController = nil
actionsSubject.send(.finished)
if let spaceRoomListProxy {
actionsSubject.send(.continueWithSpaceFlow(spaceRoomListProxy))
} else {
actionsSubject.send(.finished)
}
flowParameters.analytics.signpost.endRoomFlow()
}
@@ -1457,6 +1474,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
actionsSubject.send(.presentCallScreen(roomProxy: roomProxy))
case .verifyUser(let userID):
actionsSubject.send(.verifyUser(userID: userID))
case .continueWithSpaceFlow(let spaceRoomListProxy):
#warning("Present the space as a child.")
case .finished:
stateMachine.tryEvent(.dismissChildFlow)
}
@@ -84,11 +84,13 @@ extension RoomFlowCoordinator {
struct EventUserInfo {
let animated: Bool
var timelineController: TimelineControllerProtocol?
var spaceRoomListProxy: SpaceRoomListProxyProtocol?
}
enum Event: EventType {
case presentJoinRoomScreen(via: [String])
case dismissJoinRoomScreen
case joinedSpace
case presentRoom(presentationAction: PresentationAction?)
case dismissFlow
@@ -321,6 +323,8 @@ extension RoomFlowCoordinator {
return .joinRoomScreen
case (_, .dismissJoinRoomScreen):
return .complete
case (_, .joinedSpace):
return .complete
case (.joinRoomScreen, .presentDeclineAndBlockScreen):
return .declineAndBlockScreen
@@ -52,6 +52,8 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
case presentingChild(childSpaceID: String, previousState: State)
/// A room flow is in progress
case roomFlow(previousState: State)
case leftSpace
}
enum Event: EventType {
@@ -62,6 +64,8 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
/// The join space screen joined the space.
case joinedSpace
/// The space screen left the space.
case leftSpace
/// Request the presentation of a child space flow.
///
@@ -116,7 +120,7 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
switch stateMachine.state {
case .initial:
break
case .joinSpace, .space:
case .joinSpace, .space, .leftSpace:
if isChildFlow {
navigationStackCoordinator.pop(animated: animated)
} else {
@@ -145,11 +149,18 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.addRoutes(event: .joinedSpace, transitions: [.joinSpace => .space]) { [weak self] _ in
self?.presentSpaceAfterJoining()
}
stateMachine.addRoutes(event: .leftSpace, transitions: [.space => .leftSpace]) { [weak self] _ in
self?.clearRoute(animated: true)
}
stateMachine.addRouteMapping { event, fromState, userInfo in
guard event == .startChildFlow, case .space = fromState else { return nil }
guard event == .startChildFlow else { return nil }
guard let childEntryPoint = userInfo as? SpaceFlowCoordinatorEntryPoint else { fatalError("An entry point must be provided.") }
return .presentingChild(childSpaceID: childEntryPoint.spaceID, previousState: fromState)
return switch fromState {
case .space: .presentingChild(childSpaceID: childEntryPoint.spaceID, previousState: fromState)
case .roomFlow(let previousState): .presentingChild(childSpaceID: childEntryPoint.spaceID, previousState: previousState)
default: nil
}
} handler: { [weak self] context in
guard let self, let entryPoint = context.userInfo as? SpaceFlowCoordinatorEntryPoint else { return }
startChildFlow(with: entryPoint)
@@ -205,6 +216,8 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.tryEvent(.startChildFlow, userInfo: SpaceFlowCoordinatorEntryPoint.joinSpace(spaceRoomProxy))
case .selectRoom(let roomID):
stateMachine.tryEvent(.startRoomFlow(roomID: roomID))
case .leftSpace:
stateMachine.tryEvent(.leftSpace)
}
}
.store(in: &cancellables)
@@ -314,6 +327,8 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
actionsSubject.send(.presentCallScreen(roomProxy: roomProxy))
case .verifyUser(let userID):
actionsSubject.send(.verifyUser(userID: userID))
case .continueWithSpaceFlow(let spaceRoomListProxy):
stateMachine.tryEvent(.startChildFlow, userInfo: SpaceFlowCoordinatorEntryPoint.space(spaceRoomListProxy))
case .finished:
stateMachine.tryEvent(.stopRoomFlow)
}