Row + Laden + Navigation zur ManaView in einem; macht den Account-Einbau pro App zu einer Zeile. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
34 lines
1.1 KiB
Swift
34 lines
1.1 KiB
Swift
import ManaCore
|
|
import SwiftUI
|
|
|
|
/// Fertiger Account-/Settings-Eintrag für die Gesamt-Mana-Anzeige:
|
|
/// kombiniert `ManaBalanceRow` (lädt das Guthaben selbst) mit einem
|
|
/// `NavigationLink` zur vollen `ManaView`. So braucht eine App nur eine
|
|
/// Zeile — `ManaBalanceLink(auth: auth)` in eine `Form`/`List`-Section —
|
|
/// statt Laden + Row + Navigation selbst zu verdrahten.
|
|
///
|
|
/// In einer `Form`/`List` zeichnet SwiftUI das Chevron automatisch.
|
|
public struct ManaBalanceLink: View {
|
|
private let client: ManaCreditsClient
|
|
@State private var balance: ManaCreditBalance?
|
|
|
|
public init(auth: AuthClient) {
|
|
client = ManaCreditsClient(auth: auth)
|
|
}
|
|
|
|
/// Variante mit vorkonfiguriertem Client (z. B. eigene `baseURL`).
|
|
public init(client: ManaCreditsClient) {
|
|
self.client = client
|
|
}
|
|
|
|
public var body: some View {
|
|
NavigationLink {
|
|
ManaView(client: client)
|
|
} label: {
|
|
ManaBalanceRow(balance: balance)
|
|
}
|
|
.task {
|
|
if balance == nil { balance = try? await client.balance() }
|
|
}
|
|
}
|
|
}
|