generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ca9e97
commit 17f9e47
Showing
4 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
Tests/UITests/TestApp/LocalStorageTests/LocalStorageLiveUpdateTestView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2025 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
|
||
import SpeziLocalStorage | ||
import SwiftUI | ||
|
||
|
||
extension LocalStorageKeys { | ||
Check failure on line 14 in Tests/UITests/TestApp/LocalStorageTests/LocalStorageLiveUpdateTestView.swift
|
||
static let number = LocalStorageKey<Int>("number") | ||
} | ||
|
||
|
||
struct LocalStorageLiveUpdateTestView: View { | ||
Check failure on line 19 in Tests/UITests/TestApp/LocalStorageTests/LocalStorageLiveUpdateTestView.swift
|
||
@Environment(LocalStorage.self) private var localStorage | ||
|
||
var body: some View { | ||
Form { | ||
RowView() | ||
Section { | ||
ForEach(0..<5) { number in | ||
Button("\(number)") { | ||
try! localStorage.store(number, for: .number) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
struct RowView: View { | ||
@LocalStorageEntry(.number) | ||
private var number | ||
Check failure on line 39 in Tests/UITests/TestApp/LocalStorageTests/LocalStorageLiveUpdateTestView.swift
|
||
|
||
var body: some View { | ||
LabeledContent("number", value: number.map(String.init) ?? "–") | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters