diff --git a/Sources/App/RootView.swift b/Sources/App/RootView.swift index 875e7ec..6f7672c 100644 --- a/Sources/App/RootView.swift +++ b/Sources/App/RootView.swift @@ -1,3 +1,4 @@ +import ManaAuthUI import ManaCore import ManaWebShell import SwiftUI @@ -43,6 +44,7 @@ private func makeWebShellConfig() -> WebShellConfig { /// die App und routen in den passenden Tab. struct RootView: View { @Environment(AuthClient.self) private var auth + @Environment(ManaAuthGate.self) private var authGate @State private var selectedTab: AppTab = .read @State private var readTarget = WebTarget(url: AppConfig.webBaseURL) @State private var exploreTarget = WebTarget( @@ -76,6 +78,17 @@ struct RootView: View { .toolbarBackground(ZitareTheme.background, for: .windowToolbar) .toolbarBackground(.visible, for: .windowToolbar) #endif + .manaBrand(ZitareBrand.manaBrand) + .manaAuthGate(authGate) { + NavigationStack { + ManaLoginView( + auth: auth, + onSignUpTapped: {}, + onForgotTapped: {} + ) + .manaBrand(ZitareBrand.manaBrand) + } + } .task { await probeHealth() } diff --git a/Sources/App/ZitareNativeApp.swift b/Sources/App/ZitareNativeApp.swift index 8f7225e..7dc58a2 100644 --- a/Sources/App/ZitareNativeApp.swift +++ b/Sources/App/ZitareNativeApp.swift @@ -1,3 +1,4 @@ +import ManaAuthUI import ManaCore import SwiftData import SwiftUI @@ -6,12 +7,14 @@ import WidgetKit @main struct ZitareNativeApp: App { @State private var auth: AuthClient + @State private var authGate: ManaAuthGate private let snapshotContainer: ModelContainer? init() { let auth = AuthClient(config: AppConfig.manaAppConfig) auth.bootstrap() _auth = State(initialValue: auth) + _authGate = State(initialValue: ManaAuthGate(auth: auth)) do { snapshotContainer = try SnapshotContainer.make() } catch { @@ -29,6 +32,7 @@ struct ZitareNativeApp: App { WindowGroup { RootView() .environment(auth) + .environment(authGate) .tint(ZitareTheme.primary) .task { await refreshSnapshot() diff --git a/Sources/Core/Theme/ZitareBrand.swift b/Sources/Core/Theme/ZitareBrand.swift new file mode 100644 index 0000000..aab9c66 --- /dev/null +++ b/Sources/Core/Theme/ZitareBrand.swift @@ -0,0 +1,21 @@ +import ManaAuthUI + +/// Brücke zwischen `ZitareTheme` (paper-Variant) und der +/// `ManaBrandConfig` von `ManaAuthUI`. Im App-Body als Environment-Wert +/// gesetzt — Login-Sheet bekommt damit das paper-Theme statt mana-Default. +enum ZitareBrand { + static let manaBrand = ManaBrandConfig( + appName: "Zitare", + tagline: "Öffentlicher Zitat-Korpus von mana e.V.", + logoSymbol: "quote.opening", + background: ZitareTheme.background, + foreground: ZitareTheme.foreground, + surface: ZitareTheme.surface, + mutedForeground: ZitareTheme.mutedForeground, + border: ZitareTheme.border, + primary: ZitareTheme.primary, + primaryForeground: ZitareTheme.primaryForeground, + error: ZitareTheme.error, + success: ZitareTheme.success + ) +} diff --git a/Sources/Features/Account/AccountView.swift b/Sources/Features/Account/AccountView.swift index 4671297..22483b7 100644 --- a/Sources/Features/Account/AccountView.swift +++ b/Sources/Features/Account/AccountView.swift @@ -1,13 +1,21 @@ +import ManaAuthUI import ManaCore import SwiftUI /// Phase ζ-0 minimal: zeigt Auth-Status und Healthz-Probe-Ergebnis. -/// Phase ζ-3 erweitert um ManaAuthUI-Login-Sheet und Submission- -/// History-Link (via WebShell auf `zitare.mana.how/me`). +/// Phase ζ-3 erweitert um Submission-History-Link (via WebShell auf +/// `zitare.mana.how/me`). Login-Sheet schon hier, damit Guests einen +/// Anmelden-Button finden. struct AccountView: View { @Environment(AuthClient.self) private var auth + @Environment(ManaAuthGate.self) private var authGate let healthStatus: HealthStatus + private var isSignedIn: Bool { + if case .signedIn = auth.status { return true } + return false + } + var body: some View { ScrollView { VStack(spacing: 24) { @@ -15,6 +23,8 @@ struct AccountView: View { statusCard + authActionCard + Spacer(minLength: 32) aboutCard @@ -25,6 +35,30 @@ struct AccountView: View { .background(ZitareTheme.background) } + @ViewBuilder + private var authActionCard: some View { + if isSignedIn { + Button(role: .destructive) { + Task { await auth.signOut(keepGuestMode: true) } + } label: { + Label("Abmelden", systemImage: "arrow.left.square") + .frame(maxWidth: .infinity) + } + .buttonStyle(.bordered) + .controlSize(.large) + } else { + Button { + authGate.isPresentingSignIn = true + } label: { + Label("Mit mana-Konto anmelden", systemImage: "arrow.right.square") + .frame(maxWidth: .infinity) + } + .buttonStyle(.borderedProminent) + .controlSize(.large) + .tint(ZitareTheme.primary) + } + } + private var header: some View { VStack(spacing: 12) { // Eigenes Anführungszeichen-Glyph in der gleichen Variante diff --git a/project.yml b/project.yml index 154425e..d2a0c61 100644 --- a/project.yml +++ b/project.yml @@ -46,8 +46,10 @@ targets: product: ManaWebShell - target: ZitareWidgetExtension embed: true + platformFilter: iOS - target: ZitareShareExtension embed: true + platformFilter: iOS sources: - path: Sources/App - path: Sources/Features