Epic: create and join rooms - Start Chat (#680)

* add start chat flow with UI

* add feature flag for start chat

* add changelog

* fix naming and tests

* fix empty display name in user cell

* Update ElementX/Sources/Application/AppSettings.swift

Co-authored-by: Alfonso Grillo <alfogrillo@element.io>

* add screenshots from UI test

* fix swiftFormat and add identifiers

* fix warnings

---------

Co-authored-by: Alfonso Grillo <alfogrillo@element.io>
This commit is contained in:
Flescio
2023-03-14 10:50:09 +01:00
committed by GitHub
parent 7eef86970a
commit 8a069ecfa5
29 changed files with 495 additions and 2 deletions
@@ -102,6 +102,10 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
case (.feedbackScreen, .dismissedFeedbackScreen, .roomList):
break
case (.roomList, .showStartChatScreen, .startChatScreen):
self.presentStartChat()
case (.startChatScreen, .dismissedStartChatScreen, .roomList):
break
default:
fatalError("Unknown transition: \(context)")
}
@@ -133,6 +137,8 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
self.stateMachine.processEvent(.feedbackScreen)
case .presentSessionVerificationScreen:
self.stateMachine.processEvent(.showSessionVerificationScreen)
case .presentStartChatScreen:
self.stateMachine.processEvent(.showStartChatScreen)
case .signOut:
self.callback?(.signOut)
}
@@ -235,6 +241,30 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
self?.stateMachine.processEvent(.dismissedSessionVerificationScreen)
}
}
// MARK: Start Chat
private func presentStartChat() {
let startChatNavigationStackCoordinator = NavigationStackCoordinator()
let userIndicatorController = UserIndicatorController(rootCoordinator: startChatNavigationStackCoordinator)
let parameters = StartChatCoordinatorParameters(userSession: userSession)
let coordinator = StartChatCoordinator(parameters: parameters)
coordinator.callback = { [weak self] action in
guard let self else { return }
switch action {
case .close:
self.navigationSplitCoordinator.setSheetCoordinator(nil)
}
}
startChatNavigationStackCoordinator.setRootCoordinator(coordinator)
navigationSplitCoordinator.setSheetCoordinator(userIndicatorController) { [weak self] in
self?.stateMachine.processEvent(.dismissedStartChatScreen)
}
}
// MARK: Bug reporting
@@ -34,6 +34,9 @@ class UserSessionFlowCoordinatorStateMachine {
/// Showing the settings screen
case settingsScreen(selectedRoomId: String?)
/// Showing the start chat screen
case startChatScreen(selectedRoomId: String?)
}
/// Events that can be triggered on the AppCoordinator state machine
@@ -61,6 +64,11 @@ class UserSessionFlowCoordinatorStateMachine {
case showSessionVerificationScreen
/// Session verification has finished
case dismissedSessionVerificationScreen
/// Request the start of the start chat flow
case showStartChatScreen
/// Start chat has been dismissed
case dismissedStartChatScreen
}
private let stateMachine: StateMachine<State, Event>
@@ -74,6 +82,7 @@ class UserSessionFlowCoordinatorStateMachine {
configure()
}
// swiftlint:disable:next cyclomatic_complexity
private func configure() {
stateMachine.addRoutes(event: .start, transitions: [.initial => .roomList(selectedRoomId: nil)])
@@ -99,6 +108,10 @@ class UserSessionFlowCoordinatorStateMachine {
case (.dismissedSessionVerificationScreen, .sessionVerificationScreen(let selectedRoomId)):
return .roomList(selectedRoomId: selectedRoomId)
case (.showStartChatScreen, .roomList(let selectedRoomId)):
return .startChatScreen(selectedRoomId: selectedRoomId)
case (.dismissedStartChatScreen, .startChatScreen(let selectedRoomId)):
return .roomList(selectedRoomId: selectedRoomId)
default:
return nil
}