Welcome Screen (#1259)

* the screen renders and changed the analytics checkmark to be more generic

* welcome screen

* transition

* tests... TODO

* changelog

* changed assets and added multilineTextAlignment

* better naming

* fix for missing after migration but has a weird presentaiton bug

* fix

* icon color
This commit is contained in:
Mauro
2023-07-05 19:55:24 +02:00
committed by GitHub
parent 9ebc57e1cf
commit 00636d98da
17 changed files with 501 additions and 49 deletions
@@ -37,7 +37,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
private let sidebarNavigationStackCoordinator: NavigationStackCoordinator
private let detailNavigationStackCoordinator: NavigationStackCoordinator
private let selectedRoomSubject = CurrentValueSubject<String?, Never>(nil)
var callback: ((UserSessionFlowCoordinatorAction) -> Void)?
@@ -85,6 +85,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
if appSettings.migratedAccounts[userSession.userID] != true {
// Show the migration screen for a new account.
stateMachine.processEvent(.startWithMigration)
} else if !appSettings.hasShownWelcomeScreen {
stateMachine.processEvent(.startWithWelcomeScreen)
} else {
// Otherwise go straight to the home screen.
stateMachine.processEvent(.start)
@@ -106,7 +108,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
return // Not ready to handle a route.
case .roomList:
break // Nothing to tidy up on the home screen.
case .feedbackScreen, .sessionVerificationScreen, .settingsScreen, .startChatScreen, .invitesScreen:
case .feedbackScreen, .sessionVerificationScreen, .settingsScreen, .startChatScreen, .invitesScreen, .welcomeScreen:
navigationSplitCoordinator.setSheetCoordinator(nil, animated: animated)
}
@@ -135,13 +137,21 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
let animated = (context.userInfo as? UserSessionFlowCoordinatorStateMachine.EventUserInfo)?.animated ?? true
switch (context.fromState, context.event, context.toState) {
case (.initial, .start, .roomList):
self.presentHomeScreen()
presentHomeScreen()
case (.initial, .startWithMigration, .migration):
self.presentMigrationScreen() // Full screen cover
self.presentHomeScreen() // Have the home screen ready to show underneath
presentMigrationScreen() // Full screen cover
presentHomeScreen() // Have the home screen ready to show underneath
case (.migration, .completeMigration, .roomList):
self.dismissMigrationScreen()
dismissMigrationScreen()
case (.initial, .startWithWelcomeScreen, .welcomeScreen):
presentHomeScreen()
presentWelcomeScreen()
case (.roomList, .presentWelcomeScreen, .welcomeScreen):
presentWelcomeScreen()
case (.welcomeScreen, .dismissedWelcomeScreen, .roomList):
break
case(.roomList, .selectRoom, .roomList):
break
@@ -154,27 +164,27 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
break
case (.roomList, .showSessionVerificationScreen, .sessionVerificationScreen):
self.presentSessionVerification(animated: animated)
presentSessionVerification(animated: animated)
case (.sessionVerificationScreen, .dismissedSessionVerificationScreen, .roomList):
break
case (.roomList, .showSettingsScreen, .settingsScreen):
self.presentSettingsScreen(animated: animated)
presentSettingsScreen(animated: animated)
case (.settingsScreen, .dismissedSettingsScreen, .roomList):
break
case (.roomList, .feedbackScreen, .feedbackScreen):
self.presentFeedbackScreen(animated: animated)
presentFeedbackScreen(animated: animated)
case (.feedbackScreen, .dismissedFeedbackScreen, .roomList):
break
case (.roomList, .showStartChatScreen, .startChatScreen):
self.presentStartChat(animated: animated)
presentStartChat(animated: animated)
case (.startChatScreen, .dismissedStartChatScreen, .roomList):
break
case (.roomList, .showInvitesScreen, .invitesScreen):
self.presentInvitesList(animated: animated)
presentInvitesList(animated: animated)
case (.invitesScreen, .showInvitesScreen, .invitesScreen):
break
case (.invitesScreen, .closedInvitesScreen, .roomList):
@@ -216,6 +226,14 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
private func dismissMigrationScreen() {
navigationSplitCoordinator.setFullScreenCoverCoordinator(nil)
// Not sure why but the full screen closure dismissal closure doesn't seem to work properly
// And not using the DispatchQueue.main results in the the screen getting presented as full screen too.
if !appSettings.hasShownWelcomeScreen {
DispatchQueue.main.async {
self.stateMachine.processEvent(.presentWelcomeScreen)
}
}
}
// swiftlint:disable:next cyclomatic_complexity
@@ -257,6 +275,21 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
sidebarNavigationStackCoordinator.setRootCoordinator(coordinator)
}
private func presentWelcomeScreen() {
let welcomeScreenCoordinator = WelcomeScreenScreenCoordinator()
welcomeScreenCoordinator.actions.sink { [weak self] action in
switch action {
case .dismiss:
self?.navigationSplitCoordinator.setSheetCoordinator(nil)
}
}
.store(in: &cancellables)
navigationSplitCoordinator.setSheetCoordinator(welcomeScreenCoordinator) { [weak self] in
self?.stateMachine.processEvent(.dismissedWelcomeScreen)
}
}
// MARK: Settings
@@ -25,6 +25,9 @@ class UserSessionFlowCoordinatorStateMachine {
/// Showing the migration screen whilst the proxy performs an initial sync.
case migration
/// Showing the welcome screen.
case welcomeScreen
/// Showing the home screen. The `selectedRoomId` represents the timeline shown on the detail panel (if any)
case roomList(selectedRoomId: String?)
@@ -53,11 +56,15 @@ class UserSessionFlowCoordinatorStateMachine {
enum Event: EventType {
/// Start the user session flows
case start
/// Starts the user session flows with the welcome screen
case startWithWelcomeScreen
/// Start the user session flows with a migration screen.
case startWithMigration
/// Request to transition from the migration state to the home screen.
case completeMigration
case presentWelcomeScreen
case dismissedWelcomeScreen
/// Request presentation for a particular room
/// - Parameter roomId:the room identifier
@@ -106,8 +113,10 @@ class UserSessionFlowCoordinatorStateMachine {
private func configure() {
stateMachine.addRoutes(event: .start, transitions: [.initial => .roomList(selectedRoomId: nil)])
stateMachine.addRoutes(event: .startWithMigration, transitions: [.initial => .migration])
stateMachine.addRoutes(event: .startWithWelcomeScreen, transitions: [.initial => .welcomeScreen])
stateMachine.addRoutes(event: .completeMigration, transitions: [.migration => .roomList(selectedRoomId: nil)])
stateMachine.addRoutes(event: .dismissedWelcomeScreen, transitions: [.welcomeScreen => .roomList(selectedRoomId: nil)])
stateMachine.addRouteMapping { event, fromState, _ in
switch (event, fromState) {
case (.selectRoom(let roomId), .roomList):
@@ -146,6 +155,9 @@ class UserSessionFlowCoordinatorStateMachine {
case (.closedInvitesScreen, .invitesScreen(let selectedRoomId)):
return .roomList(selectedRoomId: selectedRoomId)
case (.presentWelcomeScreen, .roomList):
return .welcomeScreen
default:
return nil