From de16a9d7b87f23a40d5f48ca0c7de63b2c851c75 Mon Sep 17 00:00:00 2001 From: Beingpax Date: Wed, 9 Apr 2025 17:45:07 +0545 Subject: [PATCH] feat: make custom provider base URL and model fields conditionally editable based on API key state --- VoiceInk/Views/APIKeyManagementView.swift | 28 +++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/VoiceInk/Views/APIKeyManagementView.swift b/VoiceInk/Views/APIKeyManagementView.swift index 9aab1c7..ec5c1be 100644 --- a/VoiceInk/Views/APIKeyManagementView.swift +++ b/VoiceInk/Views/APIKeyManagementView.swift @@ -358,14 +358,29 @@ struct APIKeyManagementView: View { // Configuration Fields VStack(alignment: .leading, spacing: 8) { - TextField("Base URL (e.g., https://api.example.com/v1/chat/completions)", text: $aiService.customBaseURL) - .textFieldStyle(.roundedBorder) - - TextField("Model Name (e.g., gpt-4o-mini, claude-3-5-sonnet-20240620)", text: $aiService.customModel) - .textFieldStyle(.roundedBorder) + if !aiService.isAPIKeyValid { + TextField("Base URL (e.g., https://api.example.com/v1/chat/completions)", text: $aiService.customBaseURL) + .textFieldStyle(.roundedBorder) + + TextField("Model Name (e.g., gpt-4o-mini, claude-3-5-sonnet-20240620)", text: $aiService.customModel) + .textFieldStyle(.roundedBorder) + } else { + VStack(alignment: .leading, spacing: 8) { + Text("Base URL") + .font(.subheadline) + .foregroundColor(.secondary) + Text(aiService.customBaseURL) + .font(.system(.body, design: .monospaced)) + + Text("Model") + .font(.subheadline) + .foregroundColor(.secondary) + Text(aiService.customModel) + .font(.system(.body, design: .monospaced)) + } + } if aiService.isAPIKeyValid { - // Show masked API key when valid Text("API Key") .font(.subheadline) .foregroundColor(.secondary) @@ -385,7 +400,6 @@ struct APIKeyManagementView: View { .buttonStyle(.borderless) } } else { - // Show API key input when not valid Text("Enter your API Key") .font(.subheadline) .foregroundColor(.secondary)