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>
51 lines
1.2 KiB
Swift
51 lines
1.2 KiB
Swift
//
|
|
// RootFeature.swift
|
|
// FantasyWatch
|
|
//
|
|
// Created by Claude Code
|
|
//
|
|
|
|
import ComposableArchitecture
|
|
import Foundation
|
|
|
|
@Reducer
|
|
struct RootFeature {
|
|
@ObservableState
|
|
struct State: Equatable {
|
|
var authentication = AuthenticationFeature.State()
|
|
var matchup: MatchupFeature.State?
|
|
}
|
|
|
|
enum Action {
|
|
case authentication(AuthenticationFeature.Action)
|
|
case matchup(MatchupFeature.Action)
|
|
case handleOAuthCallback(URL)
|
|
}
|
|
|
|
var body: some ReducerOf<Self> {
|
|
Scope(state: \.authentication, action: \.authentication) {
|
|
AuthenticationFeature(
|
|
clientID: ConfigurationManager.yahooClientID,
|
|
clientSecret: ConfigurationManager.yahooClientSecret
|
|
)
|
|
}
|
|
|
|
Reduce { state, action in
|
|
switch action {
|
|
case .authentication(.yahooTokenResponse(.success)):
|
|
state.matchup = MatchupFeature.State()
|
|
return .none
|
|
|
|
case .handleOAuthCallback(let url):
|
|
return .send(.authentication(.yahooOAuthCallback(url)))
|
|
|
|
default:
|
|
return .none
|
|
}
|
|
}
|
|
.ifLet(\.matchup, action: \.matchup) {
|
|
MatchupFeature()
|
|
}
|
|
}
|
|
}
|