mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Tidy up the naming of spaces a bit more. (#4955)
* Rename SpaceListScreen to SpacesScreen To avoid confusion with the SpaceRoomListProxy. * Rename SpaceExplorerFlowCoordinator to SpacesTabFlowCoordinator and ChatsFlowCoordinator to ChatsTabFlowCoordinator.
This commit is contained in:
+10
-10
@@ -11,7 +11,7 @@ import Combine
|
||||
import MatrixRustSDK
|
||||
import SwiftUI
|
||||
|
||||
enum ChatsFlowCoordinatorAction {
|
||||
enum ChatsTabFlowCoordinatorAction {
|
||||
case switchToChatsTab
|
||||
case showSettings
|
||||
case showChatBackupSettings
|
||||
@@ -21,13 +21,13 @@ enum ChatsFlowCoordinatorAction {
|
||||
case logout
|
||||
}
|
||||
|
||||
class ChatsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
class ChatsTabFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private let navigationSplitCoordinator: NavigationSplitCoordinator
|
||||
private let flowParameters: CommonFlowParameters
|
||||
|
||||
private var userSession: UserSessionProtocol { flowParameters.userSession }
|
||||
|
||||
private let stateMachine: ChatsFlowCoordinatorStateMachine
|
||||
private let stateMachine: ChatsTabFlowCoordinatorStateMachine
|
||||
|
||||
// periphery:ignore - retaining purpose
|
||||
private var roomFlowCoordinator: RoomFlowCoordinator?
|
||||
@@ -50,15 +50,15 @@ class ChatsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
private let selectedRoomSubject = CurrentValueSubject<String?, Never>(nil)
|
||||
|
||||
private let actionsSubject: PassthroughSubject<ChatsFlowCoordinatorAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<ChatsFlowCoordinatorAction, Never> {
|
||||
private let actionsSubject: PassthroughSubject<ChatsTabFlowCoordinatorAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<ChatsTabFlowCoordinatorAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(isNewLogin: Bool,
|
||||
navigationSplitCoordinator: NavigationSplitCoordinator,
|
||||
flowParameters: CommonFlowParameters) {
|
||||
stateMachine = flowParameters.stateMachineFactory.makeChatsFlowStateMachine()
|
||||
stateMachine = flowParameters.stateMachineFactory.makeChatsTabFlowStateMachine()
|
||||
self.navigationSplitCoordinator = navigationSplitCoordinator
|
||||
self.flowParameters = flowParameters
|
||||
|
||||
@@ -188,7 +188,7 @@ class ChatsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
stateMachine.addTransitionHandler { [weak self] context in
|
||||
guard let self else { return }
|
||||
|
||||
let userInfo = context.userInfo as? ChatsFlowCoordinatorStateMachine.EventUserInfo
|
||||
let userInfo = context.userInfo as? ChatsTabFlowCoordinatorStateMachine.EventUserInfo
|
||||
let animated = userInfo?.animated ?? true
|
||||
|
||||
switch (context.fromState, context.event, context.toState) {
|
||||
@@ -289,7 +289,7 @@ class ChatsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
private func handleSelectRoomTransition(roomID: String, via: [String], entryPoint: RoomFlowCoordinatorEntryPoint, detailState: ChatsFlowCoordinatorStateMachine.DetailState?, animated: Bool) {
|
||||
private func handleSelectRoomTransition(roomID: String, via: [String], entryPoint: RoomFlowCoordinatorEntryPoint, detailState: ChatsTabFlowCoordinatorStateMachine.DetailState?, animated: Bool) {
|
||||
if case .room(roomID) = detailState,
|
||||
!entryPoint.isEventID, // Don't reuse the existing room so the live timeline is hidden while the detached timeline is loading.
|
||||
let roomFlowCoordinator {
|
||||
@@ -798,8 +798,8 @@ class ChatsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
// MARK: Toasts and loading indicators
|
||||
|
||||
private static let loadingIndicatorIdentifier = "\(ChatsFlowCoordinator.self)-Loading"
|
||||
private static let failureIndicatorIdentifier = "\(ChatsFlowCoordinator.self)-Failure"
|
||||
private static let loadingIndicatorIdentifier = "\(ChatsTabFlowCoordinator.self)-Loading"
|
||||
private static let failureIndicatorIdentifier = "\(ChatsTabFlowCoordinator.self)-Failure"
|
||||
|
||||
private func showLoadingIndicator(delay: Duration? = nil) {
|
||||
flowParameters.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||
+2
-2
@@ -10,7 +10,7 @@ import Combine
|
||||
import Foundation
|
||||
import SwiftState
|
||||
|
||||
class ChatsFlowCoordinatorStateMachine {
|
||||
class ChatsTabFlowCoordinatorStateMachine {
|
||||
enum DetailState: Hashable {
|
||||
case room(roomID: String)
|
||||
case space
|
||||
@@ -138,7 +138,7 @@ class ChatsFlowCoordinatorStateMachine {
|
||||
|
||||
private let stateMachine: StateMachine<State, Event>
|
||||
|
||||
var state: ChatsFlowCoordinatorStateMachine.State {
|
||||
var state: ChatsTabFlowCoordinatorStateMachine.State {
|
||||
stateMachine.state
|
||||
}
|
||||
|
||||
+18
-18
@@ -10,13 +10,13 @@ import Combine
|
||||
import Foundation
|
||||
import SwiftState
|
||||
|
||||
enum SpaceExplorerFlowCoordinatorAction {
|
||||
enum SpacesTabFlowCoordinatorAction {
|
||||
case showSettings
|
||||
case presentCallScreen(roomProxy: JoinedRoomProxyProtocol)
|
||||
case verifyUser(userID: String)
|
||||
}
|
||||
|
||||
class SpaceExplorerFlowCoordinator: FlowCoordinatorProtocol {
|
||||
class SpacesTabFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private let userSession: UserSessionProtocol
|
||||
|
||||
private var flowParameters: CommonFlowParameters
|
||||
@@ -30,7 +30,7 @@ class SpaceExplorerFlowCoordinator: FlowCoordinatorProtocol {
|
||||
/// The state machine hasn't started.
|
||||
case initial
|
||||
/// The root screen for this flow.
|
||||
case spaceList(selectedSpaceID: String?)
|
||||
case spacesScreen(selectedSpaceID: String?)
|
||||
}
|
||||
|
||||
enum Event: EventType {
|
||||
@@ -49,8 +49,8 @@ class SpaceExplorerFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
private let selectedSpaceSubject = CurrentValueSubject<String?, Never>(nil)
|
||||
|
||||
private let actionsSubject: PassthroughSubject<SpaceExplorerFlowCoordinatorAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<SpaceExplorerFlowCoordinatorAction, Never> {
|
||||
private let actionsSubject: PassthroughSubject<SpacesTabFlowCoordinatorAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<SpacesTabFlowCoordinatorAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class SpaceExplorerFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
func clearRoute(animated: Bool) {
|
||||
switch stateMachine.state {
|
||||
case .initial, .spaceList:
|
||||
case .initial, .spacesScreen:
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -87,22 +87,22 @@ class SpaceExplorerFlowCoordinator: FlowCoordinatorProtocol {
|
||||
// MARK: - Private
|
||||
|
||||
private func configureStateMachine() {
|
||||
stateMachine.addRoutes(event: .start, transitions: [.initial => .spaceList(selectedSpaceID: nil)]) { [weak self] _ in
|
||||
self?.presentSpaceList()
|
||||
stateMachine.addRoutes(event: .start, transitions: [.initial => .spacesScreen(selectedSpaceID: nil)]) { [weak self] _ in
|
||||
self?.presentSpacesScreen()
|
||||
}
|
||||
|
||||
stateMachine.addRouteMapping { event, fromState, userInfo in
|
||||
guard event == .selectSpace, case .spaceList = fromState else { return nil }
|
||||
guard event == .selectSpace, case .spacesScreen = fromState else { return nil }
|
||||
guard let spaceRoomListProxy = userInfo as? SpaceRoomListProxyProtocol else { fatalError("A space proxy must be provided.") }
|
||||
return .spaceList(selectedSpaceID: spaceRoomListProxy.id)
|
||||
return .spacesScreen(selectedSpaceID: spaceRoomListProxy.id)
|
||||
} handler: { [weak self] context in
|
||||
guard let self, let spaceRoomListProxy = context.userInfo as? SpaceRoomListProxyProtocol else { return }
|
||||
startSpaceFlow(spaceRoomListProxy: spaceRoomListProxy)
|
||||
}
|
||||
|
||||
stateMachine.addRouteMapping { event, fromState, _ in
|
||||
guard event == .deselectSpace, case .spaceList(.some) = fromState else { return nil }
|
||||
return .spaceList(selectedSpaceID: nil)
|
||||
guard event == .deselectSpace, case .spacesScreen(.some) = fromState else { return nil }
|
||||
return .spacesScreen(selectedSpaceID: nil)
|
||||
} handler: { [weak self] _ in
|
||||
guard let self else { return }
|
||||
navigationSplitCoordinator.setDetailCoordinator(nil) // If we forget to do this, the tab bar remains hidden.
|
||||
@@ -115,12 +115,12 @@ class SpaceExplorerFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
private func presentSpaceList() {
|
||||
let parameters = SpaceListScreenCoordinatorParameters(userSession: userSession,
|
||||
selectedSpacePublisher: selectedSpaceSubject.asCurrentValuePublisher(),
|
||||
appSettings: flowParameters.appSettings,
|
||||
userIndicatorController: flowParameters.userIndicatorController)
|
||||
let coordinator = SpaceListScreenCoordinator(parameters: parameters)
|
||||
private func presentSpacesScreen() {
|
||||
let parameters = SpacesScreenCoordinatorParameters(userSession: userSession,
|
||||
selectedSpacePublisher: selectedSpaceSubject.asCurrentValuePublisher(),
|
||||
appSettings: flowParameters.appSettings,
|
||||
userIndicatorController: flowParameters.userIndicatorController)
|
||||
let coordinator = SpacesScreenCoordinator(parameters: parameters)
|
||||
coordinator.actionsPublisher
|
||||
.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
@@ -31,9 +31,9 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
private let onboardingFlowCoordinator: OnboardingFlowCoordinator
|
||||
private let onboardingStackCoordinator: NavigationStackCoordinator
|
||||
private let chatsFlowCoordinator: ChatsFlowCoordinator
|
||||
private let chatsTabFlowCoordinator: ChatsTabFlowCoordinator
|
||||
private let chatsTabDetails: NavigationTabCoordinator<HomeTab>.TabDetails
|
||||
private let spaceExplorerFlowCoordinator: SpaceExplorerFlowCoordinator
|
||||
private let spacesTabFlowCoordinator: SpacesTabFlowCoordinator
|
||||
private let spacesTabDetails: NavigationTabCoordinator<HomeTab>.TabDetails
|
||||
|
||||
// periphery:ignore - retaining purpose
|
||||
@@ -78,15 +78,15 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
navigationRootCoordinator.setRootCoordinator(navigationTabCoordinator)
|
||||
|
||||
let chatsSplitCoordinator = NavigationSplitCoordinator(placeholderCoordinator: PlaceholderScreenCoordinator(hideBrandChrome: flowParameters.appSettings.hideBrandChrome))
|
||||
chatsFlowCoordinator = ChatsFlowCoordinator(isNewLogin: isNewLogin,
|
||||
navigationSplitCoordinator: chatsSplitCoordinator,
|
||||
flowParameters: flowParameters)
|
||||
chatsTabFlowCoordinator = ChatsTabFlowCoordinator(isNewLogin: isNewLogin,
|
||||
navigationSplitCoordinator: chatsSplitCoordinator,
|
||||
flowParameters: flowParameters)
|
||||
chatsTabDetails = .init(tag: HomeTab.chats, title: L10n.screenHomeTabChats, icon: \.chat, selectedIcon: \.chatSolid)
|
||||
chatsTabDetails.navigationSplitCoordinator = chatsSplitCoordinator
|
||||
|
||||
let spacesSplitCoordinator = NavigationSplitCoordinator(placeholderCoordinator: PlaceholderScreenCoordinator(hideBrandChrome: flowParameters.appSettings.hideBrandChrome))
|
||||
spaceExplorerFlowCoordinator = SpaceExplorerFlowCoordinator(navigationSplitCoordinator: spacesSplitCoordinator,
|
||||
flowParameters: flowParameters)
|
||||
spacesTabFlowCoordinator = SpacesTabFlowCoordinator(navigationSplitCoordinator: spacesSplitCoordinator,
|
||||
flowParameters: flowParameters)
|
||||
spacesTabDetails = .init(tag: HomeTab.spaces, title: L10n.screenHomeTabSpaces, icon: \.space, selectedIcon: \.spaceSolid)
|
||||
spacesTabDetails.navigationSplitCoordinator = spacesSplitCoordinator
|
||||
|
||||
@@ -112,7 +112,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
|
||||
func stop() {
|
||||
chatsFlowCoordinator.stop()
|
||||
chatsTabFlowCoordinator.stop()
|
||||
}
|
||||
|
||||
func handleAppRoute(_ appRoute: AppRoute, animated: Bool) {
|
||||
@@ -133,7 +133,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
.event, .eventOnRoomAlias, .childEvent, .childEventOnRoomAlias,
|
||||
.share, .transferOwnership, .thread:
|
||||
clearPresentedSheets(animated: animated) // Make sure the presented route is visible.
|
||||
chatsFlowCoordinator.handleAppRoute(appRoute, animated: animated)
|
||||
chatsTabFlowCoordinator.handleAppRoute(appRoute, animated: animated)
|
||||
if navigationTabCoordinator.selectedTab != .chats {
|
||||
navigationTabCoordinator.selectedTab = .chats
|
||||
}
|
||||
@@ -142,7 +142,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
func clearRoute(animated: Bool) {
|
||||
clearPresentedSheets(animated: animated)
|
||||
chatsFlowCoordinator.clearRoute(animated: animated)
|
||||
chatsTabFlowCoordinator.clearRoute(animated: animated)
|
||||
}
|
||||
|
||||
// Clearing routes is more complicated than it first seems. When passing routes
|
||||
@@ -162,7 +162,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
func isDisplayingRoomScreen(withRoomID roomID: String) -> Bool {
|
||||
guard navigationTabCoordinator.selectedTab == .chats else { return false }
|
||||
return chatsFlowCoordinator.isDisplayingRoomScreen(withRoomID: roomID)
|
||||
return chatsTabFlowCoordinator.isDisplayingRoomScreen(withRoomID: roomID)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
@@ -171,8 +171,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
stateMachine.addRoutes(event: .start, transitions: [.initial => .tabBar]) { [weak self] _ in
|
||||
guard let self else { return }
|
||||
|
||||
chatsFlowCoordinator.start()
|
||||
spaceExplorerFlowCoordinator.start()
|
||||
chatsTabFlowCoordinator.start()
|
||||
spacesTabFlowCoordinator.start()
|
||||
attemptStartingOnboarding()
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
|
||||
private func setupObservers() {
|
||||
chatsFlowCoordinator.actionsPublisher
|
||||
chatsTabFlowCoordinator.actionsPublisher
|
||||
.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
switch action {
|
||||
@@ -211,7 +211,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
spaceExplorerFlowCoordinator.actionsPublisher
|
||||
spacesTabFlowCoordinator.actionsPublisher
|
||||
.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
switch action {
|
||||
@@ -499,7 +499,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
primaryButton: .init(title: L10n.screenSignoutConfirmationDialogSubmit, role: .destructive) { [weak self] in
|
||||
self?.actionsSubject.send(.logout)
|
||||
}, secondaryButton: .init(title: L10n.commonSettings, role: .cancel) { [weak self] in
|
||||
self?.chatsFlowCoordinator.handleAppRoute(.chatBackupSettings, animated: true)
|
||||
self?.chatsTabFlowCoordinator.handleAppRoute(.chatBackupSettings, animated: true)
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -511,7 +511,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
primaryButton: .init(title: L10n.screenSignoutConfirmationDialogSubmit, role: .destructive) { [weak self] in
|
||||
self?.actionsSubject.send(.logout)
|
||||
}, secondaryButton: .init(title: L10n.commonSettings, role: .cancel) { [weak self] in
|
||||
self?.chatsFlowCoordinator.handleAppRoute(.chatBackupSettings, animated: true)
|
||||
self?.chatsTabFlowCoordinator.handleAppRoute(.chatBackupSettings, animated: true)
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -540,7 +540,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
case .cancel:
|
||||
navigationTabCoordinator.setSheetCoordinator(nil)
|
||||
case .settings:
|
||||
chatsFlowCoordinator.handleAppRoute(.chatBackupSettings, animated: true)
|
||||
chatsTabFlowCoordinator.handleAppRoute(.chatBackupSettings, animated: true)
|
||||
navigationTabCoordinator.setSheetCoordinator(nil)
|
||||
case .logout:
|
||||
actionsSubject.send(.logout)
|
||||
|
||||
Reference in New Issue
Block a user