Add iPhone target with shared data layer and persistent cache

Two-target restructure: shared sources (models, services, settings,
extensions, team logos) move into Shared/, consumed by both the
existing macOS menu bar app and a new iOS app. MainService no longer
imports AppKit — platform code attaches via a MainServiceObserver
protocol (MacObserverAdapter wires back to MenuManager / StatusItemManager
/ NotificationManager).

iPhone app is a single SwiftUI page mirroring the macOS menu (playoff
round + yesterday/today/tomorrow), with a gear-icon settings sheet
(display option + IndieAbout for license/changelog). Persistent JSON
snapshot in Application Support paints last-known data on cold launch;
"Updated …" header escalates secondary → orange (>5min) → red (>30min)
so staleness is visually unmistakable. Foreground polling, scenePhase
refresh, and pull-to-refresh; no notifications on iOS in v1.
This commit is contained in:
2026-04-25 06:34:36 -04:00
parent 18c4ef64d6
commit aaffa3771c
70 changed files with 1011 additions and 65 deletions
@@ -0,0 +1,14 @@
//
// Date+easternTimeZone.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension Date {
static var easternTimeZone: TimeZone {
TimeZone(identifier: "America/New_York")!
}
}
+16
View File
@@ -0,0 +1,16 @@
//
// Date+etCalendar.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension Date {
static func etCalendar() -> Calendar {
var calendar = Calendar.current
calendar.timeZone = Date.easternTimeZone
return calendar
}
}
+21
View File
@@ -0,0 +1,21 @@
//
// Date+formatDateET.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension Date {
func formatDateET(format: String = "MMMM, d yyyy @ h:mm a z") -> String {
let formatter = DateFormatter()
formatter.timeZone = TimeZone(identifier: "America/New_York")
formatter.dateFormat = format
return formatter.string(from: self)
}
static var ISO8601: String {
"yyyy-MM-dd'T'HH:mm:ssZ"
}
}
+68
View File
@@ -0,0 +1,68 @@
//
// Date+gameWindow.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension Date {
/// Returns YYYY-MM-DD string for yesterday in Eastern Time
static var yesterdayET: String {
let calendar = etCalendar()
let yesterday = calendar.date(byAdding: .day, value: -1, to: .now)!
return formatDateString(yesterday)
}
/// Returns YYYY-MM-DD string for today in Eastern Time
static var todayET: String {
formatDateString(.now)
}
/// Returns YYYY-MM-DD string for tomorrow in Eastern Time
static var tomorrowET: String {
let calendar = etCalendar()
let tomorrow = calendar.date(byAdding: .day, value: 1, to: .now)!
return formatDateString(tomorrow)
}
private static func formatDateString(_ date: Date) -> String {
date.formatDateET(format: "yyyy-MM-dd")
}
/// Returns a friendly label like "YESTERDAY", "TODAY", "TOMORROW", or a formatted date
static func friendlyDateLabel(for dateString: String) -> String {
if dateString == todayET { return "TODAY" }
if dateString == yesterdayET { return "YESTERDAY" }
if dateString == tomorrowET { return "TOMORROW" }
// Parse and format as weekday abbreviation + date
let inputFormatter = DateFormatter()
inputFormatter.dateFormat = "yyyy-MM-dd"
inputFormatter.timeZone = easternTimeZone
if let date = inputFormatter.date(from: dateString) {
return date.formatDateET(format: "EEE, MMM d")
}
return dateString
}
/// Returns a full label like "TODAY Sun, Apr 12"
static func fullDateLabel(for dateString: String) -> String {
let friendly = friendlyDateLabel(for: dateString)
let inputFormatter = DateFormatter()
inputFormatter.dateFormat = "yyyy-MM-dd"
inputFormatter.timeZone = easternTimeZone
if let date = inputFormatter.date(from: dateString) {
let formatted = date.formatDateET(format: "EEE, MMM d")
if friendly == "TODAY" || friendly == "YESTERDAY" || friendly == "TOMORROW" {
return "\(friendly)\(formatted)"
}
return formatted
}
return friendly
}
}
@@ -0,0 +1,38 @@
//
// Game+nextGameLabel.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension Scoreboard.Game {
/// Friendly "next game" label used by both the macOS menu and the iOS
/// playoff series row: "Today 9:30 PM", "Tomorrow 7:00 PM", "Wed 7:00 PM (PRE)",
/// or just "LIVE" when the game is in progress.
var nextGameLabel: String {
let state = parsedGameState
if state.isLive {
return state.shortTag
}
let dayLabel: String
switch gameDate {
case Date.todayET: dayLabel = "Today"
case Date.tomorrowET: dayLabel = "Tomorrow"
case Date.yesterdayET: dayLabel = "Yesterday"
default:
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd"
formatter.timeZone = TimeZone(identifier: "America/New_York")
if let date = formatter.date(from: gameDate) {
dayLabel = date.formatDateET(format: "EEE")
} else {
dayLabel = ""
}
}
let time = startTimeET.trimmingCharacters(in: .whitespaces)
let base = "\(dayLabel) \(time)"
return state == .pre ? "\(base) (PRE)" : base
}
}
@@ -0,0 +1,36 @@
//
// TimeInterval+humanReadableTime.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension TimeInterval {
static func humanReadableTime(from timeInterval: TimeInterval) -> String {
let seconds = Int(timeInterval)
let hours = seconds / 3600
let minutes = (seconds % 3600) / 60
let remainingSeconds = seconds % 60
var components: [String] = []
if hours > 0 {
components.append("\(hours) \(hours == 1 ? "hour" : "hours")")
}
if minutes > 0 {
components.append("\(minutes) \(minutes == 1 ? "minute" : "minutes")")
}
if remainingSeconds > 0 || components.isEmpty {
components.append("\(remainingSeconds) \(remainingSeconds == 1 ? "second" : "seconds")")
}
return components.joined(separator: " ")
}
func humanReadableTime() -> String {
return TimeInterval.humanReadableTime(from: self)
}
}
+19
View File
@@ -0,0 +1,19 @@
//
// Timer+startTimer.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension Timer {
static func startTimer(timer: Timer?, interval: TimeInterval, action: @escaping @Sendable (Timer) -> Void) -> Timer {
timer?.invalidate()
return Timer.scheduledTimer(
withTimeInterval: interval,
repeats: true,
block: action
)
}
}