moodlit-native/Sources/Features/Settings/ProfileView.swift
till d4a0142ab1 Konto: Profil- + Einstellungen-Tab hinter den Avatar oben rechts (Sheet)
iOS: .manaAccountToolbar an Moods + Sequenzen (beide Tabs in
RootViews eigenem NavigationStack → Modifier direkt). macOS: ein
Avatar in der Detail-Toolbar des NavigationSplitView (deckt beide
Tabs ab). AppTab-Enum auf moods/sequences reduziert.

Profil + Einstellungen kombiniert: ProfileView wird die Sheet-Wurzel
(Konto-Heim mit Identität/Login/Logout/About), die App-Einstellungen
sind darin per NavigationLink "App-Einstellungen" erreichbar
(Apple-Muster: Settings liegen beim Konto). Eigenen NavigationStack
liefert das Sheet. Profil lazy via getProfile() fuer die Initialen
(.task + bei jedem Auth-Statuswechsel).

Teil der flottenweiten Migration, siehe mana/docs/playbooks/ACCOUNT_AVATAR_MIGRATION.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 22:17:50 +02:00

65 lines
1.9 KiB
Swift

import ManaAuthUI
import ManaCore
import SwiftUI
/// Konto-Heim (Sheet-Wurzel hinter dem Avatar oben rechts): Login-
/// Status, Logout, App-Einstellungen (per `NavigationLink`) und
/// About. Vereint die früheren Profil- + Einstellungen-Tabs nach dem
/// Apple-Muster Settings liegen beim Konto. Siehe
/// `mana/docs/playbooks/ACCOUNT_AVATAR_MIGRATION.md`.
struct ProfileView: View {
@Environment(AuthClient.self) private var auth
@Environment(ManaAuthGate.self) private var authGate
private var isSignedIn: Bool {
if case .signedIn = auth.status { return true }
return false
}
var body: some View {
Form {
Section("Konto") {
if let email = auth.currentEmail {
LabeledContent("E-Mail", value: email)
} else {
Text("Nicht eingeloggt")
.foregroundStyle(MoodlitTheme.mutedForeground)
}
}
Section {
if isSignedIn {
Button("Abmelden", role: .destructive) {
Task { await auth.signOut() }
}
} else {
ManaSignInCTA(
headline: "Noch nicht angemeldet",
message: "Mit einem mana-Konto sicherst du deine Moods "
+ "geräteübergreifend — ein Login für alle Vereins-Apps.",
buttonLabel: "Mit mana-Konto anmelden",
action: { authGate.require(reason: "profile") {} }
)
.listRowInsets(EdgeInsets(top: 8, leading: 16, bottom: 8, trailing: 16))
.listRowBackground(Color.clear)
}
}
Section("Einstellungen") {
NavigationLink {
SettingsView()
} label: {
Label("App-Einstellungen", systemImage: "gearshape")
}
}
ManaAboutSection(.init(
appName: "Moodlit",
links: [
.init("moodlit.mana.how", URL(string: "https://moodlit.mana.how")!),
.init("Datenschutz", URL(string: "https://moodlit.mana.how/datenschutz")!, inApp: true),
.init("Impressum", URL(string: "https://mana-ev.ch/impressum")!, inApp: true),
]
))
}
.navigationTitle("Konto")
}
}