Create UserSessionsOverview screen.

This commit is contained in:
SBiOSoftWhare
2022-09-05 11:15:37 +02:00
parent 33a93c9e6e
commit d87fc2dc73
5 changed files with 178 additions and 12 deletions
@@ -31,6 +31,9 @@ final class UserSessionsOverviewCoordinator: Coordinator, Presentable {
private let userSessionsOverviewHostingController: UIViewController
private var userSessionsOverviewViewModel: UserSessionsOverviewViewModelProtocol
private var indicatorPresenter: UserIndicatorTypePresenterProtocol
private var loadingIndicator: UserIndicator?
// MARK: Public
// Must be used only internally
@@ -41,10 +44,15 @@ final class UserSessionsOverviewCoordinator: Coordinator, Presentable {
init(parameters: UserSessionsOverviewCoordinatorParameters) {
self.parameters = parameters
let viewModel = UserSessionsOverviewViewModel(userSessionsOverviewService: UserSessionsOverviewService())
let viewModel = UserSessionsOverviewViewModel(userSessionsOverviewService: UserSessionsOverviewService(mxSession: parameters.session))
let view = UserSessionsOverview(viewModel: viewModel.context)
userSessionsOverviewViewModel = viewModel
userSessionsOverviewHostingController = VectorHostingController(rootView: view)
let hostingViewController = VectorHostingController(rootView: view)
userSessionsOverviewHostingController = hostingViewController
indicatorPresenter = UserIndicatorTypePresenter(presentingViewController: hostingViewController)
}
// MARK: - Public
@@ -55,8 +63,22 @@ final class UserSessionsOverviewCoordinator: Coordinator, Presentable {
guard let self = self else { return }
MXLog.debug("[UserSessionsOverviewCoordinator] UserSessionsOverviewViewModel did complete with result: \(result).")
switch result {
case .done:
case .cancel:
self.completion?()
case .loadData:
self.loadData()
case .showAllUnverifiedSessions:
self.showAllUnverifiedSessions()
case .showAllInactiveSessions:
self.showAllInactiveSessions()
case .verifyCurrentSession:
self.startVerifyCurrentSession()
case .showCurrentSessionDetails:
self.showCurrentSessionDetails()
case .showAllOtherSessions:
self.showAllOtherSessions()
case .showUserSessionDetails(let sessionId):
self.showUserSessionDetails(sessionId: sessionId)
}
}
}
@@ -64,4 +86,47 @@ final class UserSessionsOverviewCoordinator: Coordinator, Presentable {
func toPresentable() -> UIViewController {
return self.userSessionsOverviewHostingController
}
// MARK: - Private
/// Show an activity indicator whilst loading.
/// - Parameters:
/// - label: The label to show on the indicator.
/// - isInteractionBlocking: Whether the indicator should block any user interaction.
private func startLoading(label: String = VectorL10n.loading, isInteractionBlocking: Bool = true) {
loadingIndicator = indicatorPresenter.present(.loading(label: label, isInteractionBlocking: isInteractionBlocking))
}
/// Hide the currently displayed activity indicator.
private func stopLoading() {
loadingIndicator = nil
}
private func loadData() {
// TODO
}
private func showAllUnverifiedSessions() {
// TODO
}
private func showAllInactiveSessions() {
// TODO
}
private func startVerifyCurrentSession() {
// TODO
}
private func showCurrentSessionDetails() {
// TODO
}
private func showUserSessionDetails(sessionId: String) {
// TODO
}
private func showAllOtherSessions() {
// TODO
}
}