Add DemoDestination; Remove DemoDestination
This commit is contained in:
parent
a881eaa145
commit
60083940e5
@ -8,28 +8,75 @@
|
||||
import SwiftUI
|
||||
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 {
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
List {
|
||||
Section("Storage Demos") {
|
||||
NavigationLink(value: DemoDestination.userDefaults) {
|
||||
Label("UserDefaults", systemImage: "gearshape.fill")
|
||||
}
|
||||
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")
|
||||
ForEach(DemoDestination.allCases, id: \.self) { demo in
|
||||
NavigationLink(value: demo) {
|
||||
Label(demo.title, systemImage: demo.systemImage)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -37,20 +84,7 @@ struct ContentView: View {
|
||||
.navigationTitle("Secure Storage")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationDestination(for: DemoDestination.self) { destination in
|
||||
switch destination {
|
||||
case .userDefaults:
|
||||
UserDefaultsDemo()
|
||||
case .keychain:
|
||||
KeychainDemo()
|
||||
case .files:
|
||||
FileSystemDemo()
|
||||
case .encrypted:
|
||||
EncryptedStorageDemo()
|
||||
case .sync:
|
||||
PlatformSyncDemo()
|
||||
case .migration:
|
||||
MigrationHubView()
|
||||
}
|
||||
return destination.view
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -59,12 +93,3 @@ struct ContentView: View {
|
||||
#Preview {
|
||||
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