91 lines
2.8 KiB
Swift
91 lines
2.8 KiB
Swift
import HelderCore
|
|
import SwiftUI
|
|
|
|
/// ⌘G: the full-screen Git view over the title bar, the columns and the status bar.
|
|
struct GitView: View {
|
|
let model: WorkspaceModel
|
|
|
|
var body: some View {
|
|
Group {
|
|
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)
|
|
}
|
|
} else {
|
|
Color.clear
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
.background(Palette.editor)
|
|
.contentShape(Rectangle())
|
|
}
|
|
}
|
|
|
|
/// The console left, the branches right, 230pt tall.
|
|
private struct GitBottomStrip: View {
|
|
let model: WorkspaceModel
|
|
let store: SourceControlStore
|
|
|
|
var body: some View {
|
|
HStack(spacing: 0) {
|
|
GitConsolePanel(model: model, store: store)
|
|
.frame(maxWidth: .infinity)
|
|
Hairline(.vertical)
|
|
GitBranchesPanel(model: model, store: store)
|
|
.frame(maxWidth: .infinity)
|
|
}
|
|
.frame(height: GitMetrics.bottomStrip)
|
|
.background(Palette.panel)
|
|
.hairline(.top)
|
|
}
|
|
}
|
|
|
|
/// The Git view's fixed sizes, from the design handoff.
|
|
enum GitMetrics {
|
|
static let topBar: CGFloat = 44
|
|
static let topButton: CGFloat = 28
|
|
static let messageMin: CGFloat = 56
|
|
static let messageMax: CGFloat = 180
|
|
static let messageInset = CGSize(width: 16, height: 14)
|
|
static let commitFooter: CGFloat = 52
|
|
static let commitButton: CGFloat = 32
|
|
static let commitButtonMinWidth: CGFloat = 160
|
|
static let sectionHeader: CGFloat = 46
|
|
static let sectionGap: CGFloat = 28
|
|
static let fileRow: CGFloat = 36
|
|
static let accentBar: CGFloat = 3
|
|
static let actionWidth: CGFloat = 100
|
|
static let headerAction: CGFloat = 28
|
|
static let rowAction: CGFloat = 26
|
|
static let actionGap: CGFloat = 6
|
|
static let statusBadge: CGFloat = 18
|
|
static let statWidth: CGFloat = 52
|
|
static let diffLine: CGFloat = 22
|
|
static let diffGutter: CGFloat = 52
|
|
static let diffGap: CGFloat = 28
|
|
static let bottomStrip: CGFloat = 230
|
|
static let stripHeader: CGFloat = 32
|
|
static let branchRow: CGFloat = 28
|
|
}
|
|
|
|
/// A colour transition on hover, the only motion the view has.
|
|
struct HoverState: ViewModifier {
|
|
@Binding var isHovered: Bool
|
|
|
|
func body(content: Content) -> some View {
|
|
content
|
|
.onHover { isHovered = $0 }
|
|
.animation(Metrics.colorTransition, value: isHovered)
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
func tracksHover(_ isHovered: Binding<Bool>) -> some View {
|
|
modifier(HoverState(isHovered: isHovered))
|
|
}
|
|
}
|