mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-20 16:42:44 +02:00
Session overview screen
This commit is contained in:
+8
-11
@@ -72,12 +72,12 @@ final class UserSessionsOverviewCoordinator: Coordinator, Presentable {
|
||||
self.showAllInactiveSessions()
|
||||
case .verifyCurrentSession:
|
||||
self.startVerifyCurrentSession()
|
||||
case .showCurrentSessionDetails:
|
||||
self.showCurrentSessionDetails()
|
||||
case let .showCurrentSessionOverview(sessionInfo):
|
||||
self.showCurrentSessionOverview(sessionInfo: sessionInfo)
|
||||
case .showAllOtherSessions:
|
||||
self.showAllOtherSessions()
|
||||
case .showUserSessionDetails(let sessionId):
|
||||
self.showUserSessionDetails(sessionId: sessionId)
|
||||
case let .showUserSessionOverview(sessionInfo):
|
||||
self.showUserSessionOverview(sessionInfo: sessionInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,15 +113,12 @@ final class UserSessionsOverviewCoordinator: Coordinator, Presentable {
|
||||
// TODO
|
||||
}
|
||||
|
||||
private func showCurrentSessionDetails() {
|
||||
// TODO
|
||||
private func showCurrentSessionOverview(sessionInfo: UserSessionInfo) {
|
||||
completion?(.openSessionOverview(session: sessionInfo, isCurrentSession: true))
|
||||
}
|
||||
|
||||
private func showUserSessionDetails(sessionId: String) {
|
||||
guard let sessionInfo = service.getOtherSession(sessionId: sessionId) else {
|
||||
return
|
||||
}
|
||||
completion?(.openSessionDetails(session: sessionInfo))
|
||||
private func showUserSessionOverview(sessionInfo: UserSessionInfo) {
|
||||
completion?(.openSessionOverview(session: sessionInfo, isCurrentSession: false))
|
||||
}
|
||||
|
||||
private func showAllOtherSessions() {
|
||||
|
||||
+5
-1
@@ -17,13 +17,17 @@
|
||||
import Foundation
|
||||
|
||||
class MockUserSessionsOverviewService: UserSessionsOverviewServiceProtocol {
|
||||
|
||||
|
||||
var lastOverviewData: UserSessionsOverviewData
|
||||
|
||||
func fetchUserSessionsOverviewData(completion: @escaping (Result<UserSessionsOverviewData, Error>) -> Void) {
|
||||
completion(.success(self.lastOverviewData))
|
||||
}
|
||||
|
||||
func getOtherSession(sessionId: String) -> UserSessionInfo? {
|
||||
nil
|
||||
}
|
||||
|
||||
init() {
|
||||
let currentSessionInfo = UserSessionInfo(sessionId: "alice", sessionName: "iOS", deviceType: .mobile, isVerified: false, lastSeenIP: "10.0.0.10", lastSeenTimestamp: nil)
|
||||
|
||||
|
||||
+2
@@ -29,4 +29,6 @@ protocol UserSessionsOverviewServiceProtocol {
|
||||
var lastOverviewData: UserSessionsOverviewData { get }
|
||||
|
||||
func fetchUserSessionsOverviewData(completion: @escaping (Result<UserSessionsOverviewData, Error>) -> Void) -> Void
|
||||
|
||||
func getOtherSession(sessionId: String) -> UserSessionInfo?
|
||||
}
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ import Foundation
|
||||
// MARK: - Coordinator
|
||||
|
||||
enum UserSessionsOverviewCoordinatorResult {
|
||||
case openSessionDetails(session: UserSessionInfo)
|
||||
case openSessionOverview(session: UserSessionInfo, isCurrentSession: Bool)
|
||||
}
|
||||
|
||||
// MARK: View model
|
||||
@@ -28,9 +28,9 @@ enum UserSessionsOverviewViewModelResult {
|
||||
case showAllUnverifiedSessions
|
||||
case showAllInactiveSessions
|
||||
case verifyCurrentSession
|
||||
case showCurrentSessionDetails
|
||||
case showCurrentSessionOverview(sessionInfo: UserSessionInfo)
|
||||
case showAllOtherSessions
|
||||
case showUserSessionDetails(_ sessionId: String)
|
||||
case showUserSessionOverview(sessionInfo: UserSessionInfo)
|
||||
}
|
||||
|
||||
// MARK: View
|
||||
|
||||
+10
-2
@@ -53,7 +53,11 @@ class UserSessionsOverviewViewModel: UserSessionsOverviewViewModelType, UserSess
|
||||
case .verifyCurrentSession:
|
||||
self.completion?(.verifyCurrentSession)
|
||||
case .viewCurrentSessionDetails:
|
||||
self.completion?(.showCurrentSessionDetails)
|
||||
guard let currentSessionInfo = userSessionsOverviewService.lastOverviewData.currentSessionInfo else {
|
||||
assertionFailure("currentSessionInfo should be present")
|
||||
return
|
||||
}
|
||||
self.completion?(.showCurrentSessionOverview(sessionInfo: currentSessionInfo))
|
||||
case .viewAllUnverifiedSessions:
|
||||
self.completion?(.showAllUnverifiedSessions)
|
||||
case .viewAllInactiveSessions:
|
||||
@@ -61,7 +65,11 @@ class UserSessionsOverviewViewModel: UserSessionsOverviewViewModelType, UserSess
|
||||
case .viewAllOtherSessions:
|
||||
self.completion?(.showAllOtherSessions)
|
||||
case .tapUserSession(let sessionId):
|
||||
self.completion?(.showUserSessionDetails(sessionId))
|
||||
guard let sessionInfo = userSessionsOverviewService.getOtherSession(sessionId: sessionId) else {
|
||||
assertionFailure("missing session info")
|
||||
return
|
||||
}
|
||||
self.completion?(.showUserSessionOverview(sessionInfo: sessionInfo))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-4
@@ -64,10 +64,7 @@ struct UserSessionListItem: View {
|
||||
|
||||
// Separator
|
||||
// Note: Separator leading is matching the text leading, we could use alignment guide in the future
|
||||
Rectangle()
|
||||
.fill(theme.colors.quinaryContent)
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
.frame(height: 1.0)
|
||||
SeparatorLine()
|
||||
.padding(.leading, LayoutConstants.horizontalPadding + LayoutConstants.avatarRightMargin + LayoutConstants.avatarWidth)
|
||||
}
|
||||
.padding(.top, LayoutConstants.verticalPadding)
|
||||
|
||||
Reference in New Issue
Block a user