import ManaAuthUI import ManaCore import SwiftUI struct AccountView: View { @Environment(AuthClient.self) private var auth @State private var showChangeEmail = false @State private var showChangePassword = false @State private var showDeleteAccount = false var body: some View { ZStack { CardsTheme.background.ignoresSafeArea() VStack(spacing: 20) { Image(systemName: "person.crop.circle.fill") .resizable() .frame(width: 80, height: 80) .foregroundStyle(CardsTheme.primary) if let email = auth.currentEmail { Text(email) .font(.headline) .foregroundStyle(CardsTheme.foreground) } VStack(spacing: 12) { NavigationLink { SettingsView() } label: { rowLabel("Einstellungen", systemImage: "gear") } .buttonStyle(.plain) Button { showChangeEmail = true } label: { rowLabel("Email ändern", systemImage: "envelope") } .buttonStyle(.plain) Button { showChangePassword = true } label: { rowLabel("Passwort ändern", systemImage: "key") } .buttonStyle(.plain) } .padding(.horizontal, 32) Spacer() Button(role: .destructive) { Task { await auth.signOut() } } label: { Text("Abmelden") .frame(maxWidth: .infinity) .padding(.vertical, 12) .background(CardsTheme.error.opacity(0.1), in: RoundedRectangle(cornerRadius: 8)) .foregroundStyle(CardsTheme.error) } .padding(.horizontal, 32) // App-Store-Guideline 5.1.1(v): jede App mit Sign-Up MUSS // eine Account-Löschung anbieten. Button(role: .destructive) { showDeleteAccount = true } label: { Text("Account löschen…") .font(.footnote) .foregroundStyle(CardsTheme.mutedForeground) } .padding(.bottom, 16) } .padding(.top, 48) } .navigationTitle("Account") #if os(iOS) .navigationBarTitleDisplayMode(.inline) #endif .manaBrand(CardsBrand.manaBrand) .sheet(isPresented: $showChangeEmail) { ManaChangeEmailView( auth: auth, callbackUniversalLink: URL(string: "https://cardecky.mana.how/auth/email-changed"), onDone: { showChangeEmail = false } ) .manaBrand(CardsBrand.manaBrand) } .sheet(isPresented: $showChangePassword) { ManaChangePasswordView( auth: auth, onDone: { showChangePassword = false } ) .manaBrand(CardsBrand.manaBrand) } .sheet(isPresented: $showDeleteAccount) { ManaDeleteAccountView( auth: auth, onDone: { showDeleteAccount = false } ) .manaBrand(CardsBrand.manaBrand) } } @ViewBuilder private func rowLabel(_ title: String, systemImage: String) -> some View { Label(title, systemImage: systemImage) .frame(maxWidth: .infinity, alignment: .leading) .padding(.vertical, 12) .padding(.horizontal, 16) .background(CardsTheme.surface, in: RoundedRectangle(cornerRadius: 8)) .foregroundStyle(CardsTheme.foreground) .overlay( RoundedRectangle(cornerRadius: 8) .stroke(CardsTheme.border, lineWidth: 1) ) } } #Preview { NavigationStack { AccountView() .environment(AuthClient(config: AppConfig.manaAppConfig)) } }