// // MetrikaApp.swift // Metrika // // Author: Simon-Pierre Boucher // Contact: contact@spboucher.ai // Copyright © 2026 Simon-Pierre Boucher. All rights reserved. // import SwiftUI @main struct MetrikaApp: App { @State private var model = SessionModel() var body: some Scene { WindowGroup { ContentView() .environment(model) .frame(minWidth: 900, minHeight: 560) } .windowStyle(.automatic) } } struct ContentView: View { enum Pane: String, CaseIterable { case console = "Console" case data = "Data" case doFile = "Do-file" case manual = "Manual" } @Environment(SessionModel.self) private var model @State private var pane: Pane = ContentView.initialPane() /// Debug hook for headless screenshots: METRIKA_AUTOPANE selects the /// pane shown at launch. private static func initialPane() -> Pane { #if DEBUG if let name = ProcessInfo.processInfo.environment["METRIKA_AUTOPANE"], let selected = Pane(rawValue: name) { return selected } #endif return .console } var body: some View { NavigationSplitView { VariablesSidebar() } detail: { Group { switch pane { case .console: HSplitView { ConsoleView() .frame(minWidth: 480) if model.lastPlot != nil { PlotView() .frame(minWidth: 300) } } case .data: DataBrowserPane() case .doFile: DoFileEditorPane() case .manual: ManualPane() } } .toolbar { ToolbarItem(placement: .principal) { Picker("Pane", selection: $pane) { ForEach(Pane.allCases, id: \.self) { pane in Text(pane.rawValue).tag(pane) } } .pickerStyle(.segmented) } } } .navigationTitle("Metrika") } }