Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
d2bf6004e1
commit
0a28f55229
@ -8,28 +8,75 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import LocalData
|
import LocalData
|
||||||
|
|
||||||
|
private enum DemoDestination: Hashable, CaseIterable {
|
||||||
|
case userDefaults
|
||||||
|
case keychain
|
||||||
|
case files
|
||||||
|
case encrypted
|
||||||
|
case sync
|
||||||
|
case migration
|
||||||
|
|
||||||
|
var view: some View {
|
||||||
|
switch self {
|
||||||
|
case .userDefaults:
|
||||||
|
return AnyView(UserDefaultsDemo())
|
||||||
|
case .keychain:
|
||||||
|
return AnyView(KeychainDemo())
|
||||||
|
case .files:
|
||||||
|
return AnyView(FileSystemDemo())
|
||||||
|
case .encrypted:
|
||||||
|
return AnyView(EncryptedStorageDemo())
|
||||||
|
case .sync:
|
||||||
|
return AnyView(PlatformSyncDemo())
|
||||||
|
case .migration:
|
||||||
|
return AnyView(MigrationHubView())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var title: String {
|
||||||
|
switch self {
|
||||||
|
case .userDefaults:
|
||||||
|
return "UserDefaults"
|
||||||
|
case .keychain:
|
||||||
|
return "Keychain"
|
||||||
|
case .files:
|
||||||
|
return "File Storage"
|
||||||
|
case .encrypted:
|
||||||
|
return "Encrypted Storage"
|
||||||
|
case .sync:
|
||||||
|
return "Watch Sync"
|
||||||
|
case .migration:
|
||||||
|
return "Migrations"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var systemImage: String {
|
||||||
|
switch self {
|
||||||
|
case .userDefaults:
|
||||||
|
return "gearshape.fill"
|
||||||
|
case .keychain:
|
||||||
|
return "lock.fill"
|
||||||
|
case .files:
|
||||||
|
return "doc.fill"
|
||||||
|
case .encrypted:
|
||||||
|
return "lock.shield.fill"
|
||||||
|
case .sync:
|
||||||
|
return "arrow.triangle.2.circlepath"
|
||||||
|
case .migration:
|
||||||
|
return "sparkles"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
List {
|
List {
|
||||||
Section("Storage Demos") {
|
Section("Storage Demos") {
|
||||||
NavigationLink(value: DemoDestination.userDefaults) {
|
ForEach(DemoDestination.allCases, id: \.self) { demo in
|
||||||
Label("UserDefaults", systemImage: "gearshape.fill")
|
NavigationLink(value: demo) {
|
||||||
}
|
Label(demo.title, systemImage: demo.systemImage)
|
||||||
NavigationLink(value: DemoDestination.keychain) {
|
}
|
||||||
Label("Keychain", systemImage: "lock.fill")
|
|
||||||
}
|
|
||||||
NavigationLink(value: DemoDestination.files) {
|
|
||||||
Label("File Storage", systemImage: "doc.fill")
|
|
||||||
}
|
|
||||||
NavigationLink(value: DemoDestination.encrypted) {
|
|
||||||
Label("Encrypted Storage", systemImage: "lock.shield.fill")
|
|
||||||
}
|
|
||||||
NavigationLink(value: DemoDestination.sync) {
|
|
||||||
Label("Watch Sync", systemImage: "arrow.triangle.2.circlepath")
|
|
||||||
}
|
|
||||||
NavigationLink(value: DemoDestination.migration) {
|
|
||||||
Label("Migrations", systemImage: "sparkles")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,20 +84,7 @@ struct ContentView: View {
|
|||||||
.navigationTitle("Secure Storage")
|
.navigationTitle("Secure Storage")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.navigationDestination(for: DemoDestination.self) { destination in
|
.navigationDestination(for: DemoDestination.self) { destination in
|
||||||
switch destination {
|
return destination.view
|
||||||
case .userDefaults:
|
|
||||||
UserDefaultsDemo()
|
|
||||||
case .keychain:
|
|
||||||
KeychainDemo()
|
|
||||||
case .files:
|
|
||||||
FileSystemDemo()
|
|
||||||
case .encrypted:
|
|
||||||
EncryptedStorageDemo()
|
|
||||||
case .sync:
|
|
||||||
PlatformSyncDemo()
|
|
||||||
case .migration:
|
|
||||||
MigrationHubView()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,12 +93,3 @@ struct ContentView: View {
|
|||||||
#Preview {
|
#Preview {
|
||||||
ContentView()
|
ContentView()
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum DemoDestination: Hashable {
|
|
||||||
case userDefaults
|
|
||||||
case keychain
|
|
||||||
case files
|
|
||||||
case encrypted
|
|
||||||
case sync
|
|
||||||
case migration
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user