Update SecureStorageSample
This commit is contained in:
parent
3139270a86
commit
e025e435bc
@ -80,10 +80,10 @@ struct PlatformSyncDemo: View {
|
||||
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)"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user