Sources/Orgstar/CryptHoldBar.swift

34f0b480a611c3278a48821f0233ba97462b13d1
orgstar/Sources/Orgstar/CryptHoldBar.swift

27 lines · 1034 bytes

 1import OrgApp
 2import OrgDocument
 3import SwiftUI
 4
 5/// Above the mode line while the focused file isn't saved because it would put text on disk
 6/// unencrypted: why, and the button that asks for the passphrase. Stays while it applies.
 7struct CryptHoldBar: View {
 8    let session: DocumentSession
 9    let encrypt: () -> Void
10
11    var body: some View {
12        if let path = session.path, let hold = session.held[path] {
13            HStack(spacing: 8) {
14                Image(systemName: "lock.trianglebadge.exclamationmark").foregroundStyle(.orange)
15                Text(hold.notice(for: path)).lineLimit(3)
16                Spacer(minLength: 8)
17                Button(hold == .file ? "Set Passphrase…" : "Encrypt…", action: encrypt)
18            }
19            .font(.callout)
20            .padding(.horizontal, 10)
21            .padding(.vertical, 5)
22            .frame(maxWidth: .infinity, alignment: .leading)
23            .background(Color.orange.opacity(0.12))
24            .accessibilityElement(children: .combine)
25        }
26    }
27}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form