mirror of
https://github.com/maxgoedjen/secretive.git
synced 2024-11-22 21:47:08 +00:00
46 lines
1.4 KiB
Swift
46 lines
1.4 KiB
Swift
import SwiftUI
|
|
import SecretKit
|
|
|
|
struct ContentView<StoreType: SecretStore>: View {
|
|
|
|
@ObservedObject var store: StoreType
|
|
@State var active: StoreType.SecretType?
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
List {
|
|
Section(header: Text(store.name)) {
|
|
ForEach(store.secrets) { secret in
|
|
NavigationLink(destination: SecretDetailView(secret: secret), tag: secret, selection: self.$active) {
|
|
Text(secret.name)
|
|
}.contextMenu {
|
|
Button(action: { self.delete(secret: secret) }) {
|
|
Text("Delete")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}.onAppear {
|
|
self.active = self.store.secrets.first
|
|
}
|
|
.listStyle(SidebarListStyle())
|
|
.frame(minWidth: 100, idealWidth: 240)
|
|
}
|
|
.navigationViewStyle(DoubleColumnNavigationViewStyle())
|
|
|
|
}
|
|
|
|
|
|
func delete(secret: StoreType.SecretType) {
|
|
// TODO: Add "type the name of the key to delete" dialogue
|
|
try! store.delete(secret: secret)
|
|
}
|
|
|
|
}
|
|
//
|
|
//struct ContentView_Previews: PreviewProvider {
|
|
// static var previews: some View {
|
|
// ContentView(store: Preview.Store(numberOfRandomSecrets: 10))
|
|
// }
|
|
//}
|