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>
This commit is contained in:
71
SportsTime/Export/Views/ShareButton.swift
Normal file
71
SportsTime/Export/Views/ShareButton.swift
Normal file
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user