adds nice git interface

This commit is contained in:
2026-10-30 13:21:45 +01:00
parent b9c03a7637
commit caec81e762
107 changed files with 6466 additions and 3992 deletions
+71
View File
@@ -0,0 +1,71 @@
import SwiftUI
/// The Git view's Lucide icons, drawn on Lucide's 24-unit grid at stroke 1.75.
/// Icons with arcs Lucide draws as curves (cloud, eraser) use the nearest SF Symbol.
enum GitIcon {
case gitBranch, cloud, arrowDownToLine, arrowUpFromLine, minimize, chevronDown, chevronRight, eraser, check
fileprivate var symbol: String? {
switch self {
case .cloud: "cloud"
case .eraser: "eraser"
default: nil
}
}
fileprivate func path(_ k: CGFloat) -> Path {
func p(_ x: CGFloat, _ y: CGFloat) -> CGPoint { CGPoint(x: x * k, y: y * k) }
var path = Path()
func line(_ points: (CGFloat, CGFloat)...) {
path.move(to: p(points[0].0, points[0].1))
for point in points.dropFirst() { path.addLine(to: p(point.0, point.1)) }
}
switch self {
case .gitBranch:
line((6, 3), (6, 15))
path.addEllipse(in: CGRect(x: 15 * k, y: 3 * k, width: 6 * k, height: 6 * k))
path.addEllipse(in: CGRect(x: 3 * k, y: 15 * k, width: 6 * k, height: 6 * k))
path.move(to: p(18, 9))
path.addQuadCurve(to: p(9, 18), control: p(18, 18))
case .arrowDownToLine:
line((12, 17), (12, 3))
line((6, 11), (12, 17), (18, 11))
line((19, 21), (5, 21))
case .arrowUpFromLine:
line((18, 9), (12, 3), (6, 9))
line((12, 3), (12, 17))
line((5, 21), (19, 21))
case .minimize:
line((14, 10), (21, 3))
line((20, 10), (14, 10), (14, 4))
line((3, 21), (10, 14))
line((4, 14), (10, 14), (10, 20))
case .chevronDown:
line((6, 9), (12, 15), (18, 9))
case .chevronRight:
line((9, 18), (15, 12), (9, 6))
case .check:
line((20, 6), (9, 17), (4, 12))
case .cloud, .eraser:
break
}
return path
}
}
struct GitIconView: View {
let icon: GitIcon
var size: CGFloat = 14
var body: some View {
if let symbol = icon.symbol {
Image(systemName: symbol)
.font(.system(size: size * 0.82, weight: .light))
.frame(width: size, height: size)
} else {
icon.path(size / 24)
.stroke(style: StrokeStyle(lineWidth: 1.75 * size / 24, lineCap: .round, lineJoin: .round))
.frame(width: size, height: size)
}
}
}