Files
Kymo/kymo/UI/Components/TooltipMaterialBackground.swift
T

32 lines
1.0 KiB
Swift

import SwiftUI
import AppKit
/// Within-window blending blurs the chart and labels below the card's root overlay.
struct TooltipMaterialBackground: View {
@Environment(\.accessibilityReduceTransparency) private var reduceTransparency
var body: some View {
Group {
if reduceTransparency { Color(nsColor: .windowBackgroundColor) }
else {
WithinWindowMaterial()
.overlay(Color("PanelTooltip").opacity(0.12))
}
}.clipShape(.rect(cornerRadius: 7))
}
}
private struct WithinWindowMaterial: NSViewRepresentable {
func makeNSView(context: Context) -> NSVisualEffectView {
let view = PassthroughVisualEffectView()
view.material = .popover
view.blendingMode = .withinWindow
view.state = .active
return view
}
func updateNSView(_ view: NSVisualEffectView, context: Context) {}
}
private final class PassthroughVisualEffectView: NSVisualEffectView {
override func hitTest(_ point: NSPoint) -> NSView? { nil }
}