- Fix suggested trips showing wrong sports for cross-country trips - Remove quick start sections from home variants (Classic, Spotify) - Remove dead quickActions code from HomeView - Fix pace capsule animation in TripCreationView - Add text wrapping to achievement descriptions - Improve poll parsing with better error handling - Various sharing system improvements Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
72 lines
1.9 KiB
Swift
72 lines
1.9 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, style: ShareButtonStyle = .icon) {
|
|
self.content = ProgressShareContent(progress: progress, tripCount: tripCount)
|
|
self.style = style
|
|
}
|
|
}
|
|
|
|
extension ShareButton where Content == AchievementSpotlightContent {
|
|
init(achievement: AchievementProgress, style: ShareButtonStyle = .icon) {
|
|
self.content = AchievementSpotlightContent(achievement: achievement)
|
|
self.style = style
|
|
}
|
|
}
|