import SwiftUI /// Sekundär-Action-Buttons unterhalb der Lern-/Karten-hinzufügen-Buttons /// in `DeckDetailView`. Eigenständige View, damit `DeckDetailView` selbst /// nicht über die Type-Body-Length-Grenze rutscht und die einzelnen /// Aktionen einzeln (z.B. via Snapshot-Tests) prüfbar bleiben. /// /// Reines Layout — alle Side-Effects laufen über die Callbacks im Parent. struct DeckSecondaryActions: View { let isForkedFromMarketplace: Bool let isPullingUpdate: Bool let isDuplicating: Bool let onPullUpdate: () -> Void let onDuplicate: () -> Void let onPublish: () -> Void let onPrint: () -> Void let onEdit: () -> Void let onDelete: () -> Void var body: some View { if isForkedFromMarketplace { updateButton } else { publishButton } duplicateButton printButton editDeleteRow } private var printButton: some View { Button(action: onPrint) { HStack { Image(systemName: "printer") Text("Druck-Ansicht / PDF") } .frame(maxWidth: .infinity) .padding(.vertical, 10) .background(CardsTheme.surface, in: RoundedRectangle(cornerRadius: 10)) .foregroundStyle(CardsTheme.foreground) .overlay( RoundedRectangle(cornerRadius: 10) .stroke(CardsTheme.border, lineWidth: 1) ) } .buttonStyle(.plain) } private var publishButton: some View { Button(action: onPublish) { HStack { Image(systemName: "globe.badge.chevron.backward") Text("Im Marketplace veröffentlichen") } .frame(maxWidth: .infinity) .padding(.vertical, 10) .background(CardsTheme.surface, in: RoundedRectangle(cornerRadius: 10)) .foregroundStyle(CardsTheme.primary) .overlay( RoundedRectangle(cornerRadius: 10) .stroke(CardsTheme.primary.opacity(0.3), lineWidth: 1) ) } .buttonStyle(.plain) } private var updateButton: some View { Button(action: onPullUpdate) { HStack { if isPullingUpdate { ProgressView().tint(CardsTheme.primary) } else { Image(systemName: "arrow.triangle.2.circlepath") } Text(isPullingUpdate ? "Wird geprüft …" : "Updates aus Marketplace prüfen") } .frame(maxWidth: .infinity) .padding(.vertical, 10) .background(CardsTheme.surface, in: RoundedRectangle(cornerRadius: 10)) .foregroundStyle(CardsTheme.primary) .overlay( RoundedRectangle(cornerRadius: 10) .stroke(CardsTheme.primary.opacity(0.3), lineWidth: 1) ) } .buttonStyle(.plain) .disabled(isPullingUpdate) } private var duplicateButton: some View { Button(action: onDuplicate) { HStack { if isDuplicating { ProgressView().tint(CardsTheme.foreground) } else { Image(systemName: "doc.on.doc") } Text(isDuplicating ? "Wird dupliziert …" : "Deck duplizieren") } .frame(maxWidth: .infinity) .padding(.vertical, 10) .background(CardsTheme.surface, in: RoundedRectangle(cornerRadius: 10)) .foregroundStyle(CardsTheme.foreground) .overlay( RoundedRectangle(cornerRadius: 10) .stroke(CardsTheme.border, lineWidth: 1) ) } .buttonStyle(.plain) .disabled(isDuplicating) } private var editDeleteRow: some View { HStack(spacing: 12) { Button(action: onEdit) { Label("Bearbeiten", systemImage: "pencil") .frame(maxWidth: .infinity) .padding(.vertical, 10) .background(CardsTheme.surface, in: RoundedRectangle(cornerRadius: 10)) .foregroundStyle(CardsTheme.foreground) .overlay( RoundedRectangle(cornerRadius: 10) .stroke(CardsTheme.border, lineWidth: 1) ) } .buttonStyle(.plain) Button(action: onDelete) { Label("Löschen", systemImage: "trash") .frame(maxWidth: .infinity) .padding(.vertical, 10) .background(CardsTheme.error.opacity(0.1), in: RoundedRectangle(cornerRadius: 10)) .foregroundStyle(CardsTheme.error) } .buttonStyle(.plain) } } }