added animated to the start of a flow coordinator

This commit is contained in:
Mauro Romito
2025-10-28 14:54:58 +01:00
committed by Mauro
parent aedc1cbf1f
commit 0002065833
17 changed files with 32 additions and 29 deletions

View File

@@ -11,11 +11,17 @@ import Foundation
// periphery:ignore - markdown protocol
@MainActor
protocol FlowCoordinatorProtocol {
func start()
func start(animated: Bool)
func handleAppRoute(_ appRoute: AppRoute, animated: Bool)
func clearRoute(animated: Bool)
}
extension FlowCoordinatorProtocol {
func start() {
start(animated: true)
}
}
/// Core parameters that are shared across the main flows for easy dependency injection.
///
/// Please do **not** pass this type directly to screen coordinators/view models.

View File

@@ -85,7 +85,7 @@ class AppLockSetupFlowCoordinator: FlowCoordinatorProtocol {
configureStateMachine()
}
func start() {
func start(animated: Bool) {
stateMachine.tryEvent(.start)
}

View File

@@ -122,7 +122,7 @@ class AuthenticationFlowCoordinator: FlowCoordinatorProtocol {
configureStateMachine()
}
func start() {
func start(animated: Bool) {
stateMachine.tryEvent(.start)
}

View File

@@ -50,7 +50,7 @@ class BugReportFlowCoordinator: FlowCoordinatorProtocol {
self.parameters = parameters
}
func start() {
func start(animated: Bool) {
presentBugReportScreen()
}

View File

@@ -70,7 +70,7 @@ class ChatsFlowCoordinator: FlowCoordinatorProtocol {
setupObservers()
}
func start() {
func start(animated: Bool) {
stateMachine.processEvent(.start)
}

View File

@@ -71,7 +71,7 @@ class EncryptionResetFlowCoordinator: FlowCoordinatorProtocol {
configureStateMachine()
}
func start() {
func start(animated: Bool) {
stateMachine.tryEvent(.start)
}

View File

@@ -72,7 +72,7 @@ class EncryptionSettingsFlowCoordinator: FlowCoordinatorProtocol {
configureStateMachine()
}
func start() {
func start(animated: Bool) {
stateMachine.tryEvent(.start)
}

View File

@@ -37,7 +37,7 @@ class MediaEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
self.flowParameters = flowParameters
}
func start() {
func start(animated: Bool) {
Task { await presentMediaEventsTimeline() }
}

View File

@@ -103,7 +103,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
return isNewLogin || requiresVerification || requiresAppLockSetup || requiresAnalyticsSetup || requiresNotificationsSetup
}
func start() {
func start(animated: Bool) {
guard shouldStart else {
fatalError("This flow coordinator shouldn't have been started")
}

View File

@@ -38,7 +38,7 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
self.flowParameters = flowParameters
}
func start() {
func start(animated: Bool) {
Task { await presentPinnedEventsTimeline() }
}

View File

@@ -115,7 +115,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
// MARK: - FlowCoordinatorProtocol
func start() {
func start(animated: Bool) {
fatalError("This flow coordinator expect a route")
}
@@ -1550,12 +1550,11 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
spaceFlowCoordinator = coordinator
coordinator.start()
coordinator.start(animated: animated)
}
private func startMembersFlow(entryPoint: RoomMembersFlowCoordinatorEntryPoint, animated: Bool) {
let flowCoordinator = RoomMembersFlowCoordinator(entryPoint: entryPoint,
animatedEntry: animated,
roomProxy: roomProxy,
navigationStackCoordinator: navigationStackCoordinator,
flowParameters: flowParameters)
@@ -1573,7 +1572,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
}
.store(in: &cancellables)
flowCoordinator.start()
flowCoordinator.start(animated: animated)
membersFlowCoordinator = flowCoordinator
}

View File

@@ -57,7 +57,6 @@ final class RoomMembersFlowCoordinator: FlowCoordinatorProtocol {
}
private let entryPoint: RoomMembersFlowCoordinatorEntryPoint
private let animatedEntry: Bool
private let roomProxy: JoinedRoomProxyProtocol
private let navigationStackCoordinator: NavigationStackCoordinator
private let flowParameters: CommonFlowParameters
@@ -73,7 +72,6 @@ final class RoomMembersFlowCoordinator: FlowCoordinatorProtocol {
private var roomFlowCoordinator: RoomFlowCoordinator?
init(entryPoint: RoomMembersFlowCoordinatorEntryPoint,
animatedEntry: Bool,
roomProxy: JoinedRoomProxyProtocol,
navigationStackCoordinator: NavigationStackCoordinator,
flowParameters: CommonFlowParameters) {
@@ -81,18 +79,17 @@ final class RoomMembersFlowCoordinator: FlowCoordinatorProtocol {
self.roomProxy = roomProxy
self.flowParameters = flowParameters
self.navigationStackCoordinator = navigationStackCoordinator
self.animatedEntry = animatedEntry
stateMachine = .init(state: .initial)
configureStateMachine()
}
func start() {
func start(animated: Bool) {
switch entryPoint {
case .roomMember(let userID):
stateMachine.tryEvent(.presentRoomMemberDetails(userID: userID), userInfo: animatedEntry)
stateMachine.tryEvent(.presentRoomMemberDetails(userID: userID), userInfo: animated)
case .roomMembersList:
stateMachine.tryEvent(.presentRoomMembersList, userInfo: animatedEntry)
stateMachine.tryEvent(.presentRoomMembersList, userInfo: animated)
}
}
@@ -116,9 +113,11 @@ final class RoomMembersFlowCoordinator: FlowCoordinatorProtocol {
} else {
stateMachine.tryEvent(.startRoomFlow(roomID: roomID, via: via, eventID: eventID), userInfo: animated)
}
case .accountProvisioningLink, .roomList, .room, .roomAlias, .childRoomAlias, .roomDetails, .event,
.eventOnRoomAlias, .childEventOnRoomAlias, .userProfile, .call, .genericCallLink, .settings,
.chatBackupSettings, .share, .transferOwnership, .thread:
case .roomAlias, .childRoomAlias, .eventOnRoomAlias, .childEventOnRoomAlias:
break // These are converted to a room ID route one level above.
case .accountProvisioningLink, .roomList, .room, .roomDetails, .event,
.userProfile, .call, .genericCallLink, .settings, .chatBackupSettings,
.share, .transferOwnership, .thread:
break
}
}

View File

@@ -77,7 +77,7 @@ class RoomRolesAndPermissionsFlowCoordinator: FlowCoordinatorProtocol {
configureStateMachine()
}
func start() {
func start(animated: Bool) {
stateMachine.tryEvent(.start)
}

View File

@@ -44,7 +44,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
self.flowParameters = flowParameters
}
func start() {
func start(animated: Bool) {
fatalError("Unavailable")
}

View File

@@ -68,7 +68,7 @@ class SpaceExplorerFlowCoordinator: FlowCoordinatorProtocol {
configureStateMachine()
}
func start() {
func start(animated: Bool) {
stateMachine.tryEvent(.start)
}

View File

@@ -109,7 +109,7 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
configureStateMachine()
}
func start() {
func start(animated: Bool) {
switch entryPoint {
case .space:
stateMachine.tryEvent(.start)
@@ -373,7 +373,6 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
private func startMembersFlow(roomProxy: JoinedRoomProxyProtocol) async {
let flowCoordinator = RoomMembersFlowCoordinator(entryPoint: .roomMembersList,
animatedEntry: true,
roomProxy: roomProxy,
navigationStackCoordinator: navigationStackCoordinator,
flowParameters: flowParameters)

View File

@@ -108,7 +108,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
setupObservers()
}
func start() {
func start(animated: Bool) {
stateMachine.tryEvent(.start)
}