Sing out filtering

This commit is contained in:
Aleksandrs Proskurins
2022-10-27 17:35:39 +03:00
parent 59ee1f3513
commit f0c69a6370
10 changed files with 62 additions and 10 deletions
@@ -71,6 +71,8 @@ final class UserSessionsOverviewCoordinator: Coordinator, Presentable {
self.showUserSessionOverview(sessionInfo: sessionInfo)
case .linkDevice:
self.completion?(.linkDevice)
case let .singOutFromUserSessions(sessionInfos: sessionInfos):
self.completion?(.singOutFromUserSessions(sessionInfos: sessionInfos))
}
}
}
@@ -25,6 +25,7 @@ enum UserSessionsOverviewCoordinatorResult {
case openSessionOverview(sessionInfo: UserSessionInfo)
case openOtherSessions(sessionInfos: [UserSessionInfo], filter: UserOtherSessionsFilter)
case linkDevice
case singOutFromUserSessions(sessionInfos: [UserSessionInfo])
}
// MARK: View model
@@ -37,6 +38,7 @@ enum UserSessionsOverviewViewModelResult: Equatable {
case showCurrentSessionOverview(sessionInfo: UserSessionInfo)
case showUserSessionOverview(sessionInfo: UserSessionInfo)
case linkDevice
case singOutFromUserSessions(sessionInfos: [UserSessionInfo])
}
// MARK: View
@@ -66,4 +68,5 @@ enum UserSessionsOverviewViewAction {
case viewAllOtherSessions
case tapUserSession(_ sessionId: String)
case linkDevice
case signOutOtherSessions
}
@@ -76,6 +76,8 @@ class UserSessionsOverviewViewModel: UserSessionsOverviewViewModelType, UserSess
completion?(.showUserSessionOverview(sessionInfo: session))
case .linkDevice:
completion?(.linkDevice)
case .signOutOtherSessions:
completion?(.singOutFromUserSessions(sessionInfos: userSessionsOverviewService.sessionInfos))
}
}
@@ -164,11 +164,15 @@ struct UserSessionsOverview: View {
.background(theme.colors.background)
} header: {
VStack(alignment: .leading) {
Text(VectorL10n.userSessionsOverviewOtherSessionsSectionTitle)
.textCase(.uppercase)
.font(theme.fonts.footnote)
.foregroundColor(theme.colors.secondaryContent)
.padding(.bottom, 8.0)
HStack {
Text(VectorL10n.userSessionsOverviewOtherSessionsSectionTitle)
.textCase(.uppercase)
.font(theme.fonts.footnote)
.foregroundColor(theme.colors.secondaryContent)
.padding(.bottom, 8.0)
Spacer()
optionsMenu
}
Text(VectorL10n.userSessionsOverviewOtherSessionsSectionInfo)
.font(theme.fonts.footnote)
@@ -198,6 +202,37 @@ struct UserSessionsOverview: View {
}
.background(theme.colors.system.ignoresSafeArea())
}
private var optionsMenu: some View {
Button { } label: {
Menu {
signOutButton
} label: {
Image(systemName: "ellipsis")
.foregroundColor(theme.colors.secondaryContent)
.padding(.horizontal, 4)
.padding(.vertical, 12)
}
}
}
@ViewBuilder
private var signOutButton: some View {
let label = Label(VectorL10n.userOtherSessionMenuSignOutSessions(String(viewModel.viewState.otherSessionsViewData.count)), systemImage: "rectangle.portrait.and.arrow.forward.fill")
if #available(iOS 15, *) {
Button(role: .destructive) {
viewModel.send(viewAction: .signOutOtherSessions)
} label: {
label
}
} else {
Button {
viewModel.send(viewAction: .signOutOtherSessions)
} label: {
label
}
}
}
}
// MARK: - Previews