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:
11
mlbIOS/Assets.xcassets/AccentColor.colorset/Contents.json
Normal file
11
mlbIOS/Assets.xcassets/AccentColor.colorset/Contents.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
8
mlbIOS/Assets.xcassets/AppIcon.appiconset/Contents.json
Normal file
8
mlbIOS/Assets.xcassets/AppIcon.appiconset/Contents.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"images" : [
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
6
mlbIOS/Assets.xcassets/Contents.json
Normal file
6
mlbIOS/Assets.xcassets/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
42
mlbIOS/Info.plist
Normal file
42
mlbIOS/Info.plist
Normal 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>
|
||||
106
mlbIOS/Views/mlbIOSRootView.swift
Normal file
106
mlbIOS/Views/mlbIOSRootView.swift
Normal 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
6
mlbIOS/mlbIOS.entitlements
Normal file
6
mlbIOS/mlbIOS.entitlements
Normal 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
26
mlbIOS/mlbIOSApp.swift
Normal 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)")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user