Select default

This commit is contained in:
Max Goedjen 2020-03-06 22:21:10 -08:00
parent f60e7c79f2
commit b1091904ed
No known key found for this signature in database
GPG Key ID: E58C21DD77B9B8E8
1 changed files with 7 additions and 2 deletions

View File

@ -4,13 +4,14 @@ 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)) {
NavigationLink(destination: SecretDetailView(secret: secret), tag: secret, selection: self.$active) {
Text(secret.name)
}.contextMenu {
Button(action: { self.delete(secret: secret) }) {
@ -19,10 +20,14 @@ struct ContentView<StoreType: SecretStore>: View {
}
}
}
}.onAppear {
self.active = self.store.secrets.first
}
.listStyle(SidebarListStyle())
.frame(minWidth: 100, idealWidth: 240)
}.navigationViewStyle(DoubleColumnNavigationViewStyle())
}
.navigationViewStyle(DoubleColumnNavigationViewStyle())
}