This commit is contained in:
Aleksandrs Proskurins
2022-10-06 10:23:33 +03:00
parent 430ad84346
commit 586756251e
4 changed files with 71 additions and 5 deletions
@@ -25,6 +25,7 @@ enum MockUserOtherSessionsScreenState: MockScreenState, CaseIterable {
// mock that screen.
case inactiveSessions
case unverifiedSessions
/// The associated screen
var screenType: Any.Type {
@@ -34,15 +35,23 @@ enum MockUserOtherSessionsScreenState: MockScreenState, CaseIterable {
/// A list of screen state definitions
static var allCases: [MockUserOtherSessionsScreenState] {
// Each of the presence statuses
[.inactiveSessions]
[.inactiveSessions, .unverifiedSessions]
}
/// Generate the view struct for the screen state.
var screenView: ([Any], AnyView) {
let viewModel = UserOtherSessionsViewModel(sessionInfos: inactiveSessions(),
let viewModel: UserOtherSessionsViewModel
switch self {
case .inactiveSessions:
viewModel = UserOtherSessionsViewModel(sessionInfos: inactiveSessions(),
filter: .inactive,
title: VectorL10n.userOtherSessionSecurityRecommendationTitle)
case .unverifiedSessions:
viewModel = UserOtherSessionsViewModel(sessionInfos: unverifiedSessions(),
filter: .unverified,
title: VectorL10n.userOtherSessionSecurityRecommendationTitle)
}
// can simulate service and viewModel actions here if needs be.
@@ -118,4 +127,40 @@ enum MockUserOtherSessionsScreenState: MockScreenState, CaseIterable {
isActive: false,
isCurrent: false)]
}
private func unverifiedSessions() -> [UserSessionInfo] {
[UserSessionInfo(id: "0",
name: "iOS",
deviceType: .mobile,
isVerified: false,
lastSeenIP: "10.0.0.10",
lastSeenTimestamp: nil,
applicationName: nil,
applicationVersion: nil,
applicationURL: nil,
deviceModel: nil,
deviceOS: nil,
lastSeenIPLocation: nil,
clientName: nil,
clientVersion: nil,
isActive: true,
isCurrent: true),
UserSessionInfo(id: "1",
name: "macOS",
deviceType: .desktop,
isVerified: false,
lastSeenIP: "1.0.0.1",
lastSeenTimestamp: Date().timeIntervalSince1970 - 8000000,
applicationName: nil,
applicationVersion: nil,
applicationURL: nil,
deviceModel: nil,
deviceOS: nil,
lastSeenIPLocation: nil,
clientName: nil,
clientVersion: nil,
isActive: true,
isCurrent: false)
]
}
}