- Add VoiceOver labels, hints, and element grouping across all 60+ views - Add Reduce Motion support (Theme.Animation.prefersReducedMotion) to all animations - Replace fixed font sizes with semantic Dynamic Type styles - Hide decorative elements from VoiceOver with .accessibilityHidden(true) - Add .minimumHitTarget() modifier ensuring 44pt touch targets - Add AccessibilityAnnouncer utility for VoiceOver announcements - Improve color contrast values in Theme.swift for WCAG AA compliance - Extract CloudKitContainerConfig for explicit container identity - Remove PostHog debug console log from AnalyticsManager Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55 lines
1.5 KiB
Swift
55 lines
1.5 KiB
Swift
import SwiftUI
|
|
import MapKit
|
|
|
|
@MainActor
|
|
@Observable
|
|
final class MapInteractionViewModel {
|
|
// Default region: Continental US
|
|
static let defaultRegion = MKCoordinateRegion(
|
|
center: CLLocationCoordinate2D(latitude: 39.8283, longitude: -98.5795),
|
|
span: MKCoordinateSpan(latitudeDelta: 35, longitudeDelta: 55)
|
|
)
|
|
|
|
// City-level zoom span
|
|
static let stadiumZoomSpan = MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01)
|
|
|
|
var region: MKCoordinateRegion = MapInteractionViewModel.defaultRegion
|
|
var hasUserInteracted: Bool = false
|
|
var selectedStadiumId: String?
|
|
|
|
var shouldShowResetButton: Bool {
|
|
hasUserInteracted
|
|
}
|
|
|
|
func userDidInteract() {
|
|
hasUserInteracted = true
|
|
}
|
|
|
|
func resetToDefault() {
|
|
Theme.Animation.withMotion(.easeInOut(duration: 0.5)) {
|
|
region = MapInteractionViewModel.defaultRegion
|
|
}
|
|
hasUserInteracted = false
|
|
selectedStadiumId = nil
|
|
}
|
|
|
|
func zoomToStadium(at coordinate: CLLocationCoordinate2D) {
|
|
Theme.Animation.withMotion(.easeInOut(duration: 0.3)) {
|
|
region = MKCoordinateRegion(
|
|
center: coordinate,
|
|
span: MapInteractionViewModel.stadiumZoomSpan
|
|
)
|
|
}
|
|
hasUserInteracted = true
|
|
}
|
|
|
|
func selectStadium(id: String, coordinate: CLLocationCoordinate2D) {
|
|
selectedStadiumId = id
|
|
zoomToStadium(at: coordinate)
|
|
}
|
|
|
|
func deselectStadium() {
|
|
selectedStadiumId = nil
|
|
}
|
|
}
|