Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class StatusBarModel: ObservableObject {
@Published public var warningCount: Int = 0 // Implementation missing

/// The selected branch from the GitClient
@Published public var selectedBranch: String = ""
@Published public var selectedBranch: String?

/// State of pulling from git
@Published public var isReloading: Bool = false // Implementation missing
Expand Down Expand Up @@ -63,6 +63,10 @@ public class StatusBarModel: ObservableObject {
/// - Parameter gitClient: a GitClient
public init(gitClient: GitClient) {
self.gitClient = gitClient
self.selectedBranch = gitClient.getCurrentBranchName()
if gitClient.getCurrentBranchName().contains("fatal: not a git repository") {
self.selectedBranch = nil
} else {
self.selectedBranch = gitClient.getCurrentBranchName()
}
}
}
6 changes: 4 additions & 2 deletions CodeEditModules/Modules/StatusBar/src/StatusBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ public struct StatusBarView: View {
StatusBarLabelButton(model: model, title: model.errorCount.formatted(), image: "xmark.octagon")
StatusBarLabelButton(model: model, title: model.warningCount.formatted(), image: "exclamationmark.triangle")
}
StatusBarBranchPicker(model: model)
StatusBarPullButton(model: model)
if model.selectedBranch != nil {
StatusBarBranchPicker(model: model)
StatusBarPullButton(model: model)
}
Spacer()
StatusBarCursorLocationLabel(model: model)
StatusBarIndentSelector(model: model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal struct StatusBarBranchPicker: View {

internal var body: some View {
Menu {

ForEach(model.gitClient.getBranches(), id: \.self) { branch in
Button {
do {
Expand All @@ -41,11 +42,12 @@ internal struct StatusBarBranchPicker: View {
}
}
} label: {
Text(model.selectedBranch)
Text(model.selectedBranch ?? "No Git Repository")
.font(model.toolbarFont)
}
.menuStyle(.borderlessButton)
.fixedSize()
.onHover { isHovering($0) }
.disabled(model.selectedBranch == nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ internal struct StatusBarPullButton: View {
}

}
.buttonStyle(.borderless)
.buttonStyle(.plain)
.foregroundStyle(.primary)
.onHover { isHovering($0) }
.disabled(model.selectedBranch == nil)
}

// Temporary
Expand Down