secretive/Secretive/ContentView.swift

41 lines
1.2 KiB
Swift
Raw Normal View History

2020-02-19 03:36:41 +00:00
import SwiftUI
2020-02-19 04:52:00 +00:00
import SecretKit
struct ContentView<StoreType: SecretStore>: View {
@ObservedObject var store: StoreType
2020-02-19 03:36:41 +00:00
var body: some View {
2020-03-04 07:14:38 +00:00
NavigationView {
2020-02-19 04:52:00 +00:00
List {
2020-03-04 07:14:38 +00:00
Section(header: Text(store.name)) {
ForEach(store.secrets) { secret in
NavigationLink(destination: SecretDetailView(secret: secret)) {
Text(secret.name)
}.contextMenu {
Button(action: { self.delete(secret: secret) }) {
Text("Delete")
}
}
}
2020-02-19 04:52:00 +00:00
}
}
2020-03-04 07:14:38 +00:00
.listStyle(SidebarListStyle())
.frame(minWidth: 100, idealWidth: 240)
}.navigationViewStyle(DoubleColumnNavigationViewStyle())
2020-02-19 03:36:41 +00:00
}
2020-03-04 07:14:38 +00:00
func delete(secret: StoreType.SecretType) {
// TODO: Add "type the name of the key to delete" dialogue
try! store.delete(secret: secret)
}
}
2020-03-06 07:48:24 +00:00
//
//struct ContentView_Previews: PreviewProvider {
// static var previews: some View {
// ContentView(store: Preview.Store(numberOfRandomSecrets: 10))
// }
//}