adds nice git interface
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import SwiftUI
|
||||
|
||||
/// The frame every overlay sits in: a flat ink scrim (no blur) and a `panel` card with a hairline border,
|
||||
/// radius 8 and the overlay shadow. `.inset` fills the window minus 34pt, up to 1200pt wide; `.sized` centres a fixed-width card
|
||||
/// at the top. A click on the scrim calls `onDismiss`.
|
||||
/// The frame every overlay sits in. `.sized` puts a top-aligned `panel` card on a flat ink scrim, and a click
|
||||
/// on the scrim calls `onDismiss`; `.fullScreen` fills the window edge to edge on the slate page, like the Git view.
|
||||
public struct OverlayShell<Content: View>: View {
|
||||
public enum Placement {
|
||||
/// Search, Diff: the whole window minus the 34pt inset, at most `insetOverlayMaxWidth` wide.
|
||||
case inset
|
||||
/// Search: the whole window, title bar and status bar included, with no scrim to click.
|
||||
case fullScreen
|
||||
/// A card of this width, top-aligned inside the inset.
|
||||
case sized(width: CGFloat)
|
||||
}
|
||||
@@ -15,31 +14,28 @@ public struct OverlayShell<Content: View>: View {
|
||||
var onDismiss: () -> Void
|
||||
var content: Content
|
||||
|
||||
public init(_ placement: Placement = .inset, onDismiss: @escaping () -> Void, @ViewBuilder content: () -> Content) {
|
||||
public init(_ placement: Placement, onDismiss: @escaping () -> Void, @ViewBuilder content: () -> Content) {
|
||||
self.placement = placement
|
||||
self.onDismiss = onDismiss
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
ZStack(alignment: .top) {
|
||||
Palette.scrim
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture(perform: onDismiss)
|
||||
card
|
||||
.padding(Metrics.overlayInset)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var card: some View {
|
||||
switch placement {
|
||||
case .inset:
|
||||
OverlayCard { content }
|
||||
.frame(maxWidth: Metrics.insetOverlayMaxWidth, maxHeight: .infinity)
|
||||
case .fullScreen:
|
||||
content
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(Palette.editor)
|
||||
.contentShape(Rectangle())
|
||||
case let .sized(width):
|
||||
OverlayCard { content }
|
||||
.frame(width: width)
|
||||
ZStack(alignment: .top) {
|
||||
Palette.scrim
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture(perform: onDismiss)
|
||||
OverlayCard { content }
|
||||
.frame(width: width)
|
||||
.padding(Metrics.overlayInset)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user