Vervollständigt die Cardecky-Web-Parität für Deck- und Card-Workflows. γ-1+γ-2 (AI-Deck-Generierung) - 4-Modi-Picker im DeckEditorView Create-Sheet: Leer/KI/Bild/CSV - POST /api/v1/decks/generate für Text-Prompt + 10/min Rate-Limit-UI - POST /api/v1/decks/from-image mit PhotosPicker + PDF-Importer (max 5 Files, 10 MiB/Bild, 30 MiB/PDF), Multipart-Body in CardsAPI+Generation - Loading-Overlay mit Task-Cancellation, Error-Mapping für 429/413/502 γ-3 (Card-Edit) - CardEditorView mit Mode .create(deckId:) / .edit(card:) - Image-Occlusion + Audio-Front behalten bestehenden Media-Ref, solange User nicht ersetzt — MediaCache lädt Bild nach - Type-Picker im Edit-Modus aus (Server-immutable) - CardEditorPayload + CardEditorMediaFields als Sub-Views γ-4 (Pull-Update + Duplicate + Archive) - POST /marketplace/private/:id/pull-update mit Smart-Merge-Anzeige - POST /decks/:id/duplicate - Archive-Toggle im Edit-Modus, Server filtert Liste serverseitig - DeckSecondaryActions als eigenes Sub-View γ-6 (CSV-Import) - RFC-4180-ish Parser (Quote-Escape, Header-Detect, BOM-strip) - Preview-Liste + sequentielle Card-Inserts mit Live-Progress - Image-Occlusion/Audio-Front werden geskipped (UI flaggt) γ-7 (Marketplace-Publish) + Follow-up (Report + Block + Re-Publish) - MarketplacePublishView mit lazy Author-Setup + Init + Publish 1.0.0 - Re-Publish-Modus: Picker für eigene Marketplace-Decks + Auto-Semver-Bump (Minor +1) - MarketplaceCardConverter (typing → type-in, audio-front → skipped, image-occlusion → skipped — Server hat keinen MP-Media-Re-Upload) - Toolbar-Menü auf PublicDeckView: „Deck melden …" + Author-Blockieren (App-Store-Guideline 5.1.1(v)) - ReportDeckSheet mit Reason-Picker (6 Kategorien) + optional Message - BlockedAuthorsView in Settings mit Swipe-Entblocken γ-8 (PDF-Export) - DeckPrintView mit SFSafariViewController auf cardecky.mana.how/decks/:id/print — iOS Share-Sheet → PDF speichern Side-Fixes (mid-stream) - StudySessionView: Card-Aspect-Ratio springt nicht mehr beim Flip (Bottom-Bar in ZStack fixer Höhe) - RootView: Glass-Pille für „Neues Deck"-Accessory + .guest- und .twoFactorRequired-Cases nachgezogen - DeckListView: Account-Toolbar-Button entfernt (Account-Tab unten ist alleinige Anlaufstelle) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
109 lines
3.7 KiB
Swift
109 lines
3.7 KiB
Swift
import ManaCore
|
|
import SwiftUI
|
|
|
|
/// Report-Form für ein Marketplace-Deck — Pflicht-Komponente nach
|
|
/// App-Store-Guideline 5.1.1(v) (Report-Mechanismus für UGC).
|
|
///
|
|
/// Owned-State (Kategorie, Message, Submit-Status). Bei Erfolg schließt
|
|
/// das Sheet und ruft `onCompleted` mit einer Toast-Message auf.
|
|
struct ReportDeckSheet: View {
|
|
let slug: String
|
|
let onCompleted: (String) -> Void
|
|
|
|
@Environment(AuthClient.self) private var auth
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
@State private var category: ReportCategory = .spam
|
|
@State private var message: String = ""
|
|
@State private var isSubmitting = false
|
|
@State private var errorMessage: String?
|
|
|
|
var body: some View {
|
|
Form {
|
|
Section("Grund") {
|
|
Picker("Grund", selection: $category) {
|
|
ForEach(ReportCategory.allCases, id: \.self) { cat in
|
|
Text(cat.label).tag(cat)
|
|
}
|
|
}
|
|
.pickerStyle(.inline)
|
|
.labelsHidden()
|
|
}
|
|
|
|
Section {
|
|
TextField("Optional: Details", text: $message, axis: .vertical)
|
|
.lineLimit(3 ... 6)
|
|
.textInputAutocapitalization(.sentences)
|
|
} header: {
|
|
Text("Beschreibung")
|
|
} footer: {
|
|
Text("Wir prüfen jede Meldung. Hass und Rechtsverletzungen werden bevorzugt behandelt.")
|
|
}
|
|
|
|
if let errorMessage {
|
|
Section {
|
|
Text(errorMessage)
|
|
.font(.footnote)
|
|
.foregroundStyle(CardsTheme.error)
|
|
}
|
|
}
|
|
}
|
|
.disabled(isSubmitting)
|
|
.navigationTitle("Deck melden")
|
|
#if os(iOS)
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
#endif
|
|
.toolbar {
|
|
ToolbarItem(placement: .cancellationAction) {
|
|
Button("Abbrechen") { dismiss() }
|
|
}
|
|
ToolbarItem(placement: .confirmationAction) {
|
|
Button("Senden") { Task { await submit() } }
|
|
.disabled(isSubmitting)
|
|
}
|
|
}
|
|
}
|
|
|
|
private func submit() async {
|
|
isSubmitting = true
|
|
errorMessage = nil
|
|
defer { isSubmitting = false }
|
|
let api = CardsAPI(auth: auth)
|
|
let trimmed = message.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
do {
|
|
let response = try await api.reportDeck(
|
|
slug: slug,
|
|
body: ReportDeckBody(
|
|
category: category,
|
|
body: trimmed.isEmpty ? nil : trimmed,
|
|
versionId: nil,
|
|
cardContentHash: nil
|
|
)
|
|
)
|
|
let toast = response.alreadyReported
|
|
? "Du hast dieses Deck bereits gemeldet."
|
|
: "Meldung gesendet. Danke fürs Aufpassen."
|
|
onCompleted(toast)
|
|
dismiss()
|
|
} catch {
|
|
errorMessage = (error as? LocalizedError)?.errorDescription ?? String(describing: error)
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Schlichtes Top-Banner für kurze Bestätigungen.
|
|
struct ToastBanner: View {
|
|
let text: String
|
|
|
|
var body: some View {
|
|
Text(text)
|
|
.font(.subheadline.weight(.medium))
|
|
.foregroundStyle(CardsTheme.foreground)
|
|
.padding(.horizontal, 14)
|
|
.padding(.vertical, 10)
|
|
.background(.regularMaterial, in: Capsule())
|
|
.overlay(Capsule().stroke(CardsTheme.border, lineWidth: 0.5))
|
|
.padding(.horizontal, 16)
|
|
.transition(.move(edge: .top).combined(with: .opacity))
|
|
}
|
|
}
|