1→// 2→// ContentView.swift 3→// KortexOS 4→// 5→// Main navigation with TabView (iPhone) and NavigationSplitView (iPad) 6→// 7→ 8→import SwiftUI 9→ 10→struct ContentView: View { 11→ @StateObject private var dataManager = DataManager.shared 12→ @Environment(\.horizontalSizeClass) private var horizontalSizeClass 13→ 14→ @State private var selectedTab: Tab = .dashboard 15→ 16→ enum Tab: String, CaseIterable { 17→ case dashboard = "Dashboard" 18→ case ritual = "Ritual" 19→ case lifeMap = "Life Map" 20→ case journal = "Journal" 21→ case ai = "ZAIROS" 22→ case settings = "Settings" 23→ 24→ var icon: String { 25→ switch self { 26→ case .dashboard: return "square.grid.2x2" 27→ case .ritual: return "sunrise.fill" 28→ case .lifeMap: return "map" 29→ case .journal: return "book.fill" 30→ case .ai: return "brain.head.profile" 31→ case .settings: return "gearshape.fill" 32→ } 33→ } 34→ 35→ var color: Color { 36→ switch self { 37→ case .dashboard: return .blue 38→ case .ritual: return .orange 39→ case .lifeMap: return .purple 40→ case .journal: return .green 41→ case .ai: return .indigo 42→ case .settings: return .gray 43→ } 44→ } 45→ } 46→ 47→ var body: some View { 48→ Group { 49→ if horizontalSizeClass == .regular { 50→ // iPad: NavigationSplitView 51→ iPadNavigationView 52→ } else { 53→ // iPhone: TabView 54→ iPhoneTabView 55→ } 56→ } 57→ .environmentObject(dataManager) 58→ .toastContainer() // Toast notifications 59→ .networkAware() // Network status banner 60→ // Deep link notification handlers 61→ .onReceive(NotificationCenter.default.publisher(for: .openRitualFromNotification)) { _ in 62→ selectedTab = .ritual 63→ } 64→ .onReceive(NotificationCenter.default.publisher(for: .openJournalFromNotification)) { _ in 65→ selectedTab = .journal 66→ } 67→ .onReceive(NotificationCenter.default.publisher(for: .openDashboardFromNotification)) { _ in 68→ selectedTab = .dashboard 69→ } 70→ .onReceive(NotificationCenter.default.publisher(for: .openLifeMapFromNotification)) { _ in 71→ selectedTab = .lifeMap 72→ } 73→ .onReceive(NotificationCenter.default.publisher(for: .openAIFromNotification)) { _ in 74→ selectedTab = .ai 75→ } 76→ .onReceive(NotificationCenter.default.publisher(for: .openSettingsFromNotification)) { _ in 77→ selectedTab = .settings 78→ } 79→ // Handle URL scheme when app is already running 80→ .onOpenURL { url in 81→ handleDeepLink(url) 82→ } 83→ } 84→ 85→ // MARK: - iPhone TabView 86→ 87→ private var iPhoneTabView: some View { 88→ TabView(selection: $selectedTab) { 89→ MissionControlView() 90→ .tabItem { 91→ Label(Tab.dashboard.rawValue, systemImage: Tab.dashboard.icon) 92→ } 93→ .tag(Tab.dashboard) 94→ 95→ RitualView() 96→ .tabItem { 97→ Label(Tab.ritual.rawValue, systemImage: Tab.ritual.icon) 98→ } 99→ .tag(Tab.ritual) 100→ 101→ LifeMapView() 102→ .tabItem { 103→ Label(Tab.lifeMap.rawValue, systemImage: Tab.lifeMap.icon) 104→ } 105→ .tag(Tab.lifeMap) 106→ 107→ JournalView() 108→ .tabItem { 109→ Label(Tab.journal.rawValue, systemImage: Tab.journal.icon) 110→ } 111→ .tag(Tab.journal) 112→ 113→ AIChatView() 114→ .tabItem { 115→ Label(Tab.ai.rawValue, systemImage: Tab.ai.icon) 116→ } 117→ .tag(Tab.ai) 118→ 119→ SettingsView() 120→ .tabItem { 121→ Label(Tab.settings.rawValue, systemImage: Tab.settings.icon) 122→ } 123→ .tag(Tab.settings) 124→ } 125→ .tint(.kortexAccent) 126→ } 127→ 128→ // MARK: - iPad NavigationSplitView 129→ 130→ private var iPadNavigationView: some View { 131→ NavigationSplitView { 132→ // Sidebar 133→ List { 134→ ForEach(Tab.allCases, id: \.self) { tab in 135→ Button { 136→ selectedTab = tab 137→ } label: { 138→ Label(tab.rawValue, systemImage: tab.icon) 139→ .foregroundColor(selectedTab == tab ? tab.color : .kortexText) 140→ } 141→ .listRowBackground(selectedTab == tab ? tab.color.opacity(0.1) : Color.clear) 142→ } 143→ } 144→ .navigationTitle("KortexOS") 145→ } detail: { 146→ // Detail view 147→ switch selectedTab { 148→ case .dashboard: 149→ MissionControlView() 150→ case .ritual: 151→ RitualView() 152→ case .lifeMap: 153→ LifeMapView() 154→ case .journal: 155→ JournalView() 156→ case .ai: 157→ AIChatView() 158→ case .settings: 159→ SettingsView() 160→ } 161→ } 162→ } 163→ 164→ // MARK: - Deep Link Handler 165→ 166→ private func handleDeepLink(_ url: URL) { 167→ guard url.scheme == "kortexos" else { return } 168→ 169→ switch url.host { 170→ case "ritual": 171→ selectedTab = .ritual 172→ case "journal": 173→ selectedTab = .journal 174→ case "dashboard": 175→ selectedTab = .dashboard 176→ case "lifemap": 177→ selectedTab = .lifeMap 178→ case "ai", "zairos": 179→ selectedTab = .ai 180→ case "settings": 181→ selectedTab = .settings 182→ default: 183→ break 184→ } 185→ } 186→} 187→ 188→// MARK: - Preview 189→ 190→#Preview { 191→ ContentView() 192→} 193→ Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.