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
28 changes: 12 additions & 16 deletions Sources/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9781,14 +9781,12 @@ struct VerticalTabsSidebar: View {
Color.clear.frame(height: scrollInsets.bottom)
.allowsHitTesting(false)
}
.overlay(alignment: .top) {
SidebarTopScrim(height: sidebarTopScrimHeight)
.allowsHitTesting(false)
}
.overlay(alignment: .bottom) {
SidebarBottomScrim(height: sidebarBottomScrimHeight)
.allowsHitTesting(false)
}
.mask(
SidebarWorkspaceScrollEdgeFadeMask(
topHeight: sidebarTopScrimHeight,
bottomHeight: sidebarBottomScrimHeight
)
)
.overlay(alignment: .top) {
// The sidebar top strip remains draggable and handles
// double-clicks with the standard titlebar action.
Expand Down Expand Up @@ -9932,14 +9930,12 @@ struct VerticalTabsSidebar: View {
Color.clear.frame(height: SidebarWorkspaceScrollInsets.workspaceList.bottom)
.allowsHitTesting(false)
}
.overlay(alignment: .top) {
SidebarTopScrim(height: sidebarTopScrimHeight)
.allowsHitTesting(false)
}
.overlay(alignment: .bottom) {
SidebarBottomScrim(height: sidebarBottomScrimHeight)
.allowsHitTesting(false)
}
.mask(
SidebarWorkspaceScrollEdgeFadeMask(
topHeight: sidebarTopScrimHeight,
bottomHeight: sidebarBottomScrimHeight
)
)
.overlay(alignment: .top) {
WindowDragHandleView()
.frame(height: sidebarTitlebarInteractionHeight)
Expand Down
63 changes: 22 additions & 41 deletions Sources/SidebarScrim.swift
Original file line number Diff line number Diff line change
@@ -1,49 +1,43 @@
import AppKit
import SwiftUI

struct SidebarTopScrim: View {
let height: CGFloat
struct SidebarWorkspaceScrollEdgeFadeMask: View {
let topHeight: CGFloat
let bottomHeight: CGFloat

var body: some View {
SidebarEdgeScrim(height: height, edge: .top)
}
}

struct SidebarBottomScrim: View {
let height: CGFloat

var body: some View {
SidebarEdgeScrim(height: height, edge: .bottom)
VStack(spacing: 0) {
SidebarEdgeFadeGradient(edge: .top)
.frame(height: topHeight)
Rectangle()
.fill(Color.black)
SidebarEdgeFadeGradient(edge: .bottom)
.frame(height: bottomHeight)
}
}
}

struct SidebarEdgeScrim: View {
private struct SidebarEdgeFadeGradient: View {
enum Edge {
case top
case bottom
}

let height: CGFloat
let edge: Edge

var body: some View {
SidebarEdgeBlurEffect()
.frame(height: height)
.mask(
LinearGradient(
colors: gradientColors,
startPoint: .top,
endPoint: .bottom
)
)
LinearGradient(
colors: maskColors,
startPoint: .top,
endPoint: .bottom
)
}

private var gradientColors: [Color] {
private var maskColors: [Color] {
let colors = [
Color.black.opacity(0.95),
Color.black.opacity(0.75),
Color.black.opacity(0.35),
Color.clear,
Color.black.opacity(0.05),
Color.black.opacity(0.25),
Color.black.opacity(0.65),
Color.black,
]
switch edge {
case .top:
Expand All @@ -53,16 +47,3 @@ struct SidebarEdgeScrim: View {
}
}
}

struct SidebarEdgeBlurEffect: NSViewRepresentable {
func makeNSView(context: Context) -> NSVisualEffectView {
let view = NSVisualEffectView()
view.blendingMode = .withinWindow
view.material = .underWindowBackground
view.state = .active
view.isEmphasized = false
return view
}

func updateNSView(_ nsView: NSVisualEffectView, context: Context) {}
}
Loading