Migration Screen (#1224)

- Hide bottom bar when in skeletons.
- Use the new design for the Waitlist screen too.
This commit is contained in:
Doug
2023-06-30 13:27:49 +01:00
committed by GitHub
parent c5d47378a4
commit 2025dd9517
38 changed files with 528 additions and 52 deletions
@@ -27,11 +27,13 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
private let navigationSplitCoordinator: NavigationSplitCoordinator
private let bugReportService: BugReportServiceProtocol
private let roomTimelineControllerFactory: RoomTimelineControllerFactoryProtocol
private let appSettings: AppSettings
private let stateMachine: UserSessionFlowCoordinatorStateMachine
private let roomFlowCoordinator: RoomFlowCoordinator
private var cancellables: Set<AnyCancellable> = .init()
private var migrationCancellable: AnyCancellable?
private let sidebarNavigationStackCoordinator: NavigationStackCoordinator
private let detailNavigationStackCoordinator: NavigationStackCoordinator
@@ -43,12 +45,14 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
init(userSession: UserSessionProtocol,
navigationSplitCoordinator: NavigationSplitCoordinator,
bugReportService: BugReportServiceProtocol,
roomTimelineControllerFactory: RoomTimelineControllerFactoryProtocol) {
roomTimelineControllerFactory: RoomTimelineControllerFactoryProtocol,
appSettings: AppSettings) {
stateMachine = UserSessionFlowCoordinatorStateMachine()
self.userSession = userSession
self.navigationSplitCoordinator = navigationSplitCoordinator
self.bugReportService = bugReportService
self.roomTimelineControllerFactory = roomTimelineControllerFactory
self.appSettings = appSettings
sidebarNavigationStackCoordinator = NavigationStackCoordinator(navigationSplitCoordinator: navigationSplitCoordinator)
detailNavigationStackCoordinator = NavigationStackCoordinator(navigationSplitCoordinator: navigationSplitCoordinator)
@@ -78,7 +82,13 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
}
func start() {
stateMachine.processEvent(.start)
if appSettings.migratedAccounts[userSession.userID] != true {
// Show the migration screen for a new account.
stateMachine.processEvent(.startWithMigration)
} else {
// Otherwise go straight to the home screen.
stateMachine.processEvent(.start)
}
}
func stop() { }
@@ -90,13 +100,17 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
// MARK: - FlowCoordinatorProtocol
func handleAppRoute(_ appRoute: AppRoute, animated: Bool) {
// Tidy up any state before applying the new route.
switch stateMachine.state {
case .initial, .migration:
return // Not ready to handle a route.
case .roomList:
break // Nothing to tidy up on the home screen.
case .feedbackScreen, .sessionVerificationScreen, .settingsScreen, .startChatScreen, .invitesScreen:
navigationSplitCoordinator.setSheetCoordinator(nil, animated: animated)
case .roomList, .initial:
break
}
// Apply the route.
switch appRoute {
case .room, .roomDetails, .roomList:
roomFlowCoordinator.handleAppRoute(appRoute, animated: animated)
@@ -122,6 +136,12 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
switch (context.fromState, context.event, context.toState) {
case (.initial, .start, .roomList):
self.presentHomeScreen()
case (.initial, .startWithMigration, .migration):
self.presentMigrationScreen() // Full screen cover
self.presentHomeScreen() // Have the home screen ready to show underneath
case (.migration, .completeMigration, .roomList):
self.dismissMigrationScreen()
case(.roomList, .selectRoom, .roomList):
break
@@ -179,6 +199,25 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
}
}
private func presentMigrationScreen() {
// Listen for the first sync to finish.
migrationCancellable = userSession.clientProxy.callbacks
.receive(on: DispatchQueue.main)
.sink { [weak self] callback in
guard let self, stateMachine.state == .migration, case .receivedSyncUpdate = callback else { return }
migrationCancellable = nil
appSettings.migratedAccounts[userSession.userID] = true
stateMachine.processEvent(.completeMigration)
}
let coordinator = MigrationScreenCoordinator()
navigationSplitCoordinator.setFullScreenCoverCoordinator(coordinator)
}
private func dismissMigrationScreen() {
navigationSplitCoordinator.setFullScreenCoverCoordinator(nil)
}
// swiftlint:disable:next cyclomatic_complexity
private func presentHomeScreen() {
let parameters = HomeScreenCoordinatorParameters(userSession: userSession,
@@ -23,6 +23,9 @@ class UserSessionFlowCoordinatorStateMachine {
/// The initial state, used before the coordinator starts
case initial
/// Showing the migration screen whilst the proxy performs an initial sync.
case migration
/// Showing the home screen. The `selectedRoomId` represents the timeline shown on the detail panel (if any)
case roomList(selectedRoomId: String?)
@@ -51,6 +54,11 @@ class UserSessionFlowCoordinatorStateMachine {
/// Start the user session flows
case start
/// Start the user session flows with a migration screen.
case startWithMigration
/// Request to transition from the migration state to the home screen.
case completeMigration
/// Request presentation for a particular room
/// - Parameter roomId:the room identifier
case selectRoom(roomId: String)
@@ -97,7 +105,9 @@ class UserSessionFlowCoordinatorStateMachine {
// swiftlint:disable:next cyclomatic_complexity
private func configure() {
stateMachine.addRoutes(event: .start, transitions: [.initial => .roomList(selectedRoomId: nil)])
stateMachine.addRoutes(event: .startWithMigration, transitions: [.initial => .migration])
stateMachine.addRoutes(event: .completeMigration, transitions: [.migration => .roomList(selectedRoomId: nil)])
stateMachine.addRouteMapping { event, fromState, _ in
switch (event, fromState) {
case (.selectRoom(let roomId), .roomList):