improves the git feature by adding a conflict status

This commit is contained in:
2026-10-30 16:47:34 +01:00
parent caec81e762
commit 0278d7fbd1
14 changed files with 10927 additions and 19 deletions
@@ -145,7 +145,7 @@ private struct TreeRowView: View {
if let status {
Text(status.rawValue)
.typeRole(RowStyle.changeLetterRole)
.foregroundStyle(status == .deleted ? Palette.amberDeep : Palette.addedText)
.foregroundStyle(letterColor(status))
.padding(.leading, 8)
}
}
@@ -164,6 +164,14 @@ private struct TreeRowView: View {
.help(isDirectory ? "" : row.path)
}
private func letterColor(_ status: GitStatus) -> Color {
switch status {
case .deleted: Palette.amberDeep
case .unmerged: Palette.gitConflict
default: Palette.addedText
}
}
private var labelColor: Color {
if status == .deleted { return Palette.text4 }
return selected || (isDirectory && isOpen) ? Palette.text1 : Palette.text3
+5 -2
View File
@@ -1,9 +1,9 @@
import SwiftUI
/// The Git view's Lucide icons, drawn on Lucide's 24-unit grid at stroke 1.75.
/// The Git view's icons, drawn on Lucide's 24-unit grid at stroke 1.75; the flag is a plain pennant.
/// 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
case gitBranch, cloud, arrowDownToLine, arrowUpFromLine, minimize, chevronDown, chevronRight, eraser, check, flag
fileprivate var symbol: String? {
switch self {
@@ -46,6 +46,9 @@ enum GitIcon {
line((9, 18), (15, 12), (9, 6))
case .check:
line((20, 6), (9, 17), (4, 12))
case .flag:
line((5, 22), (5, 3))
line((5, 4), (19, 9), (5, 14))
case .cloud, .eraser:
break
}
+21 -6
View File
@@ -233,8 +233,15 @@ private struct GitFileRow: View {
GitIconView(icon: expanded ? .chevronDown : .chevronRight, size: 13)
.foregroundStyle(expanded ? Palette.amber : Palette.text4)
StatusBadge(status: row.status)
path
.frame(maxWidth: .infinity, alignment: .leading)
HStack(spacing: 8) {
path
if isConflict {
GitIconView(icon: .flag, size: 13)
.foregroundStyle(Palette.gitConflict)
.tip("Merge conflict — resolve, then Stage")
}
}
.frame(maxWidth: .infinity, alignment: .leading)
HStack(spacing: 0) {
Text("+\(row.added)").foregroundStyle(Palette.gitNew)
.frame(width: GitMetrics.statWidth, alignment: .trailing)
@@ -248,9 +255,9 @@ private struct GitFileRow: View {
}
.padding(.horizontal, 14)
.frame(height: GitMetrics.fileRow)
.background(expanded ? Palette.panel : (isHovered ? Palette.gitRowHover : .clear))
.background(expanded ? Palette.panel : (isHovered ? Palette.gitRowHover : (isConflict ? Palette.gitConflictTint : .clear)))
.overlay(alignment: .leading) {
Rectangle().fill(kind == .staged ? Palette.amber : .clear).frame(width: GitMetrics.accentBar)
Rectangle().fill(accentColor).frame(width: GitMetrics.accentBar)
}
.hairline(.bottom)
.contentShape(Rectangle())
@@ -262,6 +269,13 @@ private struct GitFileRow: View {
.tracksHover($isHovered)
}
private var isConflict: Bool { row.status == .unmerged }
private var accentColor: Color {
if isConflict { return Palette.gitConflict }
return kind == .staged ? Palette.amber : .clear
}
/// The folder and slash muted, the name bright; a deleted file is struck through with a muted name.
private var path: some View {
let dir = PathUtils.dirname(row.path)
@@ -292,7 +306,8 @@ private struct StatusBadge: View {
switch status {
case .added: Palette.gitNew
case .deleted: Palette.gitDeleted
case .modified, .renamed, .unmerged: Palette.gitModified
case .modified, .renamed: Palette.gitModified
case .unmerged: Palette.gitConflict
}
}
@@ -302,7 +317,7 @@ private struct StatusBadge: View {
case .deleted: "Deleted"
case .modified: "Modified"
case .renamed: "Renamed"
case .unmerged: "Conflict"
case .unmerged: "Merge conflict"
}
}
}
+4
View File
@@ -132,11 +132,15 @@ public enum Palette {
public static let gitModified = Color(hex: 0xF0B476)
public static let gitNew = Color(hex: 0x8FBFB4)
public static let gitDeleted = Color(hex: 0xC3A6CE)
/// The one red in the app: a merge conflict must not blend in with the soft status colours.
public static let gitConflict = Color(hex: 0xE5534B)
/// Section header fills.
public static let gitStagedTint = Color(hex: 0xE8913A, alpha: 0.08)
public static let gitModifiedTint = Color(hex: 0xF0B476, alpha: 0.06)
public static let gitNewTint = Color(hex: 0x8FBFB4, alpha: 0.06)
public static let gitDeletedTint = Color(hex: 0xC3A6CE, alpha: 0.06)
/// The fill of a conflicted row.
public static let gitConflictTint = Color(hex: 0xE5534B, alpha: 0.08)
/// The current branch row.
public static let gitCurrentBranch = Color(hex: 0xE8913A, alpha: 0.08)
/// Inline diff: line fills, the differing middle of a paired line, and the side with no line.