Für Apps mit ScrollView/VStack-Card-Layout (viadocu) statt Form/Section. Inhalt im .manaCard-Container, Farben aus @Environment(\.manaTheme). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
73 lines
2.8 KiB
Swift
73 lines
2.8 KiB
Swift
import ManaTokens
|
|
import SwiftUI
|
|
|
|
/// Karten-Variante von ``ManaAppearanceSection`` für Apps mit **Card-Layout**
|
|
/// (`ScrollView`/`VStack` statt `Form`/`List`). Gleicher Inhalt — Hell/Dunkel-
|
|
/// Picker + Theme-Galerie + Footer —, aber in einem ``SwiftUICore/View/manaCard(surface:border:cornerRadius:borderWidth:padding:alignment:)``-Container
|
|
/// statt einer `Section`. Für viadocu & Co., deren Konto-Tab aus eigenen Cards
|
|
/// besteht und keine `Section` aufnehmen kann.
|
|
///
|
|
/// Farben kommen aus `@Environment(\.manaTheme)` (die App setzt es ohnehin für
|
|
/// die Galerie) — kein hartkodiertes Farbwerk im Paket. Persistenz bleibt
|
|
/// App-Sache (zwei `Binding`s rein), Theme-Pass via `unlocked`/`onLockedTap`.
|
|
///
|
|
/// ```swift
|
|
/// ManaAppearanceCard(
|
|
/// appearance: Binding(get: { … }, set: { … }),
|
|
/// theme: Binding(get: { … }, set: { … }),
|
|
/// unlocked: themePass.unlocked
|
|
/// )
|
|
/// ```
|
|
public struct ManaAppearanceCard: View {
|
|
@Environment(\.manaTheme) private var palette
|
|
|
|
@Binding private var appearance: ManaAppearanceMode
|
|
@Binding private var theme: ManaTheme
|
|
private let themes: [ManaTheme]
|
|
private let unlocked: Set<ManaTheme>
|
|
private let onLockedTap: ((ManaTheme) -> Void)?
|
|
private let header: String
|
|
private let footer: String?
|
|
|
|
/// - Parameters: identisch zu ``ManaAppearanceSection`` — `appearance`/`theme`
|
|
/// sind app-gehaltene Bindings, `themes`/`unlocked`/`onLockedTap` steuern
|
|
/// Angebot + Theme-Pass, `header`/`footer` die Beschriftung.
|
|
public init(
|
|
appearance: Binding<ManaAppearanceMode>,
|
|
theme: Binding<ManaTheme>,
|
|
themes: [ManaTheme] = ManaTheme.allCases,
|
|
unlocked: Set<ManaTheme> = Set(ManaTheme.allCases),
|
|
onLockedTap: ((ManaTheme) -> Void)? = nil,
|
|
header: String = "Darstellung",
|
|
footer: String? = ManaAppearanceSection.defaultFooter
|
|
) {
|
|
_appearance = appearance
|
|
_theme = theme
|
|
self.themes = themes
|
|
self.unlocked = unlocked
|
|
self.onLockedTap = onLockedTap
|
|
self.header = header
|
|
self.footer = footer
|
|
}
|
|
|
|
public var body: some View {
|
|
VStack(alignment: .leading, spacing: 10) {
|
|
Text(header)
|
|
.font(.headline)
|
|
.foregroundStyle(palette.foreground)
|
|
ManaAppearancePicker(selection: $appearance)
|
|
ManaThemeGallery(
|
|
selection: $theme,
|
|
themes: themes,
|
|
unlocked: unlocked,
|
|
onLockedTap: onLockedTap
|
|
)
|
|
if let footer {
|
|
Text(footer)
|
|
.font(.caption)
|
|
.foregroundStyle(palette.mutedForeground)
|
|
}
|
|
}
|
|
.manaCard(surface: palette.surface, border: palette.border)
|
|
}
|
|
}
|