mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 17:12:45 +02:00
Session Manager: Single session logout
This commit is contained in:
+24
-2
@@ -31,9 +31,11 @@ struct UserSessionOverview: View {
|
||||
})
|
||||
.padding(16)
|
||||
SwiftUI.Section {
|
||||
UserSessionOverviewDisclosureCell(title: VectorL10n.userSessionOverviewSessionDetailsButtonTitle, onBackgroundTap: {
|
||||
UserSessionOverviewItem(title: VectorL10n.userSessionOverviewSessionDetailsButtonTitle,
|
||||
showsChevron: true) {
|
||||
viewModel.send(viewAction: .viewSessionDetails)
|
||||
})
|
||||
}
|
||||
|
||||
if let enabled = viewModel.viewState.isPusherEnabled {
|
||||
UserSessionOverviewToggleCell(title: VectorL10n.userSessionPushNotifications,
|
||||
message: VectorL10n.userSessionPushNotificationsMessage,
|
||||
@@ -42,6 +44,13 @@ struct UserSessionOverview: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SwiftUI.Section {
|
||||
UserSessionOverviewItem(title: VectorL10n.manageSessionSignOut,
|
||||
isDestructive: true) {
|
||||
viewModel.send(viewAction: .logoutOfSession)
|
||||
}
|
||||
}
|
||||
}
|
||||
.background(theme.colors.system.ignoresSafeArea())
|
||||
.frame(maxHeight: .infinity)
|
||||
@@ -49,6 +58,19 @@ struct UserSessionOverview: View {
|
||||
.navigationTitle(viewModel.viewState.isCurrentSession ?
|
||||
VectorL10n.userSessionOverviewCurrentSessionTitle :
|
||||
VectorL10n.userSessionOverviewSessionTitle)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Menu {
|
||||
Button { viewModel.send(viewAction: .renameSession) } label: {
|
||||
Label(VectorL10n.manageSessionRename, systemImage: "pencil")
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "ellipsis.circle")
|
||||
}
|
||||
}
|
||||
}
|
||||
.accentColor(theme.colors.accent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-10
@@ -16,10 +16,12 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct UserSessionOverviewDisclosureCell: View {
|
||||
struct UserSessionOverviewItem: View {
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
|
||||
let title: String
|
||||
var showsChevron = false
|
||||
var isDestructive = false
|
||||
var onBackgroundTap: (() -> Void)?
|
||||
|
||||
var body: some View {
|
||||
@@ -29,9 +31,12 @@ struct UserSessionOverviewDisclosureCell: View {
|
||||
HStack {
|
||||
Text(title)
|
||||
.font(theme.fonts.body)
|
||||
.foregroundColor(theme.colors.primaryContent)
|
||||
.foregroundColor(textColor)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Image(Asset.Images.chevron.name)
|
||||
|
||||
if showsChevron {
|
||||
Image(Asset.Images.chevron.name)
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 15)
|
||||
.padding(.horizontal, 16)
|
||||
@@ -40,17 +45,27 @@ struct UserSessionOverviewDisclosureCell: View {
|
||||
.background(theme.colors.background)
|
||||
}
|
||||
}
|
||||
|
||||
var textColor: Color {
|
||||
isDestructive ? theme.colors.alert : theme.colors.primaryContent
|
||||
}
|
||||
}
|
||||
|
||||
struct UserSessionOverviewDisclosureCell_Previews: PreviewProvider {
|
||||
struct UserSessionOverviewButtonCell_Previews: PreviewProvider {
|
||||
static var buttons: some View {
|
||||
NavigationView {
|
||||
ScrollView {
|
||||
UserSessionOverviewItem(title: "Nav item", showsChevron: true)
|
||||
UserSessionOverviewItem(title: "Button")
|
||||
UserSessionOverviewItem(title: "Button", isDestructive: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static var previews: some View {
|
||||
Group {
|
||||
UserSessionOverviewDisclosureCell(title: "Title")
|
||||
.theme(.light)
|
||||
.preferredColorScheme(.light)
|
||||
UserSessionOverviewDisclosureCell(title: "Title")
|
||||
.theme(.dark)
|
||||
.preferredColorScheme(.dark)
|
||||
buttons.theme(.light).preferredColorScheme(.light)
|
||||
buttons.theme(.dark).preferredColorScheme(.dark)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user