mirror of
https://github.com/maxgoedjen/secretive.git
synced 2024-11-22 13:37:07 +00:00
59ec40c611
* Moving create to a popover. * Switch to popover here too
42 lines
1.3 KiB
Swift
42 lines
1.3 KiB
Swift
import SwiftUI
|
|
import SecretKit
|
|
|
|
struct SecretListView: View {
|
|
|
|
@ObservedObject var store: AnySecretStore
|
|
@Binding var activeSecret: AnySecret.ID?
|
|
@Binding var deletingSecret: AnySecret?
|
|
|
|
var deletedSecret: (AnySecret) -> Void
|
|
|
|
var body: some View {
|
|
ForEach(store.secrets) { secret in
|
|
NavigationLink(destination: SecretDetailView(secret: secret), tag: secret.id, selection: $activeSecret) {
|
|
Text(secret.name)
|
|
}.contextMenu {
|
|
if store is AnySecretStoreModifiable {
|
|
Button(action: { delete(secret: secret) }) {
|
|
Text("Delete")
|
|
}
|
|
}
|
|
}
|
|
.popover(isPresented: .constant(deletingSecret == secret)) {
|
|
if let modifiable = store as? AnySecretStoreModifiable {
|
|
DeleteSecretView(store: modifiable, secret: secret) { deleted in
|
|
deletingSecret = nil
|
|
if deleted {
|
|
deletedSecret(AnySecret(secret))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
func delete<SecretType: Secret>(secret: SecretType) {
|
|
deletingSecret = AnySecret(secret)
|
|
}
|
|
|
|
}
|