Improves Git's user interface
This commit is contained in:
@@ -10,10 +10,17 @@ struct GitView: View {
|
||||
if let store = model.sourceControl {
|
||||
VStack(spacing: 0) {
|
||||
GitTopBar(model: model, store: store)
|
||||
GitCommitBlock(model: model, store: store)
|
||||
GitSectionsList(model: model, store: store)
|
||||
.frame(maxHeight: .infinity)
|
||||
GitBottomStrip(model: model, store: store)
|
||||
GeometryReader { proxy in
|
||||
switch GitBodyMode(width: proxy.size.width) {
|
||||
case .sideColumns:
|
||||
GitSideColumns(model: model, store: store, height: proxy.size.height)
|
||||
case .bottomStrip:
|
||||
VStack(spacing: 0) {
|
||||
GitChanges(model: model, store: store)
|
||||
GitBottomStrip(model: model, store: store)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Color.clear
|
||||
@@ -25,6 +32,50 @@ struct GitView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// The commit block over the sections, filling the height it gets.
|
||||
private struct GitChanges: View {
|
||||
let model: WorkspaceModel
|
||||
let store: SourceControlStore
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
GitCommitBlock(model: model, store: store)
|
||||
GitSectionsList(model: model, store: store)
|
||||
.frame(maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Branches over commits on the left, the changes in the middle, the console on the right, all full height.
|
||||
private struct GitSideColumns: View {
|
||||
let model: WorkspaceModel
|
||||
let store: SourceControlStore
|
||||
let height: CGFloat
|
||||
|
||||
var body: some View {
|
||||
let half = max(0, (height - Metrics.hairline) / 2).rounded(.down)
|
||||
HStack(spacing: 0) {
|
||||
VStack(spacing: 0) {
|
||||
GitBranchesPanel(model: model, store: store)
|
||||
.frame(height: half)
|
||||
Hairline()
|
||||
GitCommitsPanel(store: store)
|
||||
.frame(maxHeight: .infinity)
|
||||
}
|
||||
.frame(width: GitMetrics.sideColumnWidth)
|
||||
.background(Palette.panel)
|
||||
.hairline(.trailing)
|
||||
GitChanges(model: model, store: store)
|
||||
.frame(maxWidth: .infinity)
|
||||
GitConsolePanel(model: model, store: store)
|
||||
.frame(width: GitMetrics.consoleColumnWidth)
|
||||
.frame(maxHeight: .infinity)
|
||||
.background(Palette.panel)
|
||||
.hairline(.leading)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The console left, the branches right, 230pt tall; a wide window adds the commit list after them.
|
||||
private struct GitBottomStrip: View {
|
||||
let model: WorkspaceModel
|
||||
@@ -53,6 +104,16 @@ private struct GitBottomStrip: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// How the body under the top bar is laid out for one window width.
|
||||
enum GitBodyMode: Equatable {
|
||||
case sideColumns
|
||||
case bottomStrip
|
||||
|
||||
init(width: CGFloat) {
|
||||
self = width >= GitMetrics.sideColumnsMinWidth ? .sideColumns : .bottomStrip
|
||||
}
|
||||
}
|
||||
|
||||
/// The widths of the bottom strip's panels for one strip width.
|
||||
struct GitStripLayout: Equatable {
|
||||
var console: CGFloat
|
||||
@@ -97,6 +158,9 @@ enum GitMetrics {
|
||||
static let consoleMaxWidth: CGFloat = 820
|
||||
static let branchesMaxWidth: CGFloat = 820
|
||||
static let commitsMinWidth: CGFloat = 260
|
||||
static let sideColumnsMinWidth: CGFloat = 1600
|
||||
static let sideColumnWidth: CGFloat = 480
|
||||
static let consoleColumnWidth: CGFloat = 560
|
||||
static let stripHeader: CGFloat = 32
|
||||
static let branchRow: CGFloat = 28
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user