mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-05-05 15:33:00 +00:00
replace NSVisualEffectView with ultraThinMaterial plus a background color
This commit is contained in:
parent
3827ce9e4c
commit
1acb1715c3
@ -18,6 +18,7 @@ struct CommandOption: Identifiable, Hashable {
|
||||
|
||||
struct CommandPaletteView: View {
|
||||
@Binding var isPresented: Bool
|
||||
var backgroundColor: Color = Color(nsColor: .windowBackgroundColor)
|
||||
var options: [CommandOption]
|
||||
@State private var query = ""
|
||||
@State private var selectedIndex: UInt?
|
||||
@ -43,6 +44,12 @@ struct CommandPaletteView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@State var scheme: ColorScheme = if OSColor(backgroundColor).isLightColor {
|
||||
.light
|
||||
} else {
|
||||
.dark
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
CommandPaletteQuery(query: $query) { event in
|
||||
switch (event) {
|
||||
@ -98,7 +105,16 @@ struct CommandPaletteView: View {
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: 500)
|
||||
.background(BackgroundVisualEffectView())
|
||||
.background(
|
||||
ZStack {
|
||||
Rectangle()
|
||||
.fill(.ultraThinMaterial)
|
||||
Rectangle()
|
||||
.fill(backgroundColor)
|
||||
.blendMode(.color)
|
||||
}
|
||||
.compositingGroup()
|
||||
)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 10))
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
@ -106,6 +122,7 @@ struct CommandPaletteView: View {
|
||||
)
|
||||
.shadow(radius: 32, x: 0, y: 12)
|
||||
.padding()
|
||||
.environment(\.colorScheme, scheme)
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,23 +261,6 @@ fileprivate struct CommandRow: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// A view that creates a semi-transparent blurry background.
|
||||
fileprivate struct BackgroundVisualEffectView: NSViewRepresentable {
|
||||
func makeNSView(context: Context) -> NSVisualEffectView {
|
||||
let view = NSVisualEffectView()
|
||||
|
||||
view.blendingMode = .withinWindow
|
||||
view.state = .active
|
||||
view.material = .sidebar
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
func updateNSView(_ nsView: NSVisualEffectView, context: Context) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
/// A row of Text representing a shortcut.
|
||||
fileprivate struct ShortcutSymbolsView: View {
|
||||
let symbols: [String]
|
||||
|
@ -59,6 +59,7 @@ struct TerminalCommandPaletteView: View {
|
||||
|
||||
CommandPaletteView(
|
||||
isPresented: $isPresented,
|
||||
backgroundColor: ghosttyConfig.backgroundColor,
|
||||
options: commandOptions
|
||||
)
|
||||
.transition(
|
||||
|
Loading…
x
Reference in New Issue
Block a user