From 04b62f147e1d8f61e20b1e0c9b31fabcab69058b Mon Sep 17 00:00:00 2001 From: Trey t Date: Tue, 13 Jan 2026 13:16:40 -0600 Subject: [PATCH] fix: resolve compiler warnings across codebase - PaywallView: remove unnecessary nil coalescing for currencyCode - GameDAGRouter: change var to let for immutable compositeKeys - GamesHistoryRow/View: add missing wnba and nwsl switch cases - VisitDetailView: fix unused variable in preview - AchievementEngine: use convenience init to avoid default parameter warning - ProgressCardGenerator: use method overload instead of default parameter - StadiumProximityMatcher: extract constants to ProximityConstants enum Co-Authored-By: Claude Opus 4.5 --- .../Core/Services/AchievementEngine.swift | 7 ++++++- .../Services/StadiumProximityMatcher.swift | 20 +++++++++++-------- .../Services/ProgressCardGenerator.swift | 9 ++++++++- .../Features/Paywall/Views/PaywallView.swift | 2 +- .../Views/Components/GamesHistoryRow.swift | 3 ++- .../Progress/Views/GamesHistoryView.swift | 3 ++- .../Progress/Views/VisitDetailView.swift | 2 +- .../Planning/Engine/GameDAGRouter.swift | 2 +- 8 files changed, 33 insertions(+), 15 deletions(-) diff --git a/SportsTime/Core/Services/AchievementEngine.swift b/SportsTime/Core/Services/AchievementEngine.swift index 9915051..2a773d7 100644 --- a/SportsTime/Core/Services/AchievementEngine.swift +++ b/SportsTime/Core/Services/AchievementEngine.swift @@ -33,11 +33,16 @@ final class AchievementEngine { // MARK: - Initialization - init(modelContext: ModelContext, dataProvider: AppDataProvider = AppDataProvider.shared) { + init(modelContext: ModelContext, dataProvider: AppDataProvider) { self.modelContext = modelContext self.dataProvider = dataProvider } + /// Convenience initializer using the shared data provider + convenience init(modelContext: ModelContext) { + self.init(modelContext: modelContext, dataProvider: AppDataProvider.shared) + } + // MARK: - Public API /// Full recalculation (call after visit deleted or on app update) diff --git a/SportsTime/Core/Services/StadiumProximityMatcher.swift b/SportsTime/Core/Services/StadiumProximityMatcher.swift index fc24b64..4d9d552 100644 --- a/SportsTime/Core/Services/StadiumProximityMatcher.swift +++ b/SportsTime/Core/Services/StadiumProximityMatcher.swift @@ -212,18 +212,22 @@ struct PhotoMatchConfidence: Sendable { } } +// MARK: - Proximity Constants + +/// Configuration constants for stadium proximity matching (outside @MainActor for default parameter use) +enum ProximityConstants: Sendable { + static let highConfidenceRadius: CLLocationDistance = 500 // 500m + static let mediumConfidenceRadius: CLLocationDistance = 2000 // 2km + static let searchRadius: CLLocationDistance = 5000 // 5km default + static let dateToleranceDays: Int = 1 // ±1 day for timezone/tailgating +} + // MARK: - Stadium Proximity Matcher @MainActor final class StadiumProximityMatcher { static let shared = StadiumProximityMatcher() - // Configuration constants - static let highConfidenceRadius: CLLocationDistance = 500 // 500m - static let mediumConfidenceRadius: CLLocationDistance = 2000 // 2km - static let searchRadius: CLLocationDistance = 5000 // 5km default - static let dateToleranceDays: Int = 1 // ±1 day for timezone/tailgating - private let dataProvider = AppDataProvider.shared private init() {} @@ -233,7 +237,7 @@ final class StadiumProximityMatcher { /// Find stadiums within radius of coordinates func findNearbyStadiums( coordinates: CLLocationCoordinate2D, - radius: CLLocationDistance = StadiumProximityMatcher.searchRadius, + radius: CLLocationDistance = ProximityConstants.searchRadius, sport: Sport? = nil ) -> [StadiumMatch] { let photoLocation = CLLocation(latitude: coordinates.latitude, longitude: coordinates.longitude) @@ -275,7 +279,7 @@ final class StadiumProximityMatcher { /// Check if coordinates are near any stadium func isNearStadium( coordinates: CLLocationCoordinate2D, - radius: CLLocationDistance = StadiumProximityMatcher.searchRadius + radius: CLLocationDistance = ProximityConstants.searchRadius ) -> Bool { let matches = findNearbyStadiums(coordinates: coordinates, radius: radius) return !matches.isEmpty diff --git a/SportsTime/Export/Services/ProgressCardGenerator.swift b/SportsTime/Export/Services/ProgressCardGenerator.swift index 3181d85..c76d8e0 100644 --- a/SportsTime/Export/Services/ProgressCardGenerator.swift +++ b/SportsTime/Export/Services/ProgressCardGenerator.swift @@ -21,6 +21,13 @@ final class ProgressCardGenerator { // MARK: - Generate Card + /// Generate a shareable progress card image with default options + /// - Parameter progress: The league progress data + /// - Returns: The generated UIImage + func generateCard(progress: LeagueProgress) async throws -> UIImage { + try await generateCard(progress: progress, options: ProgressCardOptions()) + } + /// Generate a shareable progress card image /// - Parameters: /// - progress: The league progress data @@ -28,7 +35,7 @@ final class ProgressCardGenerator { /// - Returns: The generated UIImage func generateCard( progress: LeagueProgress, - options: ProgressCardOptions = ProgressCardOptions() + options: ProgressCardOptions ) async throws -> UIImage { // Generate map snapshot if needed var mapSnapshot: UIImage? diff --git a/SportsTime/Features/Paywall/Views/PaywallView.swift b/SportsTime/Features/Paywall/Views/PaywallView.swift index d671b7e..bfcb2fa 100644 --- a/SportsTime/Features/Paywall/Views/PaywallView.swift +++ b/SportsTime/Features/Paywall/Views/PaywallView.swift @@ -300,7 +300,7 @@ struct PricingOptionCard: View { private var pricePerMonth: String { if product.id.contains("annual") { let monthly = product.price / 12 - return "\(monthly.formatted(.currency(code: product.priceFormatStyle.currencyCode ?? "USD")))/mo" + return "\(monthly.formatted(.currency(code: product.priceFormatStyle.currencyCode)))/mo" } return "per month" } diff --git a/SportsTime/Features/Progress/Views/Components/GamesHistoryRow.swift b/SportsTime/Features/Progress/Views/Components/GamesHistoryRow.swift index 124c598..a972142 100644 --- a/SportsTime/Features/Progress/Views/Components/GamesHistoryRow.swift +++ b/SportsTime/Features/Progress/Views/Components/GamesHistoryRow.swift @@ -51,7 +51,8 @@ struct GamesHistoryRow: View { case .nhl: return "hockey.puck" case .nfl: return "football" case .mls: return "soccerball" - @unknown default: return "sportscourt" + case .wnba: return "basketball" + case .nwsl: return "soccerball" } } } diff --git a/SportsTime/Features/Progress/Views/GamesHistoryView.swift b/SportsTime/Features/Progress/Views/GamesHistoryView.swift index 6350f9d..0f39a8a 100644 --- a/SportsTime/Features/Progress/Views/GamesHistoryView.swift +++ b/SportsTime/Features/Progress/Views/GamesHistoryView.swift @@ -140,7 +140,8 @@ private struct SportChip: View { case .nhl: return "hockey.puck" case .nfl: return "football" case .mls: return "soccerball" - @unknown default: return "sportscourt" + case .wnba: return "basketball" + case .nwsl: return "soccerball" } } } diff --git a/SportsTime/Features/Progress/Views/VisitDetailView.swift b/SportsTime/Features/Progress/Views/VisitDetailView.swift index 27bf1c2..31082af 100644 --- a/SportsTime/Features/Progress/Views/VisitDetailView.swift +++ b/SportsTime/Features/Progress/Views/VisitDetailView.swift @@ -522,7 +522,7 @@ extension VisitSource { // MARK: - Preview #Preview { - let stadium = Stadium( + let _ = Stadium( id: "stadium_preview_oracle_park", name: "Oracle Park", city: "San Francisco", diff --git a/SportsTime/Planning/Engine/GameDAGRouter.swift b/SportsTime/Planning/Engine/GameDAGRouter.swift index 40a04ab..356cc90 100644 --- a/SportsTime/Planning/Engine/GameDAGRouter.swift +++ b/SportsTime/Planning/Engine/GameDAGRouter.swift @@ -324,7 +324,7 @@ enum GameDAGRouter { } // Round-robin from composite buckets - var compositeKeys = Array(byComposite.keys).sorted() + let compositeKeys = Array(byComposite.keys).sorted() var indices: [String: Int] = [:] while selected.count < maxCount && !compositeKeys.isEmpty { var addedAny = false