diff --git a/Sources/ContentView.swift b/Sources/ContentView.swift index bd6e401debff..cd36a7f4a720 100644 --- a/Sources/ContentView.swift +++ b/Sources/ContentView.swift @@ -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. @@ -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) diff --git a/Sources/SidebarScrim.swift b/Sources/SidebarScrim.swift index 87f182cd60de..b5ac091c85a3 100644 --- a/Sources/SidebarScrim.swift +++ b/Sources/SidebarScrim.swift @@ -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: @@ -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) {} -}