Skip to content

Commit

Permalink
fix: branch selector icons
Browse files Browse the repository at this point in the history
  • Loading branch information
FezVrasta committed Jan 25, 2024
1 parent f15c2a4 commit 7c7a8a7
Showing 1 changed file with 12 additions and 28 deletions.
40 changes: 12 additions & 28 deletions CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct ToolbarBranchPicker: View {
var body: some View {
HStack(alignment: .center, spacing: 5) {
if currentBranch != nil {
Image.checkout
Image.branch
.font(.title3)
.imageScale(.large)
.foregroundColor(controlActive == .inactive ? inactiveColor : .primary)
Expand Down Expand Up @@ -103,7 +103,7 @@ struct ToolbarBranchPicker: View {
var body: some View {
VStack(alignment: .leading) {
if let currentBranch = sourceControlManager.currentBranch {
VStack(alignment: .leading, spacing: 0) {
Section {
headerLabel("Current Branch")
BranchCell(sourceControlManager: sourceControlManager, branch: currentBranch, active: true)
}
Expand All @@ -123,7 +123,7 @@ struct ToolbarBranchPicker: View {
}

if !branches.isEmpty {
VStack(alignment: .leading, spacing: 0) {
Section {
headerLabel("Branches")
ForEach(branchesGroups.keys.sorted(), id: \.self) { branchGroupPrefix in
if let group = branchesGroups[branchGroupPrefix] {
Expand All @@ -144,7 +144,10 @@ struct ToolbarBranchPicker: View {
)
}
}, label: {
Text(group.name)
HStack {
Image(systemName: "folder")
Text(group.name)
}
})
}
}
Expand Down Expand Up @@ -173,9 +176,9 @@ struct ToolbarBranchPicker: View {
/// A Button Cell that represents a branch in the branch picker
struct BranchCell: View {
let sourceControlManager: SourceControlManager
var branch: GitBranch
let branch: GitBranch
let active: Bool
let title: String?
var active: Bool = false

init(
sourceControlManager: SourceControlManager,
Expand All @@ -192,37 +195,18 @@ struct ToolbarBranchPicker: View {
@Environment(\.dismiss)
private var dismiss

@State private var isHovering: Bool = false

var body: some View {
Button {
switchBranch()
} label: {
HStack {
Label {
Text(self.title ?? branch.name)
.frame(maxWidth: .infinity, alignment: .leading)
} icon: {
Image.checkout
.imageScale(.large)
}
.foregroundColor(isHovering ? .white : .secondary)
if active {
Image(systemName: "checkmark.circle.fill")
.foregroundColor(isHovering ? .white : .green)
} else {
Image.branch
}
Text(self.title ?? branch.name)
}
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.padding(.horizontal)
.padding(.vertical, 10)
.background(
EffectView.selectionBackground(isHovering)
)
.clipShape(RoundedRectangle(cornerRadius: 4))
.onHover { active in
isHovering = active
}
}

Expand Down

0 comments on commit 7c7a8a7

Please sign in to comment.