| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- // LoopFollow
- // URLTokenValidationView.swift
- import SwiftUI
- struct URLTokenValidationView: View {
- let settings: RemoteCommandSettings
- let shouldPromptForURL: Bool
- let shouldPromptForToken: Bool
- let message: String
- let onConfirm: (RemoteCommandSettings) -> Void
- let onCancel: () -> Void
- init(
- settings: RemoteCommandSettings,
- shouldPromptForURL: Bool,
- shouldPromptForToken: Bool,
- message: String,
- onConfirm: @escaping (RemoteCommandSettings) -> Void,
- onCancel: @escaping () -> Void
- ) {
- self.settings = settings
- self.shouldPromptForURL = shouldPromptForURL
- self.shouldPromptForToken = shouldPromptForToken
- self.message = message
- self.onConfirm = onConfirm
- self.onCancel = onCancel
- }
- var body: some View {
- Form {
- Section {
- Text(message)
- .font(.body)
- .foregroundColor(.primary)
- }
- // Show URL section if we have URL data
- if !settings.url.isEmpty {
- Section(header: Text("Nightscout URL")) {
- HStack {
- Text("Current URL:")
- Spacer()
- Text(Storage.shared.url.value.isEmpty ? "Not set" : Storage.shared.url.value)
- .foregroundColor(.secondary)
- }
- HStack {
- Text("Scanned URL:")
- Spacer()
- Text(settings.url)
- .foregroundColor(.primary)
- }
- }
- }
- // Show token section if we have token data
- if !settings.token.isEmpty {
- Section(header: Text("Access Token")) {
- HStack {
- Text("Current Token:")
- Spacer()
- Text(Storage.shared.token.value.isEmpty ? "Not set" : "••••••••")
- .foregroundColor(.secondary)
- }
- HStack {
- Text("Scanned Token:")
- Spacer()
- Text("••••••••")
- .foregroundColor(.primary)
- }
- }
- }
- Section {
- HStack {
- Button("Cancel") {
- onCancel()
- }
- .buttonStyle(.bordered)
- Spacer()
- Button("Confirm & Import") {
- onConfirm(settings)
- }
- .buttonStyle(.borderedProminent)
- }
- }
- }
- .navigationTitle("URL/Token Validation")
- .navigationBarTitleDisplayMode(.inline)
- .navigationBarItems(trailing: Button("Cancel") {
- onCancel()
- })
- }
- }
|