Initial implementation of Fantasy Hockey watchOS app
Implemented complete TCA architecture for iOS and watchOS targets: - Authentication flow (Sign in with Apple + Yahoo OAuth) - OAuth token management with iCloud Key-Value Storage - Yahoo Fantasy Sports API client with async/await - Watch Connectivity for iPhone ↔ Watch data sync - Complete UI for both iPhone and Watch platforms Core features: - Matchup score display - Category breakdown with win/loss/tie indicators - Roster status tracking - Manual refresh functionality - Persistent data caching on Watch Technical stack: - The Composable Architecture for state management - Swift Concurrency (async/await, actors) - WatchConnectivity framework - Sign in with Apple - OAuth 2.0 authentication flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
58
FantasyWatch/Shared/Models/MatchupModels.swift
Normal file
58
FantasyWatch/Shared/Models/MatchupModels.swift
Normal file
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// MatchupModels.swift
|
||||
// FantasyWatch
|
||||
//
|
||||
// Created by Claude Code
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct Matchup: Codable, Equatable, Sendable {
|
||||
let week: Int
|
||||
let status: String
|
||||
let userTeam: TeamScore
|
||||
let opponentTeam: TeamScore
|
||||
let categories: [CategoryScore]
|
||||
}
|
||||
|
||||
struct TeamScore: Codable, Equatable, Sendable {
|
||||
let teamKey: String
|
||||
let teamName: String
|
||||
let wins: Int
|
||||
let losses: Int
|
||||
let ties: Int
|
||||
}
|
||||
|
||||
struct CategoryScore: Codable, Equatable, Sendable, Identifiable {
|
||||
let statID: String
|
||||
let name: String
|
||||
let userValue: String
|
||||
let opponentValue: String
|
||||
|
||||
var id: String { statID }
|
||||
|
||||
enum ComparisonResult {
|
||||
case winning
|
||||
case losing
|
||||
case tied
|
||||
}
|
||||
|
||||
var comparison: ComparisonResult {
|
||||
guard let userNum = Double(userValue),
|
||||
let opponentNum = Double(opponentValue) else {
|
||||
return userValue == opponentValue ? .tied : .winning
|
||||
}
|
||||
|
||||
let isInvertedStat = name == "GAA" || name == "ERA"
|
||||
|
||||
if isInvertedStat {
|
||||
if userNum < opponentNum { return .winning }
|
||||
if userNum > opponentNum { return .losing }
|
||||
return .tied
|
||||
} else {
|
||||
if userNum > opponentNum { return .winning }
|
||||
if userNum < opponentNum { return .losing }
|
||||
return .tied
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user