Add iOS/iPad target with platform-adaptive UI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-03-30 21:30:28 -05:00
parent 127125ae1b
commit fda809fd2f
21 changed files with 851 additions and 129 deletions

View File

@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,8 @@
{
"images" : [
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

42
mlbIOS/Info.plist Normal file
View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
<key>UILaunchScreen</key>
<dict/>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,106 @@
import SwiftUI
private enum mlbIOSSection: String, CaseIterable, Identifiable {
case games
case league
case multiView
case settings
var id: String { rawValue }
var title: String {
switch self {
case .games: "Games"
case .league: "League"
case .multiView: "Multi-View"
case .settings: "Settings"
}
}
var systemImage: String {
switch self {
case .games: "sportscourt.fill"
case .league: "list.bullet.rectangle.portrait.fill"
case .multiView: "rectangle.split.2x2.fill"
case .settings: "gearshape.fill"
}
}
}
struct mlbIOSRootView: View {
@Environment(GamesViewModel.self) private var viewModel
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@State private var selectedSection: mlbIOSSection? = .games
private var usesCompactTabs: Bool {
horizontalSizeClass == .compact
}
private var multiViewTitle: String {
let count = viewModel.activeStreams.count
return count > 0 ? "Multi-View (\(count))" : "Multi-View"
}
var body: some View {
Group {
if usesCompactTabs {
compactTabs
} else {
splitView
}
}
.task {
if viewModel.games.isEmpty, !viewModel.isLoading {
await viewModel.loadGames()
}
}
}
private var compactTabs: some View {
TabView {
Tab("Games", systemImage: "sportscourt.fill") {
DashboardView()
}
Tab("League", systemImage: "list.bullet.rectangle.portrait.fill") {
LeagueCenterView()
}
Tab(multiViewTitle, systemImage: "rectangle.split.2x2.fill") {
MultiStreamView()
}
Tab("Settings", systemImage: "gearshape.fill") {
SettingsView()
}
}
}
private var splitView: some View {
NavigationSplitView {
List(mlbIOSSection.allCases, selection: $selectedSection) { section in
Label(section.title, systemImage: section.systemImage)
.tag(section)
}
.navigationTitle("MLB")
} detail: {
NavigationStack {
detailView(for: selectedSection ?? .games)
.navigationTitle(selectedSection?.title ?? mlbIOSSection.games.title)
.navigationBarTitleDisplayMode(.inline)
}
}
.navigationSplitViewStyle(.balanced)
}
@ViewBuilder
private func detailView(for section: mlbIOSSection) -> some View {
switch section {
case .games:
DashboardView()
case .league:
LeagueCenterView()
case .multiView:
MultiStreamView()
case .settings:
SettingsView()
}
}
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

26
mlbIOS/mlbIOSApp.swift Normal file
View File

@@ -0,0 +1,26 @@
import AVFoundation
import SwiftUI
@main
struct mlbIOSApp: App {
@State private var viewModel = GamesViewModel()
init() {
configureAudioSession()
}
var body: some Scene {
WindowGroup {
mlbIOSRootView()
.environment(viewModel)
}
}
private func configureAudioSession() {
do {
try AVAudioSession.sharedInstance().setCategory(.ambient)
} catch {
print("Failed to set audio session: \(error)")
}
}
}