Files
Sportstime/SportsTime/Export/Views/ShareButton.swift
Trey t fe36f99bca feat(sharing): implement unified sharing system for social media
Replace old ProgressCardGenerator with protocol-based sharing architecture
supporting trips, achievements, and stadium progress. Features 8 color
themes, Instagram Stories optimization (1080x1920), and reusable card
components with map snapshots.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 08:54:37 -06:00

72 lines
2.0 KiB
Swift

//
// ShareButton.swift
// SportsTime
//
// Contextual share button component.
//
import SwiftUI
struct ShareButton<Content: ShareableContent>: View {
let content: Content
var style: ShareButtonStyle = .icon
@State private var showPreview = false
var body: some View {
Button {
showPreview = true
} label: {
switch style {
case .icon:
Image(systemName: "square.and.arrow.up")
case .labeled:
Label("Share", systemImage: "square.and.arrow.up")
case .pill:
HStack(spacing: 4) {
Image(systemName: "square.and.arrow.up")
Text("Share")
}
.font(.subheadline.weight(.medium))
.padding(.horizontal, 12)
.padding(.vertical, 6)
.background(Theme.warmOrange)
.foregroundStyle(.white)
.clipShape(Capsule())
}
}
.sheet(isPresented: $showPreview) {
SharePreviewView(content: content)
}
}
}
enum ShareButtonStyle {
case icon
case labeled
case pill
}
// MARK: - Convenience Initializers
extension ShareButton where Content == TripShareContent {
init(trip: Trip, style: ShareButtonStyle = .icon) {
self.content = TripShareContent(trip: trip)
self.style = style
}
}
extension ShareButton where Content == ProgressShareContent {
init(progress: LeagueProgress, tripCount: Int = 0, username: String? = nil, style: ShareButtonStyle = .icon) {
self.content = ProgressShareContent(progress: progress, tripCount: tripCount, username: username)
self.style = style
}
}
extension ShareButton where Content == AchievementSpotlightContent {
init(achievement: AchievementProgress, style: ShareButtonStyle = .icon) {
self.content = AchievementSpotlightContent(achievement: achievement)
self.style = style
}
}