From e025e435bc53add2eb5b5f04b023ce985c219a91 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 16 Jan 2026 16:56:36 -0600 Subject: [PATCH] Update SecureStorageSample --- .../Views/PlatformSyncDemo.swift | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/SecureStorageSample/Views/PlatformSyncDemo.swift b/SecureStorageSample/Views/PlatformSyncDemo.swift index 6164633..ef73d62 100644 --- a/SecureStorageSample/Views/PlatformSyncDemo.swift +++ b/SecureStorageSample/Views/PlatformSyncDemo.swift @@ -76,14 +76,14 @@ struct PlatformSyncDemo: View { } } .disabled(isLoading) - + Button(action: testPlatformError) { HStack { Image(systemName: "exclamationmark.triangle") - Text("Test Platform Restriction") + Text("Test Current Availability") } } - .foregroundStyle(.orange) + .foregroundStyle(Color.Status.warning) .disabled(isLoading) } @@ -98,8 +98,8 @@ struct PlatformSyncDemo: View { Section { Text(statusMessage) .font(.caption) - .foregroundStyle(statusMessage.contains("Error") ? .red : - statusMessage.contains("⚠") ? .orange : .green) + .foregroundStyle(statusMessage.contains("Error") ? Color.Status.error : + statusMessage.contains("⚠") ? Color.Status.warning : Color.Status.success) } } @@ -114,6 +114,7 @@ struct PlatformSyncDemo: View { LabeledContent("Platform", value: selectedPlatform.displayName) LabeledContent("Sync", value: selectedSync.displayName) LabeledContent("Max Auto-Sync Size", value: "50 KB") + LabeledContent("Key Name", value: StorageKeys.SyncableSettingKey().name) } Section("Watch Notes") { @@ -182,12 +183,17 @@ struct PlatformSyncDemo: View { private func testPlatformError() { isLoading = true Task { - let key = StorageKeys.WatchVibrationKey() do { + let key = StorageKeys.SyncableSettingKey( + availability: selectedPlatform, + syncPolicy: selectedSync + ) _ = try await StorageRouter.shared.get(key) - statusMessage = "⚠ Accessed successfully (running on Watch?)" + statusMessage = "✓ Current availability allows iPhone access" } catch StorageError.watchOnlyKeyAccessedOnPhone(let name) { statusMessage = "⚠ Expected Error: Key '\(name)' is watchOnly, accessed from iPhone" + } catch StorageError.notFound { + statusMessage = "⚠ No stored value. Availability allows access." } catch { statusMessage = "Error: \(error.localizedDescription)" }