// CxLLM Studio — iOS Application // Views/Settings/SettingsView.swift — iOS app configuration import SwiftUI import CxCode import CxAWS struct SettingsView: View { @Environment(AppState.self) private var appState @Environment(GatewayService.self) private var gateway @Environment(AWSService.self) private var aws @State private var baseURL = UserDefaults.standard.string(forKey: "cxllm_url") ?? "https://cxllm-studio.com" @State private var apiKey = UserDefaults.standard.string(forKey: "cxllm_api_key") ?? "" @State private var awsKey = UserDefaults.standard.string(forKey: "aws_access_key") ?? "" @State private var awsSecret = UserDefaults.standard.string(forKey: "aws_secret_key") ?? "" @State private var awsRegion = UserDefaults.standard.string(forKey: "aws_region") ?? "us-east-2" @State private var healthResult: String? var body: some View { Form { Section("Gateway") { TextField("Base URL", text: $baseURL) .keyboardType(.URL) .autocapitalization(.none) SecureField("API Key", text: $apiKey) } Section("AWS") { TextField("Access Key ID", text: $awsKey) .autocapitalization(.none) SecureField("Secret Access Key", text: $awsSecret) TextField("Region", text: $awsRegion) .autocapitalization(.none) } Section("Default Model") { Picker("Model", selection: Bindable(appState).selectedModel) { ForEach(CxModelSlot.allCases) { slot in Label(slot.codename, systemImage: slot.icon) .tag(slot) } } } Section("Status") { LabeledContent("Gateway") { HStack { Circle() .fill(gateway.isConnected ? .green : .red) .frame(width: 8, height: 8) Text(gateway.isConnected ? "Connected" : "Offline") } } LabeledContent("AWS") { HStack { Circle() .fill(aws.isConnected ? .green : .red) .frame(width: 8, height: 8) Text(aws.isConnected ? "Connected" : "Offline") } } Button("Check Health") { Task { await gateway.checkHealth() await aws.checkHealth() healthResult = "Checked" } } } Section("About") { LabeledContent("App", value: "CxLLM Studio 1.0") LabeledContent("Platform", value: "iOS") LabeledContent("Models", value: "7 cx-model slots") } Section { Button("Save Settings") { UserDefaults.standard.set(baseURL, forKey: "cxllm_url") UserDefaults.standard.set(apiKey, forKey: "cxllm_api_key") UserDefaults.standard.set(awsKey, forKey: "aws_access_key") UserDefaults.standard.set(awsSecret, forKey: "aws_secret_key") UserDefaults.standard.set(awsRegion, forKey: "aws_region") } .buttonStyle(.borderedProminent) } } } }