restores Helder in all its glory

This commit is contained in:
2026-09-28 11:34:49 +02:00
parent c2b38b853c
commit 1d29d0952d
280 changed files with 29205 additions and 7 deletions
+54
View File
@@ -0,0 +1,54 @@
import HelderCore
import SwiftUI
/// The bar above the code: which file is open, whether it is unsaved or changed, and its Preview and Diff buttons.
/// With no file open it stays as an empty bar, so the column's top edge lines up with its neighbours.
struct EditorBar: View {
var editor: EditorStore?
var presentation: EditorPresentation?
var body: some View {
HStack(spacing: 10) {
if let editor, let presentation {
content(editor, presentation)
}
}
.padding(.horizontal, 14)
.frame(height: Metrics.editorBar)
.frame(maxWidth: .infinity, alignment: .leading)
.background(Palette.editor)
.overlay(alignment: .bottom) { Rectangle().fill(Palette.raised).frame(height: Metrics.hairline) }
}
@ViewBuilder
private func content(_ editor: EditorStore, _ presentation: EditorPresentation) -> some View {
let path = presentation.path
TypeBadge(path: path)
Text(path)
.typeRole(Typography.path)
.foregroundStyle(Palette.text2)
.lineLimit(1)
.truncationMode(.head)
.help(path)
if editor.isDirty(path) {
Circle().fill(Palette.text2).frame(width: 7, height: 7)
.accessibilityLabel("Unsaved changes")
}
if let diff = editor.diff(for: path), presentation.hasDiff {
HStack(spacing: 8) {
if diff.added > 0 { Text("+\(diff.added)").foregroundStyle(Palette.addedText) }
if diff.removed > 0 { Text("\u{2212}\(diff.removed)").foregroundStyle(Palette.removedText) }
}
.typeRole(TypeRole(.monoMedium, 12))
}
Spacer(minLength: 0)
ForEach(presentation.barButtons, id: \.self) { button in
switch button {
case .preview:
SegmentButton("Preview", isOn: presentation.mode == .preview) { editor.togglePreview() }
case .diff:
SegmentButton("Diff", isOn: presentation.mode == .diff) { editor.setMode(.diff, for: path) }
}
}
}
}