From fc896cbccde7084c4f0024dab2a01f56ff3094d7 Mon Sep 17 00:00:00 2001 From: Federico Zivolo Date: Mon, 22 Jan 2024 12:07:51 +0100 Subject: [PATCH 1/2] fix: git branches dropdown scroll and navigation --- .../Views/ToolbarBranchPicker.swift | 71 +++++++++---------- 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift b/CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift index fde39952ce..cf8f8ef935 100644 --- a/CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift +++ b/CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift @@ -31,52 +31,47 @@ struct ToolbarBranchPicker: View { } var body: some View { - HStack(alignment: .center, spacing: 5) { - if currentBranch != nil { - Image.checkout - .font(.title3) - .imageScale(.large) - .foregroundColor(controlActive == .inactive ? inactiveColor : .primary) - } else { - Image(systemName: "folder.fill.badge.gearshape") - .font(.title3) - .imageScale(.medium) - .foregroundColor(controlActive == .inactive ? inactiveColor : .accentColor) + Menu(content: { + if let sourceControlManager = workspaceFileManager?.sourceControlManager { + PopoverView(sourceControlManager: sourceControlManager) } - VStack(alignment: .leading, spacing: 2) { - Text(title) - .font(.headline) - .foregroundColor(controlActive == .inactive ? inactiveColor : .primary) - .frame(height: 16) - .help(title) - if let currentBranch { - ZStack(alignment: .trailing) { - Text(currentBranch.name) - .padding(.trailing) - if isHovering { - Image(systemName: "chevron.down") + }, label: { + HStack(alignment: .center, spacing: 5) { + if currentBranch != nil { + Image.checkout + .font(.title3) + .imageScale(.large) + .foregroundColor(controlActive == .inactive ? inactiveColor : .primary) + } else { + Image(systemName: "folder.fill.badge.gearshape") + .font(.title3) + .imageScale(.medium) + .foregroundColor(controlActive == .inactive ? inactiveColor : .accentColor) + } + VStack(alignment: .leading, spacing: 2) { + Text(title) + .font(.headline) + .foregroundColor(controlActive == .inactive ? inactiveColor : .primary) + .frame(height: 16) + .help(title) + if let currentBranch { + ZStack(alignment: .trailing) { + Text(currentBranch.name) + .padding(.trailing) + if isHovering { + Image(systemName: "chevron.down") + } } + .font(.subheadline) + .foregroundColor(controlActive == .inactive ? inactiveColor : .secondary) + .frame(height: 11) } - .font(.subheadline) - .foregroundColor(controlActive == .inactive ? inactiveColor : .secondary) - .frame(height: 11) } } - } - .contentShape(Rectangle()) - .onTapGesture { - if currentBranch != nil { - displayPopover.toggle() - } - } + }) .onHover { active in isHovering = active } - .popover(isPresented: $displayPopover, arrowEdge: .bottom) { - if let sourceControlManager = workspaceFileManager?.sourceControlManager { - PopoverView(sourceControlManager: sourceControlManager) - } - } .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { (_) in Task { await sourceControlManager?.refreshCurrentBranch() From 1b0b1291f078b23f65a463e26fc7c8df9370280a Mon Sep 17 00:00:00 2001 From: Federico Zivolo Date: Mon, 22 Jan 2024 16:03:38 +0100 Subject: [PATCH 2/2] fix: show project title --- .../Views/ToolbarBranchPicker.swift | 64 +++++++++---------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift b/CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift index cf8f8ef935..e9afe531e9 100644 --- a/CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift +++ b/CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift @@ -31,44 +31,40 @@ struct ToolbarBranchPicker: View { } var body: some View { - Menu(content: { - if let sourceControlManager = workspaceFileManager?.sourceControlManager { - PopoverView(sourceControlManager: sourceControlManager) + HStack(alignment: .center, spacing: 5) { + if currentBranch != nil { + Image.checkout + .font(.title3) + .imageScale(.large) + .foregroundColor(controlActive == .inactive ? inactiveColor : .primary) + } else { + Image(systemName: "folder.fill.badge.gearshape") + .font(.title3) + .imageScale(.medium) + .foregroundColor(controlActive == .inactive ? inactiveColor : .accentColor) } - }, label: { - HStack(alignment: .center, spacing: 5) { - if currentBranch != nil { - Image.checkout - .font(.title3) - .imageScale(.large) - .foregroundColor(controlActive == .inactive ? inactiveColor : .primary) - } else { - Image(systemName: "folder.fill.badge.gearshape") - .font(.title3) - .imageScale(.medium) - .foregroundColor(controlActive == .inactive ? inactiveColor : .accentColor) - } - VStack(alignment: .leading, spacing: 2) { - Text(title) - .font(.headline) - .foregroundColor(controlActive == .inactive ? inactiveColor : .primary) - .frame(height: 16) - .help(title) - if let currentBranch { - ZStack(alignment: .trailing) { - Text(currentBranch.name) - .padding(.trailing) - if isHovering { - Image(systemName: "chevron.down") - } + VStack(alignment: .leading, spacing: 2) { + Text(title) + .font(.headline) + .foregroundColor(controlActive == .inactive ? inactiveColor : .primary) + .frame(height: 16) + .help(title) + if let currentBranch { + Menu(content: { + if let sourceControlManager = workspaceFileManager?.sourceControlManager { + PopoverView(sourceControlManager: sourceControlManager) } - .font(.subheadline) - .foregroundColor(controlActive == .inactive ? inactiveColor : .secondary) - .frame(height: 11) - } + }, label: { + Text(currentBranch.name) + .font(.subheadline) + .foregroundColor(controlActive == .inactive ? inactiveColor : .secondary) + .frame(height: 11) + }) + .buttonStyle(.borderless) + .padding(.leading, -3) } } - }) + } .onHover { active in isHovering = active }